vmm: Unreference the VM when shutting down

This way, we are forced to re-create the VM object when moving from
shutdown to boot.

Fixes: #321

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2019-10-08 11:20:09 +02:00
parent 14eb071b29
commit 228adebc32

View File

@ -252,7 +252,7 @@ impl Vmm {
}
fn vm_shutdown(&mut self) -> result::Result<(), VmError> {
if let Some(ref mut vm) = self.vm {
if let Some(ref mut vm) = self.vm.take() {
vm.shutdown()
} else {
Err(VmError::VmNotBooted)
@ -312,13 +312,10 @@ impl Vmm {
return Ok(());
}
self.vm_config = None;
// First we try to shut the current VM down.
self.vm_shutdown()?;
// First we shut the current VM down if necessary.
if let Some(ref mut vm) = self.vm {
vm.shutdown()?;
self.vm = None;
}
self.vm_config = None;
Ok(())
}