mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 11:22:26 +00:00
vmm: Update VmConfig when removing VFIO device
This commit ensures that when a VFIO device is hot-unplugged from the VM, it is also removed from the VmConfig. This prevents a potential reboot from creating the device. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
81173bf4ab
commit
e514b124ed
@ -584,9 +584,24 @@ impl Vm {
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.remove_device(_id)
|
||||
.remove_device(_id.clone())
|
||||
.map_err(Error::DeviceManager)?;
|
||||
|
||||
// Update VmConfig by removing the device. This is important to
|
||||
// ensure the device would not be created in case of a reboot.
|
||||
{
|
||||
let mut config = self.config.lock().unwrap();
|
||||
if let Some(devices) = config.devices.as_mut() {
|
||||
devices.retain(|dev| {
|
||||
if let Some(dev_id) = &dev.id {
|
||||
*dev_id != _id
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
Loading…
x
Reference in New Issue
Block a user