Enable --extended-status for crosvm and return reason why VM died.
This will allow us to detect guest VM kernel panics because they can be
configured to reboot on panic.
Bug: 211704107
Test: Ran some VMs manually with vm tool
Change-Id: I3845bb9d569ad0dc098013b527b69b31352e7e08
diff --git a/vm/src/run.rs b/vm/src/run.rs
index 19982ea..8583fe2 100644
--- a/vm/src/run.rs
+++ b/vm/src/run.rs
@@ -17,7 +17,8 @@
use crate::create_partition::command_create_partition;
use crate::sync::AtomicFlag;
use android_system_virtualizationservice::aidl::android::system::virtualizationservice::{
- IVirtualMachine::IVirtualMachine, IVirtualMachineCallback::BnVirtualMachineCallback,
+ DeathReason::DeathReason, IVirtualMachine::IVirtualMachine,
+ IVirtualMachineCallback::BnVirtualMachineCallback,
IVirtualMachineCallback::IVirtualMachineCallback,
IVirtualizationService::IVirtualizationService, PartitionType::PartitionType,
VirtualMachineAppConfig::DebugLevel::DebugLevel,
@@ -286,13 +287,17 @@
Ok(())
}
- fn onDied(&self, _cid: i32) -> BinderResult<()> {
- // No need to explicitly report the event to the user (e.g. via println!) because this
- // callback is registered only when the vm tool is invoked as interactive mode (e.g. not
- // --daemonize) in which case the tool will exit to the shell prompt upon VM shutdown.
- // Printing something will actually even confuse the user as the output from the app
- // payload is printed.
+ fn onDied(&self, _cid: i32, reason: DeathReason) -> BinderResult<()> {
self.dead.raise();
+
+ match reason {
+ DeathReason::SHUTDOWN => println!("VM shutdown cleanly."),
+ DeathReason::REBOOT => println!("VM tried to reboot, possibly due to a kernel panic."),
+ DeathReason::KILLED => println!("VM was killed."),
+ DeathReason::UNKNOWN => println!("VM died for an unknown reason."),
+ DeathReason::INFRASTRUCTURE_ERROR => println!("Error waiting for VM to finish."),
+ _ => println!("VM died for an unrecognised reason."),
+ }
Ok(())
}
}