mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
Samuel Ortiz
parent
ebe8edd423
commit
ae66a44d26
+9
-5
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user