Skip to content

Commit

Permalink
ioctls: Rework run vp
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
NunoDasNeves committed May 7, 2024
1 parent af0efed commit d45a68c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions mshv-ioctls/src/ioctls/vcpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<hv_message> {
pub fn run(&self) -> Result<hv_message> {
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.
Expand Down Expand Up @@ -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!");
Expand Down
2 changes: 1 addition & 1 deletion mshv-ioctls/src/mshv_ioctls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit d45a68c

Please sign in to comment.