Skip to content

Commit 23d0a73

Browse files
committed
Add missing VFD to epoll entries
1 parent 6455470 commit 23d0a73

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/tinykvm/machine_state.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct ColdStartFds {
3535
struct ColdStartEpollEntry {
3636
size_t epoll_fds;
3737
size_t shared_epoll_fds;
38+
int vfd;
3839
};
3940
struct ColdStartEpollFd {
4041
int vfd;
@@ -148,15 +149,13 @@ bool Machine::load_snapshot_state()
148149
fdm.set_vfd_start(fds->next_vfd);
149150
for (size_t i = 0; i < fds->epoll_entries; i++) {
150151
ColdStartEpollEntry* centry = state.next<ColdStartEpollEntry>(current);
151-
auto& our_entries = fdm.get_epoll_entries();
152+
auto& entry = fdm.get_epoll_entry_for_vfd(centry->vfd);
152153
for (size_t j = 0; j < centry->epoll_fds; j++) {
153154
ColdStartEpollFd* cefd = state.next<ColdStartEpollFd>(current);
154-
auto& entry = fdm.get_epoll_entry_for_vfd(cefd->vfd);
155155
entry.epoll_fds[cefd->vfd] = cefd->event;
156156
}
157157
for (size_t j = 0; j < centry->shared_epoll_fds; j++) {
158158
ColdStartSharedEpollFd* csefd = state.next<ColdStartSharedEpollFd>(current);
159-
auto& entry = fdm.get_epoll_entry_for_vfd(csefd->vfd);
160159
entry.shared_epoll_fds.insert(csefd->vfd);
161160
}
162161
}
@@ -232,6 +231,7 @@ void Machine::save_snapshot_state_now() const
232231
// Epoll reconstruction entries
233232
for (const auto& [vfd, entry] : epoll_entries) {
234233
ColdStartEpollEntry* centry = state.next<ColdStartEpollEntry>(current);
234+
centry->vfd = vfd;
235235
centry->epoll_fds = entry->epoll_fds.size();
236236
centry->shared_epoll_fds = entry->shared_epoll_fds.size();
237237
for (const auto& [evfd, event] : entry->epoll_fds) {
@@ -268,16 +268,16 @@ void Machine::save_snapshot_state_now() const
268268
}
269269

270270
} catch (const MachineException& me) {
271-
throw std::runtime_error(std::string("Failed to get cold start state: ") + me.what());
271+
throw std::runtime_error(std::string("Failed to get snapshot state: ") + me.what());
272272
}
273273
}
274274

275275
void* vMemory::get_snapshot_state_area() const
276276
{
277277
if (!this->has_snapshot_area) {
278-
throw std::runtime_error("No cold start state area allocated");
278+
throw std::runtime_error("No snapshot state area allocated");
279279
}
280-
// The cold start state area is after the end of the memory
280+
// The snapshot state area is after the end of the memory
281281
return (void*)(this->ptr + this->size);
282282
}
283283
bool vMemory::has_loadable_snapshot_state() const noexcept
@@ -302,8 +302,8 @@ void* Machine::get_snapshot_state_user_area() const
302302
if (state.size < sizeof(SnapshotState) || state.size > SnapshotState::Size()) {
303303
return nullptr;
304304
}
305-
// The user area is after the SnapshotState + size
306-
return reinterpret_cast<char*>(map) + sizeof(SnapshotState) + state.size;
305+
// The user area is after the SnapshotState base + size
306+
return reinterpret_cast<char*>(map) + state.size;
307307
}
308308

309309
} // namespace tinykvm

0 commit comments

Comments
 (0)