From d45a68c96006cc8d1874916ff95435b8c71ab440 Mon Sep 17 00:00:00 2001 From: Nuno Das Neves Date: Wed, 24 Apr 2024 21:23:29 +0000 Subject: [PATCH] ioctls: Rework run vp Update run vp interface to not take a hv_message unnecessarily, and work with the new MSHV_RUN_VP which takes a plain buffer. Signed-off-by: Nuno Das Neves --- mshv-ioctls/src/ioctls/vcpu.rs | 10 +++++----- mshv-ioctls/src/mshv_ioctls.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mshv-ioctls/src/ioctls/vcpu.rs b/mshv-ioctls/src/ioctls/vcpu.rs index 8a35ab6..2908554 100644 --- a/mshv-ioctls/src/ioctls/vcpu.rs +++ b/mshv-ioctls/src/ioctls/vcpu.rs @@ -738,13 +738,14 @@ impl VcpuFd { Ok(0_usize) } /// Triggers the running of the current virtual CPU returning an exit reason. - pub fn run(&self, mut hv_message_input: hv_message) -> Result { + pub fn run(&self) -> Result { + let mut msg = hv_message::default(); // SAFETY: we know that our file is a vCPU fd and we verify the return result. - let ret = unsafe { ioctl_with_mut_ref(self, MSHV_RUN_VP(), &mut hv_message_input) }; + let ret = unsafe { ioctl_with_mut_ref(self, MSHV_RUN_VP(), &mut msg) }; if ret != 0 { return Err(errno::Error::last().into()); } - Ok(hv_message_input) + Ok(msg) } /// Returns currently pending exceptions, interrupts, and NMIs as well as related /// states of the vcpu. @@ -1485,10 +1486,9 @@ mod tests { ]) .unwrap(); - let hv_message: hv_message = unsafe { std::mem::zeroed() }; let mut done = false; loop { - let ret_hv_message: hv_message = vcpu.run(hv_message).unwrap(); + let ret_hv_message = vcpu.run().unwrap(); match ret_hv_message.header.message_type { hv_message_type_HVMSG_X64_HALT => { println!("VM Halted!"); diff --git a/mshv-ioctls/src/mshv_ioctls.rs b/mshv-ioctls/src/mshv_ioctls.rs index 6bb7755..7d8c06f 100644 --- a/mshv-ioctls/src/mshv_ioctls.rs +++ b/mshv-ioctls/src/mshv_ioctls.rs @@ -10,7 +10,7 @@ ioctl_iow_nr!(MSHV_GET_VERSION_INFO, MSHV_IOCTL, 0x00, mshv_version_info); ioctl_iow_nr!(MSHV_CREATE_VP, MSHV_IOCTL, 0x04, mshv_create_vp); ioctl_iowr_nr!(MSHV_GET_VP_REGISTERS, MSHV_IOCTL, 0x05, mshv_vp_registers); ioctl_iow_nr!(MSHV_SET_VP_REGISTERS, MSHV_IOCTL, 0x06, mshv_vp_registers); -ioctl_ior_nr!(MSHV_RUN_VP, MSHV_IOCTL, 0x07, hv_message); +ioctl_ior_nr!(MSHV_RUN_VP, MSHV_IOCTL, 0x00, mshv_run_vp); #[cfg(target_arch = "x86_64")] ioctl_iowr_nr!(MSHV_GET_VP_STATE, MSHV_IOCTL, 0x0A, mshv_get_set_vp_state); #[cfg(target_arch = "x86_64")]