blob: 34d89fc7775e306f0916f106116597fd40932f3b [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
Andrew Walbrand0ef4002022-05-16 16:14:10 +000015use android_system_virtualizationservice::{
16 aidl::android::system::virtualizationservice::{
17 DeathReason::DeathReason as AidlDeathReason}};
18
19/// The reason why a VM died.
20#[derive(Clone, Copy, Debug, Eq, PartialEq)]
21pub enum DeathReason {
22 /// VirtualizationService died.
23 VirtualizationServiceDied,
24 /// There was an error waiting for the VM.
25 InfrastructureError,
26 /// The VM was killed.
27 Killed,
28 /// The VM died for an unknown reason.
29 Unknown,
30 /// The VM requested to shut down.
31 Shutdown,
32 /// crosvm had an error starting the VM.
Alan Stokes7c459e82022-12-06 12:21:49 +000033 StartFailed,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000034 /// The VM requested to reboot, possibly as the result of a kernel panic.
35 Reboot,
36 /// The VM or crosvm crashed.
37 Crash,
38 /// The pVM firmware failed to verify the VM because the public key doesn't match.
39 PvmFirmwarePublicKeyMismatch,
40 /// The pVM firmware failed to verify the VM because the instance image changed.
41 PvmFirmwareInstanceImageChanged,
42 /// The bootloader failed to verify the VM because the public key doesn't match.
43 BootloaderPublicKeyMismatch,
44 /// The bootloader failed to verify the VM because the instance image changed.
45 BootloaderInstanceImageChanged,
Jiyong Parke6ed0f92022-06-22 00:13:00 +090046 /// The microdroid failed to connect to VirtualizationService's RPC server.
47 MicrodroidFailedToConnectToVirtualizationService,
48 /// The payload for microdroid is changed.
49 MicrodroidPayloadHasChanged,
50 /// The microdroid failed to verify given payload APK.
51 MicrodroidPayloadVerificationFailed,
52 /// The VM config for microdroid is invalid (e.g. missing tasks).
53 MicrodroidInvalidPayloadConfig,
54 /// There was a runtime error while running microdroid manager.
55 MicrodroidUnknownRuntimeError,
56 /// The VM was killed due to hangup.
57 Hangup,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000058 /// VirtualizationService sent a death reason which was not recognised by the client library.
59 Unrecognised(AidlDeathReason),
60}
61
62impl From<AidlDeathReason> for DeathReason {
63 fn from(reason: AidlDeathReason) -> Self {
64 match reason {
65 AidlDeathReason::INFRASTRUCTURE_ERROR => Self::InfrastructureError,
66 AidlDeathReason::KILLED => Self::Killed,
67 AidlDeathReason::UNKNOWN => Self::Unknown,
68 AidlDeathReason::SHUTDOWN => Self::Shutdown,
Alan Stokes7c459e82022-12-06 12:21:49 +000069 AidlDeathReason::START_FAILED => Self::StartFailed,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000070 AidlDeathReason::REBOOT => Self::Reboot,
71 AidlDeathReason::CRASH => Self::Crash,
72 AidlDeathReason::PVM_FIRMWARE_PUBLIC_KEY_MISMATCH => Self::PvmFirmwarePublicKeyMismatch,
73 AidlDeathReason::PVM_FIRMWARE_INSTANCE_IMAGE_CHANGED => {
74 Self::PvmFirmwareInstanceImageChanged
75 }
76 AidlDeathReason::BOOTLOADER_PUBLIC_KEY_MISMATCH => Self::BootloaderPublicKeyMismatch,
77 AidlDeathReason::BOOTLOADER_INSTANCE_IMAGE_CHANGED => {
78 Self::BootloaderInstanceImageChanged
79 }
Jiyong Parke6ed0f92022-06-22 00:13:00 +090080 AidlDeathReason::MICRODROID_FAILED_TO_CONNECT_TO_VIRTUALIZATION_SERVICE => {
81 Self::MicrodroidFailedToConnectToVirtualizationService
82 }
83 AidlDeathReason::MICRODROID_PAYLOAD_HAS_CHANGED => Self::MicrodroidPayloadHasChanged,
84 AidlDeathReason::MICRODROID_PAYLOAD_VERIFICATION_FAILED => {
85 Self::MicrodroidPayloadVerificationFailed
86 }
87 AidlDeathReason::MICRODROID_INVALID_PAYLOAD_CONFIG => {
88 Self::MicrodroidInvalidPayloadConfig
89 }
90 AidlDeathReason::MICRODROID_UNKNOWN_RUNTIME_ERROR => {
91 Self::MicrodroidUnknownRuntimeError
92 }
93 AidlDeathReason::HANGUP => Self::Hangup,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000094 _ => Self::Unrecognised(reason),
95 }
96 }
97}