Skip to content

Commit

Permalink
mshv-ioctls/vcpu: Add index field to vcpu fd
Browse files Browse the repository at this point in the history
This will be used with the generic hvcall ioctl for vcpus.

Signed-off-by: Nuno Das Neves <nudasnev@microsoft.com>
  • Loading branch information
NunoDasNeves committed Jan 17, 2024
1 parent 9058a7b commit 7e183db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions mshv-ioctls/src/ioctls/vcpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ macro_rules! set_registers_64 {
#[derive(Debug)]
/// Wrapper over Mshv vCPU ioctls.
pub struct VcpuFd {
index: u32,
vcpu: File,
}

Expand All @@ -52,8 +53,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 {
Expand Down
2 changes: 1 addition & 1 deletion mshv-ioctls/src/ioctls/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down

0 comments on commit 7e183db

Please sign in to comment.