mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-08 19:33:07 +00:00
devices: vmwdt: Add watchdog reset reboot reason
When we detect a VCPU stall we propagate the watchdog reboot error code to the event tube. The newly added error code WATCHDOG_REBOOT = 36 is returned from the crovm process. Bug: 245900797 Test: manual testing, build and Virtualization apk on a device Signed-off-by: Sebastian Ene <sebastianene@google.com> Change-Id: Ib1ce97de911784b33d130d40536be26813edc3d7 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3936647 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
cc8e94dc59
commit
b5edcab20b
6 changed files with 21 additions and 2 deletions
|
@ -191,4 +191,5 @@ pub enum VmEventType {
|
|||
Reset,
|
||||
Crash,
|
||||
Panic(u8),
|
||||
WatchdogReset,
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ impl Vmwdt {
|
|||
} else {
|
||||
// The guest ran but it did not send the periodic event
|
||||
if let Err(_e) =
|
||||
reset_evt_wrtube.send::<VmEventType>(&VmEventType::Reset)
|
||||
reset_evt_wrtube.send::<VmEventType>(&VmEventType::WatchdogReset)
|
||||
{
|
||||
error!("failed to send reset event from vcpu {}", cpu_id)
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ mod tests {
|
|||
// Verify that our timer expired and the next_expiration_interval_ms changed
|
||||
match vm_evt_rdtube.recv::<VmEventType>() {
|
||||
Ok(vm_event) => {
|
||||
assert!(vm_event == VmEventType::Reset);
|
||||
assert!(vm_event == VmEventType::WatchdogReset);
|
||||
}
|
||||
Err(_e) => {
|
||||
panic!();
|
||||
|
|
|
@ -1213,6 +1213,7 @@ pub enum ExitState {
|
|||
Stop,
|
||||
Crash,
|
||||
GuestPanic,
|
||||
WatchdogReset,
|
||||
}
|
||||
// Remove ranges in `guest_mem_layout` that overlap with ranges in `file_backed_mappings`.
|
||||
// Returns the updated guest memory layout.
|
||||
|
@ -2465,6 +2466,10 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
info!("Guest reported panic [Code: {}]", pvpanic_code);
|
||||
break_to_wait = false;
|
||||
}
|
||||
VmEventType::WatchdogReset => {
|
||||
info!("vcpu stall detected");
|
||||
exit_state = ExitState::WatchdogReset;
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
warn!("failed to recv VmEvent: {}", e);
|
||||
|
|
|
@ -733,6 +733,7 @@ where
|
|||
ExitState::Crash => VmEventType::Crash,
|
||||
// vcpu_loop doesn't exit with GuestPanic.
|
||||
ExitState::GuestPanic => unreachable!(),
|
||||
ExitState::WatchdogReset => VmEventType::WatchdogReset,
|
||||
};
|
||||
if let Err(e) = vm_evt_wrtube.send::<VmEventType>(&final_event_data) {
|
||||
error!(
|
||||
|
|
|
@ -90,6 +90,8 @@ enum CommandStatus {
|
|||
GuestPanic = 34,
|
||||
/// Invalid argument was given to crosvm.
|
||||
InvalidArgs = 35,
|
||||
/// VM exit due to vcpu stall detection.
|
||||
WatchdogReset = 36,
|
||||
}
|
||||
|
||||
impl CommandStatus {
|
||||
|
@ -100,6 +102,7 @@ impl CommandStatus {
|
|||
Self::VmCrash => "exiting with crash",
|
||||
Self::GuestPanic => "exiting with guest panic",
|
||||
Self::InvalidArgs => "invalid argument",
|
||||
Self::WatchdogReset => "exiting with watchdog reset",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,6 +125,10 @@ fn to_command_status(result: Result<sys::ExitState>) -> Result<CommandStatus> {
|
|||
info!("crosvm has exited due to a kernel panic in guest");
|
||||
Ok(CommandStatus::GuestPanic)
|
||||
}
|
||||
Ok(sys::ExitState::WatchdogReset) => {
|
||||
info!("crosvm has exited due to watchdog reboot");
|
||||
Ok(CommandStatus::WatchdogReset)
|
||||
}
|
||||
Err(e) => {
|
||||
error!("crosvm has exited with error: {:#}", e);
|
||||
Err(e)
|
||||
|
|
|
@ -233,6 +233,7 @@ pub enum ExitState {
|
|||
Crash,
|
||||
#[allow(dead_code)]
|
||||
GuestPanic,
|
||||
WatchdogReset,
|
||||
}
|
||||
|
||||
type DeviceResult<T = VirtioDeviceStub> = Result<T>;
|
||||
|
@ -966,6 +967,10 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
VmEventType::Panic(_) => {
|
||||
error!("got pvpanic event. this event is not expected on Windows.");
|
||||
}
|
||||
VmEventType::WatchdogReset => {
|
||||
info!("vcpu stall detected");
|
||||
exit_state = ExitState::WatchdogReset;
|
||||
}
|
||||
}
|
||||
break 'poll;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue