mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
pci: Add a function to remove a PciDevice from the bus
Simple function relying on the retain() method from std::Vec, allowing to remove every occurence of the same device. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
08604ac6a8
commit
f8e2008e0e
@ -124,6 +124,11 @@ impl PciBus {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn remove_by_device(&mut self, device: &Arc<Mutex<dyn PciDevice>>) -> Result<()> {
|
||||
self.devices.retain(|dev| !Arc::ptr_eq(dev, device));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn next_device_id(&self) -> u32 {
|
||||
self.devices.len() as u32
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user