mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 03:12:27 +00:00
vmm: Exit VMM event loop after guest shutdown for AArch64
X86 and AArch64 work in different ways to shutdown a VM. X86 exit VMM event loop through ACPI device; AArch64 need to exit from CPU loop of a SystemEvent. Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
parent
5cd1730bc4
commit
97a1e5e1d2
@ -23,6 +23,8 @@ use arch::EntryPoint;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use arch::{CpuidPatch, CpuidReg};
|
||||
use devices::{interrupt_controller::InterruptController, BusDevice};
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use kvm_bindings::KVM_SYSTEM_EVENT_SHUTDOWN;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use kvm_bindings::{
|
||||
kvm_fpu, kvm_lapic_state, kvm_mp_state, kvm_regs, kvm_sregs, kvm_vcpu_events, kvm_xcrs,
|
||||
@ -368,6 +370,20 @@ impl Vcpu {
|
||||
// Triple fault to trigger a reboot
|
||||
Ok(false)
|
||||
}
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
VcpuExit::SystemEvent(event_type, flags) => {
|
||||
// On Aarch64, when the VM is shutdown, run() returns
|
||||
// VcpuExit::SystemEvent with reason KVM_SYSTEM_EVENT_SHUTDOWN
|
||||
if event_type == KVM_SYSTEM_EVENT_SHUTDOWN {
|
||||
Ok(false)
|
||||
} else {
|
||||
error!(
|
||||
"Unexpected system event with type 0x{:x}, flags 0x{:x}",
|
||||
event_type, flags
|
||||
);
|
||||
Err(Error::VcpuUnhandledKvmExit)
|
||||
}
|
||||
}
|
||||
r => {
|
||||
error!("Unexpected exit reason on vcpu run: {:?}", r);
|
||||
Err(Error::VcpuUnhandledKvmExit)
|
||||
|
@ -365,7 +365,8 @@ impl Vmm {
|
||||
#[cfg(not(feature = "acpi"))]
|
||||
{
|
||||
if self.vm.is_some() {
|
||||
return self.vm_shutdown();
|
||||
self.exit_evt.write(1).unwrap();
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user