mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: support removing devices before VM is booted
If the VM has been configured but not yet booted, all we need to do to support removing a device is to remove it from the config, so it will never be created. Signed-off-by: Alyssa Ross <hi@alyssa.is>
This commit is contained in:
+9
-2
@@ -1025,13 +1025,20 @@ impl Vmm {
|
||||
fn vm_remove_device(&mut self, id: String) -> result::Result<(), VmError> {
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
if let Err(e) = vm.remove_device(id) {
|
||||
error!("Error when removing new device to the VM: {:?}", e);
|
||||
error!("Error when removing device from the VM: {:?}", e);
|
||||
Err(e)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
} else if let Some(ref config) = self.vm_config {
|
||||
let mut config = config.lock().unwrap();
|
||||
if config.remove_device(&id) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(VmError::NoDeviceToRemove(id))
|
||||
}
|
||||
} else {
|
||||
Err(VmError::VmNotRunning)
|
||||
Err(VmError::VmNotCreated)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user