mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
hypervisor: drop create_device from Vm trait
This then avoids the need for creating a generic DeviceFd type in the hypervisor crate. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
@@ -314,6 +314,20 @@ pub struct KvmVm {
|
||||
dirty_log_slots: Arc<RwLock<HashMap<u32, KvmDirtyLogSlot>>>,
|
||||
}
|
||||
|
||||
impl KvmVm {
|
||||
///
|
||||
/// Creates an emulated device in the kernel.
|
||||
///
|
||||
/// See the documentation for `KVM_CREATE_DEVICE`.
|
||||
fn create_device(&self, device: &mut CreateDevice) -> vm::Result<Arc<dyn device::Device>> {
|
||||
let device_fd = self
|
||||
.fd
|
||||
.create_device(device)
|
||||
.map_err(|e| vm::HypervisorVmError::CreateDevice(e.into()))?;
|
||||
Ok(Arc::new(device_fd))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Implementation of Vm trait for KVM
|
||||
/// Example:
|
||||
@@ -616,17 +630,6 @@ impl vm::Vm for KvmVm {
|
||||
}
|
||||
}
|
||||
///
|
||||
/// Creates an emulated device in the kernel.
|
||||
///
|
||||
/// See the documentation for `KVM_CREATE_DEVICE`.
|
||||
fn create_device(&self, device: &mut CreateDevice) -> vm::Result<Arc<dyn device::Device>> {
|
||||
let device_fd = self
|
||||
.fd
|
||||
.create_device(device)
|
||||
.map_err(|e| vm::HypervisorVmError::CreateDevice(e.into()))?;
|
||||
Ok(Arc::new(device_fd))
|
||||
}
|
||||
///
|
||||
/// Returns the preferred CPU target type which can be emulated by KVM on underlying host.
|
||||
///
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
|
||||
Reference in New Issue
Block a user