mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
crosvm: support VM shutdown via SystemEvent
ARM systems don't have an exit event fd like x86, instead one of the Vcpus will exit with the SystemEvent reason and put a code into the kvm run union of either shutdown, reboot, or crash. We currently don't handle reboot or crash differently but can do so in the future. BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on kevin - manually test shutdown via maitred Change-Id: I455cbe1ac653f61a1e9eae1ce22922d14cff4e3c Reviewed-on: https://chromium-review.googlesource.com/982531 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
This commit is contained in:
parent
62a4063aa6
commit
6ce158fb86
2 changed files with 13 additions and 2 deletions
|
@ -696,7 +696,9 @@ pub enum VcpuExit<'a> {
|
|||
Watchdog,
|
||||
S390Tsch,
|
||||
Epr,
|
||||
SystemEvent,
|
||||
/// The cpu triggered a system level event which is specified by the type field.
|
||||
/// The possible events are shutdown, reset, or crash.
|
||||
SystemEvent(u32 /* event_type*/, u64 /* flags */),
|
||||
}
|
||||
|
||||
/// A wrapper around creating and using a VCPU.
|
||||
|
@ -803,7 +805,13 @@ impl Vcpu {
|
|||
KVM_EXIT_WATCHDOG => Ok(VcpuExit::Watchdog),
|
||||
KVM_EXIT_S390_TSCH => Ok(VcpuExit::S390Tsch),
|
||||
KVM_EXIT_EPR => Ok(VcpuExit::Epr),
|
||||
KVM_EXIT_SYSTEM_EVENT => Ok(VcpuExit::SystemEvent),
|
||||
KVM_EXIT_SYSTEM_EVENT => {
|
||||
// Safe because we know the exit reason told us this union
|
||||
// field is valid
|
||||
let event_type = unsafe { run.__bindgen_anon_1.system_event.type_ };
|
||||
let event_flags = unsafe { run.__bindgen_anon_1.system_event.flags };
|
||||
Ok(VcpuExit::SystemEvent(event_type, event_flags))
|
||||
},
|
||||
r => panic!("unknown kvm exit reason: {}", r),
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -468,6 +468,9 @@ fn run_vcpu(vcpu: Vcpu,
|
|||
}
|
||||
VcpuExit::Hlt => break,
|
||||
VcpuExit::Shutdown => break,
|
||||
VcpuExit::SystemEvent(_, _) =>
|
||||
//TODO handle reboot and crash events
|
||||
kill_signaled.store(true, Ordering::SeqCst),
|
||||
r => warn!("unexpected vcpu exit: {:?}", r),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue