mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: api: Introduce new "remove-device" HTTP endpoint
This commit introduces the new command "remove-device" that will let a user hot-unplug a VFIO PCI device from an already running VM. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
991f3bb5da
commit
6cbdb9aa47
@@ -236,6 +236,10 @@ pub enum DeviceManagerError {
|
||||
|
||||
/// Failed removing a bus device from the MMIO bus.
|
||||
RemoveDeviceFromMmioBus(devices::BusError),
|
||||
|
||||
/// Failed to find VFIO device corresponding to the given identifier.
|
||||
#[cfg(feature = "pci_support")]
|
||||
UnknownVfioDeviceId(String),
|
||||
}
|
||||
pub type DeviceManagerResult<T> = result::Result<T, DeviceManagerError>;
|
||||
|
||||
@@ -1791,6 +1795,18 @@ impl DeviceManager {
|
||||
Ok(device_cfg)
|
||||
}
|
||||
|
||||
#[cfg(feature = "pci_support")]
|
||||
pub fn remove_device(&mut self, id: String) -> DeviceManagerResult<()> {
|
||||
if let Some(pci_device_bdf) = self.pci_id_list.get(&id) {
|
||||
// Update the PCID bitmap
|
||||
self.pci_devices_down |= 1 << (*pci_device_bdf >> 3);
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
Err(DeviceManagerError::UnknownVfioDeviceId(id))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "pci_support")]
|
||||
pub fn eject_device(&mut self, device_id: u8) -> DeviceManagerResult<()> {
|
||||
// Retrieve the PCI bus.
|
||||
|
||||
Reference in New Issue
Block a user