Give a better name to STOP_REASON_ERROR

It indicates crosvm failed to start the VM, so
STOP_REASON_START_FAILED.

Slightly gratuitously I also renamed the internal DeathReason - mainly
because this is just a much clearer name.

I didn't change the statslog version, because that would just be too
complicated.

Bug: 261037705
Test: atest MicrodroidTests
Change-Id: I5effdba86ea49ff919d82810926fb14ccbbd8499
diff --git a/javalib/api/system-current.txt b/javalib/api/system-current.txt
index f38d8fd..f364f4c 100644
--- a/javalib/api/system-current.txt
+++ b/javalib/api/system-current.txt
@@ -38,7 +38,6 @@
     field public static final int STOP_REASON_BOOTLOADER_INSTANCE_IMAGE_CHANGED = 10; // 0xa
     field public static final int STOP_REASON_BOOTLOADER_PUBLIC_KEY_MISMATCH = 9; // 0x9
     field public static final int STOP_REASON_CRASH = 6; // 0x6
-    field public static final int STOP_REASON_ERROR = 4; // 0x4
     field public static final int STOP_REASON_HANGUP = 16; // 0x10
     field public static final int STOP_REASON_INFRASTRUCTURE_ERROR = 0; // 0x0
     field public static final int STOP_REASON_KILLED = 1; // 0x1
@@ -51,6 +50,7 @@
     field public static final int STOP_REASON_PVM_FIRMWARE_PUBLIC_KEY_MISMATCH = 7; // 0x7
     field public static final int STOP_REASON_REBOOT = 5; // 0x5
     field public static final int STOP_REASON_SHUTDOWN = 3; // 0x3
+    field public static final int STOP_REASON_START_FAILED = 4; // 0x4
     field public static final int STOP_REASON_UNKNOWN = 2; // 0x2
     field public static final int STOP_REASON_VIRTUALIZATION_SERVICE_DIED = -1; // 0xffffffff
   }
diff --git a/javalib/src/android/system/virtualmachine/VirtualMachine.java b/javalib/src/android/system/virtualmachine/VirtualMachine.java
index 63b5628..0305650 100644
--- a/javalib/src/android/system/virtualmachine/VirtualMachine.java
+++ b/javalib/src/android/system/virtualmachine/VirtualMachine.java
@@ -26,7 +26,6 @@
 import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_BOOTLOADER_INSTANCE_IMAGE_CHANGED;
 import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_BOOTLOADER_PUBLIC_KEY_MISMATCH;
 import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_CRASH;
-import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_ERROR;
 import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_HANGUP;
 import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_INFRASTRUCTURE_ERROR;
 import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_KILLED;
@@ -39,6 +38,7 @@
 import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_PVM_FIRMWARE_PUBLIC_KEY_MISMATCH;
 import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_REBOOT;
 import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_SHUTDOWN;
+import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_START_FAILED;
 import static android.system.virtualmachine.VirtualMachineCallback.STOP_REASON_UNKNOWN;
 
 import static java.util.Objects.requireNonNull;
@@ -1034,8 +1034,8 @@
                 return STOP_REASON_KILLED;
             case DeathReason.SHUTDOWN:
                 return STOP_REASON_SHUTDOWN;
-            case DeathReason.ERROR:
-                return STOP_REASON_ERROR;
+            case DeathReason.START_FAILED:
+                return STOP_REASON_START_FAILED;
             case DeathReason.REBOOT:
                 return STOP_REASON_REBOOT;
             case DeathReason.CRASH:
diff --git a/javalib/src/android/system/virtualmachine/VirtualMachineCallback.java b/javalib/src/android/system/virtualmachine/VirtualMachineCallback.java
index f3c4831..fad2fa9 100644
--- a/javalib/src/android/system/virtualmachine/VirtualMachineCallback.java
+++ b/javalib/src/android/system/virtualmachine/VirtualMachineCallback.java
@@ -58,26 +58,28 @@
 
     /** @hide */
     @Retention(RetentionPolicy.SOURCE)
-    @IntDef(prefix = "STOP_REASON_", value = {
-        STOP_REASON_VIRTUALIZATION_SERVICE_DIED,
-        STOP_REASON_INFRASTRUCTURE_ERROR,
-        STOP_REASON_KILLED,
-        STOP_REASON_UNKNOWN,
-        STOP_REASON_SHUTDOWN,
-        STOP_REASON_ERROR,
-        STOP_REASON_REBOOT,
-        STOP_REASON_CRASH,
-        STOP_REASON_PVM_FIRMWARE_PUBLIC_KEY_MISMATCH,
-        STOP_REASON_PVM_FIRMWARE_INSTANCE_IMAGE_CHANGED,
-        STOP_REASON_BOOTLOADER_PUBLIC_KEY_MISMATCH,
-        STOP_REASON_BOOTLOADER_INSTANCE_IMAGE_CHANGED,
-        STOP_REASON_MICRODROID_FAILED_TO_CONNECT_TO_VIRTUALIZATION_SERVICE,
-        STOP_REASON_MICRODROID_PAYLOAD_HAS_CHANGED,
-        STOP_REASON_MICRODROID_PAYLOAD_VERIFICATION_FAILED,
-        STOP_REASON_MICRODROID_INVALID_PAYLOAD_CONFIG,
-        STOP_REASON_MICRODROID_UNKNOWN_RUNTIME_ERROR,
-        STOP_REASON_HANGUP,
-    })
+    @IntDef(
+            prefix = "STOP_REASON_",
+            value = {
+                STOP_REASON_VIRTUALIZATION_SERVICE_DIED,
+                STOP_REASON_INFRASTRUCTURE_ERROR,
+                STOP_REASON_KILLED,
+                STOP_REASON_UNKNOWN,
+                STOP_REASON_SHUTDOWN,
+                STOP_REASON_START_FAILED,
+                STOP_REASON_REBOOT,
+                STOP_REASON_CRASH,
+                STOP_REASON_PVM_FIRMWARE_PUBLIC_KEY_MISMATCH,
+                STOP_REASON_PVM_FIRMWARE_INSTANCE_IMAGE_CHANGED,
+                STOP_REASON_BOOTLOADER_PUBLIC_KEY_MISMATCH,
+                STOP_REASON_BOOTLOADER_INSTANCE_IMAGE_CHANGED,
+                STOP_REASON_MICRODROID_FAILED_TO_CONNECT_TO_VIRTUALIZATION_SERVICE,
+                STOP_REASON_MICRODROID_PAYLOAD_HAS_CHANGED,
+                STOP_REASON_MICRODROID_PAYLOAD_VERIFICATION_FAILED,
+                STOP_REASON_MICRODROID_INVALID_PAYLOAD_CONFIG,
+                STOP_REASON_MICRODROID_UNKNOWN_RUNTIME_ERROR,
+                STOP_REASON_HANGUP,
+            })
     @interface StopReason {}
 
     /** The virtualization service itself died, taking the VM down with it. */
@@ -98,7 +100,7 @@
     int STOP_REASON_SHUTDOWN = 3;
 
     /** crosvm had an error starting the VM. */
-    int STOP_REASON_ERROR = 4;
+    int STOP_REASON_START_FAILED = 4;
 
     /** The VM requested to reboot, possibly as the result of a kernel panic. */
     int STOP_REASON_REBOOT = 5;
diff --git a/virtualizationservice/aidl/android/system/virtualizationservice/DeathReason.aidl b/virtualizationservice/aidl/android/system/virtualizationservice/DeathReason.aidl
index 416eb7b..0980630 100644
--- a/virtualizationservice/aidl/android/system/virtualizationservice/DeathReason.aidl
+++ b/virtualizationservice/aidl/android/system/virtualizationservice/DeathReason.aidl
@@ -29,7 +29,7 @@
     /** The VM requested to shut down. */
     SHUTDOWN = 3,
     /** crosvm had an error starting the VM. */
-    ERROR = 4,
+    START_FAILED = 4,
     /** The VM requested to reboot, possibly as the result of a kernel panic. */
     REBOOT = 5,
     /** The VM or crosvm crashed. */
diff --git a/virtualizationservice/src/atom.rs b/virtualizationservice/src/atom.rs
index 9c74d1e..85e37af 100644
--- a/virtualizationservice/src/atom.rs
+++ b/virtualizationservice/src/atom.rs
@@ -182,7 +182,7 @@
                 DeathReason::KILLED => vm_exited::DeathReason::Killed,
                 DeathReason::UNKNOWN => vm_exited::DeathReason::Unknown,
                 DeathReason::SHUTDOWN => vm_exited::DeathReason::Shutdown,
-                DeathReason::ERROR => vm_exited::DeathReason::Error,
+                DeathReason::START_FAILED => vm_exited::DeathReason::Error,
                 DeathReason::REBOOT => vm_exited::DeathReason::Reboot,
                 DeathReason::CRASH => vm_exited::DeathReason::Crash,
                 DeathReason::PVM_FIRMWARE_PUBLIC_KEY_MISMATCH => {
diff --git a/virtualizationservice/src/crosvm.rs b/virtualizationservice/src/crosvm.rs
index 0fdc293..406054c 100644
--- a/virtualizationservice/src/crosvm.rs
+++ b/virtualizationservice/src/crosvm.rs
@@ -62,7 +62,7 @@
 const CROSVM_PLATFORM_VERSION: &str = "1.0.0";
 
 /// The exit status which crosvm returns when it has an error starting a VM.
-const CROSVM_ERROR_STATUS: i32 = 1;
+const CROSVM_START_ERROR_STATUS: i32 = 1;
 /// The exit status which crosvm returns when a VM requests a reboot.
 const CROSVM_REBOOT_STATUS: i32 = 32;
 /// The exit status which crosvm returns when it crashes due to an error.
@@ -637,7 +637,7 @@
         match status.code() {
             None => DeathReason::KILLED,
             Some(0) => DeathReason::SHUTDOWN,
-            Some(CROSVM_ERROR_STATUS) => DeathReason::ERROR,
+            Some(CROSVM_START_ERROR_STATUS) => DeathReason::START_FAILED,
             Some(CROSVM_REBOOT_STATUS) => DeathReason::REBOOT,
             Some(CROSVM_CRASH_STATUS) => DeathReason::CRASH,
             Some(CROSVM_WATCHDOG_REBOOT_STATUS) => DeathReason::WATCHDOG_REBOOT,
diff --git a/vmclient/src/death_reason.rs b/vmclient/src/death_reason.rs
index fbf2523..34d89fc 100644
--- a/vmclient/src/death_reason.rs
+++ b/vmclient/src/death_reason.rs
@@ -30,7 +30,7 @@
     /// The VM requested to shut down.
     Shutdown,
     /// crosvm had an error starting the VM.
-    Error,
+    StartFailed,
     /// The VM requested to reboot, possibly as the result of a kernel panic.
     Reboot,
     /// The VM or crosvm crashed.
@@ -66,7 +66,7 @@
             AidlDeathReason::KILLED => Self::Killed,
             AidlDeathReason::UNKNOWN => Self::Unknown,
             AidlDeathReason::SHUTDOWN => Self::Shutdown,
-            AidlDeathReason::ERROR => Self::Error,
+            AidlDeathReason::START_FAILED => Self::StartFailed,
             AidlDeathReason::REBOOT => Self::Reboot,
             AidlDeathReason::CRASH => Self::Crash,
             AidlDeathReason::PVM_FIRMWARE_PUBLIC_KEY_MISMATCH => Self::PvmFirmwarePublicKeyMismatch,