hypervisor: mshv: create_device returns DeviceFd directly

This aligns with KVM's code. No functional change.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2022-07-20 19:16:19 +00:00 committed by Liu Wei
parent c5e966c972
commit eca6609dbb

View File

@ -918,12 +918,12 @@ impl MshvVm {
/// Creates an in-kernel device. /// Creates an in-kernel device.
/// ///
/// See the documentation for `MSHV_CREATE_DEVICE`. /// See the documentation for `MSHV_CREATE_DEVICE`.
fn create_device(&self, device: &mut CreateDevice) -> vm::Result<Arc<dyn device::Device>> { fn create_device(&self, device: &mut CreateDevice) -> vm::Result<DeviceFd> {
let device_fd = self let device_fd = self
.fd .fd
.create_device(device) .create_device(device)
.map_err(|e| vm::HypervisorVmError::CreateDevice(e.into()))?; .map_err(|e| vm::HypervisorVmError::CreateDevice(e.into()))?;
Ok(Arc::new(device_fd)) Ok(device_fd)
} }
} }
@ -1117,8 +1117,9 @@ impl vm::Vm for MshvVm {
flags: 0, flags: 0,
}; };
self.create_device(&mut vfio_dev) Ok(Arc::new(self.create_device(&mut vfio_dev).map_err(
.map_err(|e| vm::HypervisorVmError::CreatePassthroughDevice(e.into())) |e| vm::HypervisorVmError::CreatePassthroughDevice(e.into()),
)?))
} }
/// ///