Skip to content

Commit

Permalink
fix(test): dont drop guest memory before using it
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
roypat committed Feb 13, 2025
1 parent edb31d8 commit 21779af
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/vmm/src/vstate/vcpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ pub(crate) mod tests {
entry_addr.unwrap().kernel_load
}

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

(vcpu_handle, vcpu_exit_evt)
(vcpu_handle, vcpu_exit_evt, vm_mem)
}

#[test]
Expand Down Expand Up @@ -1155,7 +1155,7 @@ pub(crate) mod tests {

#[test]
fn test_vcpu_pause_resume() {
let (vcpu_handle, vcpu_exit_evt) = vcpu_configured_for_boot();
let (vcpu_handle, vcpu_exit_evt, _mem) = vcpu_configured_for_boot();

// Queue a Resume event, expect a response.
queue_event_expect_response(&vcpu_handle, VcpuEvent::Resume, VcpuResponse::Resumed);
Expand Down Expand Up @@ -1187,7 +1187,7 @@ pub(crate) mod tests {

#[test]
fn test_vcpu_save_state_events() {
let (vcpu_handle, _vcpu_exit_evt) = vcpu_configured_for_boot();
let (vcpu_handle, _vcpu_exit_evt, _) = vcpu_configured_for_boot();

// Queue a Resume event, expect a response.
queue_event_expect_response(&vcpu_handle, VcpuEvent::Resume, VcpuResponse::Resumed);
Expand Down Expand Up @@ -1220,7 +1220,7 @@ pub(crate) mod tests {

#[test]
fn test_vcpu_dump_cpu_config() {
let (vcpu_handle, _) = vcpu_configured_for_boot();
let (vcpu_handle, _, _) = vcpu_configured_for_boot();

// Queue a DumpCpuConfig event, expect a DumpedCpuConfig response.
vcpu_handle
Expand Down

0 comments on commit 21779af

Please sign in to comment.