mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-03-20 07:58:55 +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")]
|
||||
AllocateBars(pci::PciDeviceError),
|
||||
|
||||
/// Could not free the BARs associated with a PCI device.
|
||||
#[cfg(feature = "pci_support")]
|
||||
FreePciBars(pci::PciDeviceError),
|
||||
|
||||
/// Cannot register ioevent.
|
||||
RegisterIoevent(kvm_ioctls::Error),
|
||||
|
||||
@ -1861,6 +1865,13 @@ impl DeviceManager {
|
||||
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
|
||||
pci.lock()
|
||||
.unwrap()
|
||||
|
Loading…
x
Reference in New Issue
Block a user