mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-22 20:45:21 +00:00
vmm: vm: Remove device from configuration after unplug
This ensures that a device that is removed will not reappear after a reboot. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
444e5c2a04
commit
f9a0445c3d
@ -710,14 +710,25 @@ impl Vm {
|
||||
// ensure the device would not be created in case of a reboot.
|
||||
{
|
||||
let mut config = self.config.lock().unwrap();
|
||||
|
||||
// Remove if VFIO device
|
||||
if let Some(devices) = config.devices.as_mut() {
|
||||
devices.retain(|dev| {
|
||||
if let Some(dev_id) = &dev.id {
|
||||
*dev_id != _id
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
devices.retain(|dev| dev.id.as_ref() != Some(&_id));
|
||||
}
|
||||
|
||||
// Remove if disk device
|
||||
if let Some(disks) = config.disks.as_mut() {
|
||||
disks.retain(|dev| dev.id.as_ref() != Some(&_id));
|
||||
}
|
||||
|
||||
// Remove if net device
|
||||
if let Some(net) = config.net.as_mut() {
|
||||
net.retain(|dev| dev.id.as_ref() != Some(&_id));
|
||||
}
|
||||
|
||||
// Remove if pmem device
|
||||
if let Some(pmem) = config.pmem.as_mut() {
|
||||
pmem.retain(|dev| dev.id.as_ref() != Some(&_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user