vmm: Support both reset and shutdown

Add a 2nd EventFd to the VM to control resetting (rebooting) the VM this
supplements the EventFd used for managing shutdown of the VM.

The default behaviour on i8042 or triple-fault based reset is currently
unchanged i.e. it will trigger a shutdown.

In order to support restarting the VM it was necessary to make start()
function take a reference to the config.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2019-08-29 14:51:45 +01:00
committed by Samuel Ortiz
parent ebe8edd423
commit ae66a44d26
3 changed files with 44 additions and 16 deletions
+9 -5
View File
@@ -15,7 +15,7 @@ pub mod config;
pub mod vm;
use self::config::VmConfig;
use self::vm::Vm;
use self::vm::{ExitBehaviour, Vm};
/// Errors associated with VM management
#[derive(Debug)]
@@ -55,11 +55,15 @@ impl Vmm {
}
pub fn boot_kernel(config: VmConfig) -> Result<()> {
let vmm = Vmm::new()?;
let mut vm = Vm::new(&vmm.kvm, config).map_err(Error::VmNew)?;
loop {
let vmm = Vmm::new()?;
let mut vm = Vm::new(&vmm.kvm, &config).map_err(Error::VmNew)?;
let entry = vm.load_kernel().map_err(Error::LoadKernel)?;
vm.start(entry).map_err(Error::VmStart)?;
let entry = vm.load_kernel().map_err(Error::LoadKernel)?;
if vm.start(entry).map_err(Error::VmStart)? == ExitBehaviour::Shutdown {
break;
}
}
Ok(())
}