mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Activate virtio device from VMM thread
When a device is ready to be activated signal to the VMM thread via an EventFd that there is a device to be activated. When the VMM receives a notification on the EventFd that there is a device to be activated notify the device manager to attempt to activate any devices that have not been activated. As a side effect the VMM thread will create the virtio device threads. Fixes: #1863 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -227,6 +227,9 @@ pub enum Error {
|
||||
|
||||
/// Failed setting the VmmOps interface.
|
||||
SetVmmOpsInterface(hypervisor::HypervisorVmError),
|
||||
|
||||
/// Cannot activate virtio devices
|
||||
ActivateVirtioDevices(device_manager::DeviceManagerError),
|
||||
}
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
@@ -488,6 +491,7 @@ impl Vm {
|
||||
seccomp_action: &SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
#[cfg(feature = "kvm")] _saved_clock: Option<hypervisor::ClockData>,
|
||||
activate_evt: EventFd,
|
||||
) -> Result<Self> {
|
||||
config
|
||||
.lock()
|
||||
@@ -509,6 +513,7 @@ impl Vm {
|
||||
seccomp_action.clone(),
|
||||
#[cfg(feature = "acpi")]
|
||||
numa_nodes.clone(),
|
||||
&activate_evt,
|
||||
)
|
||||
.map_err(Error::DeviceManager)?;
|
||||
|
||||
@@ -646,6 +651,7 @@ impl Vm {
|
||||
reset_evt: EventFd,
|
||||
seccomp_action: &SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
activate_evt: EventFd,
|
||||
) -> Result<Self> {
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
hypervisor.check_required_extensions().unwrap();
|
||||
@@ -682,6 +688,7 @@ impl Vm {
|
||||
hypervisor,
|
||||
#[cfg(feature = "kvm")]
|
||||
None,
|
||||
activate_evt,
|
||||
)?;
|
||||
|
||||
// The device manager must create the devices from here as it is part
|
||||
@@ -704,6 +711,7 @@ impl Vm {
|
||||
prefault: bool,
|
||||
seccomp_action: &SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
activate_evt: EventFd,
|
||||
) -> Result<Self> {
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
hypervisor.check_required_extensions().unwrap();
|
||||
@@ -746,6 +754,7 @@ impl Vm {
|
||||
hypervisor,
|
||||
#[cfg(feature = "kvm")]
|
||||
None,
|
||||
activate_evt,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -755,6 +764,7 @@ impl Vm {
|
||||
reset_evt: EventFd,
|
||||
seccomp_action: &SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
activate_evt: EventFd,
|
||||
) -> Result<Self> {
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
hypervisor.check_required_extensions().unwrap();
|
||||
@@ -781,6 +791,7 @@ impl Vm {
|
||||
hypervisor,
|
||||
#[cfg(feature = "kvm")]
|
||||
None,
|
||||
activate_evt,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1739,6 +1750,14 @@ impl Vm {
|
||||
pub fn device_tree(&self) -> Arc<Mutex<DeviceTree>> {
|
||||
self.device_manager.lock().unwrap().device_tree()
|
||||
}
|
||||
|
||||
pub fn activate_virtio_devices(&self) -> Result<()> {
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.activate_virtio_devices()
|
||||
.map_err(Error::ActivateVirtioDevices)
|
||||
}
|
||||
}
|
||||
|
||||
impl Pausable for Vm {
|
||||
|
||||
Reference in New Issue
Block a user