blob: 0610c1adedd8b672881796996dbc51050f982272 [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,
Jiyong Parke6ed0f92022-06-22 00:13:00 +090040 /// The microdroid failed to connect to VirtualizationService's RPC server.
41 MicrodroidFailedToConnectToVirtualizationService,
42 /// The payload for microdroid is changed.
43 MicrodroidPayloadHasChanged,
44 /// The microdroid failed to verify given payload APK.
45 MicrodroidPayloadVerificationFailed,
46 /// The VM config for microdroid is invalid (e.g. missing tasks).
47 MicrodroidInvalidPayloadConfig,
48 /// There was a runtime error while running microdroid manager.
49 MicrodroidUnknownRuntimeError,
50 /// The VM was killed due to hangup.
51 Hangup,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000052 /// VirtualizationService sent a death reason which was not recognised by the client library.
53 Unrecognised(AidlDeathReason),
54}
55
56impl From<AidlDeathReason> for DeathReason {
57 fn from(reason: AidlDeathReason) -> Self {
58 match reason {
59 AidlDeathReason::INFRASTRUCTURE_ERROR => Self::InfrastructureError,
60 AidlDeathReason::KILLED => Self::Killed,
61 AidlDeathReason::UNKNOWN => Self::Unknown,
62 AidlDeathReason::SHUTDOWN => Self::Shutdown,
Alan Stokes7c459e82022-12-06 12:21:49 +000063 AidlDeathReason::START_FAILED => Self::StartFailed,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000064 AidlDeathReason::REBOOT => Self::Reboot,
65 AidlDeathReason::CRASH => Self::Crash,
66 AidlDeathReason::PVM_FIRMWARE_PUBLIC_KEY_MISMATCH => Self::PvmFirmwarePublicKeyMismatch,
67 AidlDeathReason::PVM_FIRMWARE_INSTANCE_IMAGE_CHANGED => {
68 Self::PvmFirmwareInstanceImageChanged
69 }
Jiyong Parke6ed0f92022-06-22 00:13:00 +090070 AidlDeathReason::MICRODROID_FAILED_TO_CONNECT_TO_VIRTUALIZATION_SERVICE => {
71 Self::MicrodroidFailedToConnectToVirtualizationService
72 }
73 AidlDeathReason::MICRODROID_PAYLOAD_HAS_CHANGED => Self::MicrodroidPayloadHasChanged,
74 AidlDeathReason::MICRODROID_PAYLOAD_VERIFICATION_FAILED => {
75 Self::MicrodroidPayloadVerificationFailed
76 }
77 AidlDeathReason::MICRODROID_INVALID_PAYLOAD_CONFIG => {
78 Self::MicrodroidInvalidPayloadConfig
79 }
80 AidlDeathReason::MICRODROID_UNKNOWN_RUNTIME_ERROR => {
81 Self::MicrodroidUnknownRuntimeError
82 }
83 AidlDeathReason::HANGUP => Self::Hangup,
Andrew Walbrand0ef4002022-05-16 16:14:10 +000084 _ => Self::Unrecognised(reason),
85 }
86 }
87}