Merge "virtmgr: fail fast on misconfigured device"
diff --git a/compos/common/compos_client.rs b/compos/common/compos_client.rs
index 34be1d5..f6811cb 100644
--- a/compos/common/compos_client.rs
+++ b/compos/common/compos_client.rs
@@ -222,10 +222,10 @@
bail!("Protected VM not supported, unable to start VM");
}
- let have_unprotected_vm =
+ let have_non_protected_vm =
system_properties::read_bool("ro.boot.hypervisor.vm.supported", false)?;
- if have_unprotected_vm {
- warn!("Protected VM not supported, falling back to unprotected on debuggable build");
+ if have_non_protected_vm {
+ warn!("Protected VM not supported, falling back to non-protected on debuggable build");
return Ok(false);
}
diff --git a/javalib/src/android/system/virtualmachine/VirtualMachineConfig.java b/javalib/src/android/system/virtualmachine/VirtualMachineConfig.java
index 0e9e86b..cb4e98c 100644
--- a/javalib/src/android/system/virtualmachine/VirtualMachineConfig.java
+++ b/javalib/src/android/system/virtualmachine/VirtualMachineConfig.java
@@ -566,7 +566,7 @@
} else {
if (!HypervisorProperties.hypervisor_vm_supported().orElse(false)) {
throw new UnsupportedOperationException(
- "Unprotected VMs are not supported on this device.");
+ "Non-protected VMs are not supported on this device.");
}
}
mProtectedVm = protectedVm;
diff --git a/rialto/tests/test.rs b/rialto/tests/test.rs
index 0447cd3..b25034f 100644
--- a/rialto/tests/test.rs
+++ b/rialto/tests/test.rs
@@ -33,7 +33,7 @@
const RIALTO_PATH: &str = "/data/local/tmp/rialto_test/arm64/rialto.bin";
-/// Runs the Rialto VM as an unprotected VM via VirtualizationService.
+/// Runs the Rialto VM as a non-protected VM via VirtualizationService.
#[test]
fn test_boots() -> Result<(), Error> {
android_logger::init_once(
diff --git a/virtualizationservice/src/virtmgr.rs b/virtualizationservice/src/virtmgr.rs
index 5616097..dca64cb 100644
--- a/virtualizationservice/src/virtmgr.rs
+++ b/virtualizationservice/src/virtmgr.rs
@@ -33,6 +33,7 @@
use nix::fcntl::{fcntl, F_GETFD, F_SETFD, FdFlag};
use nix::unistd::{Pid, Uid};
use std::os::unix::raw::{pid_t, uid_t};
+use rustutils::system_properties;
const LOG_TAG: &str = "virtmgr";
@@ -91,6 +92,11 @@
Ok(unsafe { OwnedFd::from_raw_fd(raw_fd) })
}
+fn is_property_set(name: &str) -> bool {
+ system_properties::read_bool(name, false)
+ .unwrap_or_else(|e| panic!("Failed to read {name}: {e:?}"))
+}
+
fn main() {
android_logger::init_once(
android_logger::Config::default()
@@ -99,6 +105,15 @@
.with_log_id(android_logger::LogId::System),
);
+ let non_protected_vm_supported = is_property_set("ro.boot.hypervisor.vm.supported");
+ let protected_vm_supported = is_property_set("ro.boot.hypervisor.protected_vm.supported");
+ if !non_protected_vm_supported && !protected_vm_supported {
+ // This should never happen, it indicates a misconfigured device where the virt APEX
+ // is present but VMs are not supported. If it does happen, fail fast to avoid wasting
+ // resources trying.
+ panic!("Device doesn't support protected or unprotected VMs");
+ }
+
let args = Args::parse();
let mut owned_fds = vec![];
diff --git a/vm/src/main.rs b/vm/src/main.rs
index 9fa805e..f70ce54 100644
--- a/vm/src/main.rs
+++ b/vm/src/main.rs
@@ -358,15 +358,15 @@
/// Print information about supported VM types.
fn command_info() -> Result<(), Error> {
- let unprotected_vm_supported =
+ let non_protected_vm_supported =
system_properties::read_bool("ro.boot.hypervisor.vm.supported", false)?;
let protected_vm_supported =
system_properties::read_bool("ro.boot.hypervisor.protected_vm.supported", false)?;
- match (unprotected_vm_supported, protected_vm_supported) {
+ match (non_protected_vm_supported, protected_vm_supported) {
(false, false) => println!("VMs are not supported."),
(false, true) => println!("Only protected VMs are supported."),
- (true, false) => println!("Only unprotected VMs are supported."),
- (true, true) => println!("Both protected and unprotected VMs are supported."),
+ (true, false) => println!("Only non-protected VMs are supported."),
+ (true, true) => println!("Both protected and non-protected VMs are supported."),
}
if let Some(version) = system_properties::read("ro.boot.hypervisor.version")? {