blob: c417a7c7f4b2aa65186907c0ab1a9d382df80df0 [file] [log] [blame]
Andrew Walbrand0ef4002022-05-16 16:14:10 +00001// Copyright 2022, The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
David Brazdil49f96f52022-12-16 21:29:13 +000015use android_system_virtualizationcommon::aidl::android::system::virtualizationcommon::DeathReason::DeathReason as AidlDeathReason;
Andrew Walbrand0ef4002022-05-16 16:14:10 +000016
17/// The reason why a VM died.
18#[derive(Clone, Copy, Debug, Eq, PartialEq)]
19pub enum DeathReason {
20 /// VirtualizationService died.
21 VirtualizationServiceDied,
22 /// There was an error waiting for the VM.
23 InfrastructureError,
24 /// The VM was killed.
25 Killed,
26 /// The VM died for an unknown reason.
27 Unknown,
28 /// The VM requested to shut down.
29 Shutdown,
30 /// crosvm had an error starting the VM.
Alan Stokes7c459e82022-12-06 12:21:49 +000031 StartFailed,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000032 /// The VM requested to reboot, possibly as the result of a kernel panic.
33 Reboot,
34 /// The VM or crosvm crashed.
35 Crash,
36 /// The pVM firmware failed to verify the VM because the public key doesn't match.
37 PvmFirmwarePublicKeyMismatch,
38 /// The pVM firmware failed to verify the VM because the instance image changed.
39 PvmFirmwareInstanceImageChanged,
40 /// The bootloader failed to verify the VM because the public key doesn't match.
41 BootloaderPublicKeyMismatch,
42 /// The bootloader failed to verify the VM because the instance image changed.
43 BootloaderInstanceImageChanged,
Jiyong Parke6ed0f92022-06-22 00:13:00 +090044 /// The microdroid failed to connect to VirtualizationService's RPC server.
45 MicrodroidFailedToConnectToVirtualizationService,
46 /// The payload for microdroid is changed.
47 MicrodroidPayloadHasChanged,
48 /// The microdroid failed to verify given payload APK.
49 MicrodroidPayloadVerificationFailed,
50 /// The VM config for microdroid is invalid (e.g. missing tasks).
51 MicrodroidInvalidPayloadConfig,
52 /// There was a runtime error while running microdroid manager.
53 MicrodroidUnknownRuntimeError,
54 /// The VM was killed due to hangup.
55 Hangup,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000056 /// VirtualizationService sent a death reason which was not recognised by the client library.
57 Unrecognised(AidlDeathReason),
58}
59
60impl From<AidlDeathReason> for DeathReason {
61 fn from(reason: AidlDeathReason) -> Self {
62 match reason {
63 AidlDeathReason::INFRASTRUCTURE_ERROR => Self::InfrastructureError,
64 AidlDeathReason::KILLED => Self::Killed,
65 AidlDeathReason::UNKNOWN => Self::Unknown,
66 AidlDeathReason::SHUTDOWN => Self::Shutdown,
Alan Stokes7c459e82022-12-06 12:21:49 +000067 AidlDeathReason::START_FAILED => Self::StartFailed,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000068 AidlDeathReason::REBOOT => Self::Reboot,
69 AidlDeathReason::CRASH => Self::Crash,
70 AidlDeathReason::PVM_FIRMWARE_PUBLIC_KEY_MISMATCH => Self::PvmFirmwarePublicKeyMismatch,
71 AidlDeathReason::PVM_FIRMWARE_INSTANCE_IMAGE_CHANGED => {
72 Self::PvmFirmwareInstanceImageChanged
73 }
74 AidlDeathReason::BOOTLOADER_PUBLIC_KEY_MISMATCH => Self::BootloaderPublicKeyMismatch,
75 AidlDeathReason::BOOTLOADER_INSTANCE_IMAGE_CHANGED => {
76 Self::BootloaderInstanceImageChanged
77 }
Jiyong Parke6ed0f92022-06-22 00:13:00 +090078 AidlDeathReason::MICRODROID_FAILED_TO_CONNECT_TO_VIRTUALIZATION_SERVICE => {
79 Self::MicrodroidFailedToConnectToVirtualizationService
80 }
81 AidlDeathReason::MICRODROID_PAYLOAD_HAS_CHANGED => Self::MicrodroidPayloadHasChanged,
82 AidlDeathReason::MICRODROID_PAYLOAD_VERIFICATION_FAILED => {
83 Self::MicrodroidPayloadVerificationFailed
84 }
85 AidlDeathReason::MICRODROID_INVALID_PAYLOAD_CONFIG => {
86 Self::MicrodroidInvalidPayloadConfig
87 }
88 AidlDeathReason::MICRODROID_UNKNOWN_RUNTIME_ERROR => {
89 Self::MicrodroidUnknownRuntimeError
90 }
91 AidlDeathReason::HANGUP => Self::Hangup,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000092 _ => Self::Unrecognised(reason),
93 }
94 }
95}