mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +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:
committed by
Rob Bradford
parent
08604ac6a8
commit
f8e2008e0e
@@ -124,6 +124,11 @@ impl PciBus {
|
|||||||
Ok(())
|
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 {
|
pub fn next_device_id(&self) -> u32 {
|
||||||
self.devices.len() as u32
|
self.devices.len() as u32
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user