mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 21:15:45 +00:00
vmm: Free PCI BARs when unplugging PCI device
Now that PciDevice trait has a dedicated function to remove the bars, the DeviceManager can invoke this function whenever a PCI device is unplugged from the VM. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
f0dff8b58c
commit
432eb5b70a
@ -135,6 +135,10 @@ pub enum DeviceManagerError {
|
|||||||
#[cfg(feature = "pci_support")]
|
#[cfg(feature = "pci_support")]
|
||||||
AllocateBars(pci::PciDeviceError),
|
AllocateBars(pci::PciDeviceError),
|
||||||
|
|
||||||
|
/// Could not free the BARs associated with a PCI device.
|
||||||
|
#[cfg(feature = "pci_support")]
|
||||||
|
FreePciBars(pci::PciDeviceError),
|
||||||
|
|
||||||
/// Cannot register ioevent.
|
/// Cannot register ioevent.
|
||||||
RegisterIoevent(kvm_ioctls::Error),
|
RegisterIoevent(kvm_ioctls::Error),
|
||||||
|
|
||||||
@ -1861,6 +1865,13 @@ impl DeviceManager {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Free the allocated BARs
|
||||||
|
pci_device
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.free_bars(&mut self.address_manager.allocator.lock().unwrap())
|
||||||
|
.map_err(DeviceManagerError::FreePciBars)?;
|
||||||
|
|
||||||
// Remove the device from the PCI bus
|
// Remove the device from the PCI bus
|
||||||
pci.lock()
|
pci.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user