Skip to content

Commit f207c51

Browse files
committed
Add some verbose remote prints
1 parent 56acdc7 commit f207c51

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/tinykvm/machine.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ void Machine::reset_to(std::string_view binary, const MachineOptions& options)
144144
if (UNLIKELY(this->is_forked() || this->is_forkable())) {
145145
throw MachineException("Machine is forked or forkable, cannot be reset");
146146
}
147+
/* Disconnect from the remote, if it's still connected */
148+
this->remote_disconnect();
149+
147150
this->m_mmap_cache = {};
148151
this->m_mt.reset(nullptr);
149152
this->m_signals.reset(nullptr);
@@ -165,6 +168,9 @@ bool Machine::reset_to(const Machine& other, const MachineOptions& options)
165168
assert(m_forked && other.m_prepped &&
166169
"This machine must be forked, and the source must be prepped");
167170

171+
/* Disconnect from the remote, if it's still connected */
172+
this->remote_disconnect();
173+
168174
bool full_reset = false;
169175
if (UNLIKELY(this->m_binary.begin() != other.m_binary.begin() ||
170176
memory.compare(other.memory) == false))

lib/tinykvm/remote.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "amd64/usercode.hpp"
44

55
namespace tinykvm {
6+
static constexpr bool VERBOSE_REMOTE = false;
67

78
Machine& Machine::remote()
89
{
@@ -62,6 +63,10 @@ void Machine::remote_connect(Machine& remote, bool connect_now)
6263

6364
// Finalize
6465
this->m_remote = &remote;
66+
if constexpr (VERBOSE_REMOTE) {
67+
fprintf(stderr, "Remote connected: this VM %p remote VM %p (%s)\n",
68+
this, &remote, connect_now ? "just-in-time" : "setup");
69+
}
6570
}
6671

6772
Machine::address_t Machine::remote_activate_now()
@@ -102,6 +107,9 @@ Machine::address_t Machine::remote_disconnect()
102107
// Restore original FSBASE
103108
auto tls_base = this->vcpu.remote_original_tls_base;
104109
this->vcpu.remote_original_tls_base = 0;
110+
if constexpr (VERBOSE_REMOTE) {
111+
fprintf(stderr, "Remote disconnected: this VM %p remote VM %p\n", this, this->m_remote);
112+
}
105113
return tls_base;
106114
}
107115
bool Machine::is_remote_connected() const noexcept

0 commit comments

Comments
 (0)