Skip to content

Commit a2a8bc4

Browse files
committed
fix(test): dont drop guest memory before using it
Dropping a GuestMemoryMmap causes the memory to get unmapped, so if we try to KVM_RUN after dropping it, we'll just get EFAULT. Admittedly no idea how we didn't run into this issue before. Signed-off-by: Patrick Roy <[email protected]>
1 parent d7ecc32 commit a2a8bc4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/vmm/src/vstate/vcpu/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ pub(crate) mod tests {
965965
entry_addr.unwrap().kernel_load
966966
}
967967

968-
fn vcpu_configured_for_boot() -> (VcpuHandle, vmm_sys_util::eventfd::EventFd) {
968+
fn vcpu_configured_for_boot() -> (VcpuHandle, EventFd, GuestMemoryMmap) {
969969
Vcpu::register_kick_signal_handler();
970970
// Need enough mem to boot linux.
971971
let mem_size = 64 << 20;
@@ -1017,7 +1017,7 @@ pub(crate) mod tests {
10171017
// Wait for vCPUs to initialize their TLS before moving forward.
10181018
barrier.wait();
10191019

1020-
(vcpu_handle, vcpu_exit_evt)
1020+
(vcpu_handle, vcpu_exit_evt, vm_mem)
10211021
}
10221022

10231023
#[test]
@@ -1151,7 +1151,7 @@ pub(crate) mod tests {
11511151

11521152
#[test]
11531153
fn test_vcpu_pause_resume() {
1154-
let (vcpu_handle, vcpu_exit_evt) = vcpu_configured_for_boot();
1154+
let (vcpu_handle, vcpu_exit_evt, _) = vcpu_configured_for_boot();
11551155

11561156
// Queue a Resume event, expect a response.
11571157
queue_event_expect_response(&vcpu_handle, VcpuEvent::Resume, VcpuResponse::Resumed);
@@ -1183,7 +1183,7 @@ pub(crate) mod tests {
11831183

11841184
#[test]
11851185
fn test_vcpu_save_state_events() {
1186-
let (vcpu_handle, _vcpu_exit_evt) = vcpu_configured_for_boot();
1186+
let (vcpu_handle, _vcpu_exit_evt, _) = vcpu_configured_for_boot();
11871187

11881188
// Queue a Resume event, expect a response.
11891189
queue_event_expect_response(&vcpu_handle, VcpuEvent::Resume, VcpuResponse::Resumed);
@@ -1216,7 +1216,7 @@ pub(crate) mod tests {
12161216

12171217
#[test]
12181218
fn test_vcpu_dump_cpu_config() {
1219-
let (vcpu_handle, _) = vcpu_configured_for_boot();
1219+
let (vcpu_handle, _, _) = vcpu_configured_for_boot();
12201220

12211221
// Queue a DumpCpuConfig event, expect a DumpedCpuConfig response.
12221222
vcpu_handle

0 commit comments

Comments
 (0)