diff --git a/mshv-ioctls/src/ioctls/vcpu.rs b/mshv-ioctls/src/ioctls/vcpu.rs index 84a4c5e2..76d128e6 100644 --- a/mshv-ioctls/src/ioctls/vcpu.rs +++ b/mshv-ioctls/src/ioctls/vcpu.rs @@ -43,6 +43,7 @@ macro_rules! set_registers_64 { #[derive(Debug)] /// Wrapper over Mshv vCPU ioctls. pub struct VcpuFd { + index: u32, vcpu: File, } @@ -51,8 +52,8 @@ pub struct VcpuFd { /// This should not be exported as a public function because the preferred way is to use /// `create_vcpu` from `VmFd`. The function cannot be part of the `VcpuFd` implementation because /// then it would be exported with the public `VcpuFd` interface. -pub fn new_vcpu(vcpu: File) -> VcpuFd { - VcpuFd { vcpu } +pub fn new_vcpu(index: u32, vcpu: File) -> VcpuFd { + VcpuFd { index, vcpu } } impl AsRawFd for VcpuFd { diff --git a/mshv-ioctls/src/ioctls/vm.rs b/mshv-ioctls/src/ioctls/vm.rs index 70bdc9f6..1d28ae68 100644 --- a/mshv-ioctls/src/ioctls/vm.rs +++ b/mshv-ioctls/src/ioctls/vm.rs @@ -202,7 +202,7 @@ impl VmFd { // SAFETY: we're sure vcpu_fd is valid. let vcpu = unsafe { File::from_raw_fd(vcpu_fd) }; - Ok(new_vcpu(vcpu)) + Ok(new_vcpu(id as u32, vcpu)) } /// Inject an interrupt into the guest.. pub fn request_virtual_interrupt(&self, request: &InterruptRequest) -> Result<()> {