Don't use non-protected VMs for CompOS
We originally allowed this, on debuggable builds only, for testing
purposes - Cuttlefish doesn't support protected VMs.
But it's a bad idea, and we don't test on Cuttlefish anyway.
Bug: 342092886
Test: atest CompOsSigningHostTest
Change-Id: I90dfc67f3fa878ed12b8bcc183b873e8eb354307
diff --git a/compos/common/compos_client.rs b/compos/common/compos_client.rs
index 6914380..107f8d0 100644
--- a/compos/common/compos_client.rs
+++ b/compos/common/compos_client.rs
@@ -36,7 +36,6 @@
use glob::glob;
use log::{info, warn};
use platformproperties::hypervisorproperties;
-use rustutils::system_properties;
use std::fs::File;
use std::path::{Path, PathBuf};
use vmclient::{DeathReason, ErrorCode, VmInstance, VmWaitError};
@@ -80,7 +79,11 @@
idsig_manifest_ext_apk: &Path,
parameters: &VmParameters,
) -> Result<Self> {
- let protected_vm = want_protected_vm()?;
+ let have_protected_vm =
+ hypervisorproperties::hypervisor_protected_vm_supported()?.unwrap_or(false);
+ if !have_protected_vm {
+ bail!("Protected VM not supported, unable to start VM");
+ }
let instance_fd = ParcelFileDescriptor::new(instance_image);
@@ -133,7 +136,7 @@
payload: Payload::ConfigPath(config_path),
debugLevel: debug_level,
extraIdsigs: extra_idsigs,
- protectedVm: protected_vm,
+ protectedVm: true,
memoryMib: parameters.memory_mib.unwrap_or(0), // 0 means use the default
cpuTopology: cpu_topology,
customConfig: custom_config,
@@ -236,28 +239,6 @@
Ok(idsig_fd)
}
-fn want_protected_vm() -> Result<bool> {
- let have_protected_vm =
- hypervisorproperties::hypervisor_protected_vm_supported()?.unwrap_or(false);
- if have_protected_vm {
- info!("Starting protected VM");
- return Ok(true);
- }
-
- let is_debug_build = system_properties::read("ro.debuggable")?.as_deref().unwrap_or("0") == "1";
- if !is_debug_build {
- bail!("Protected VM not supported, unable to start VM");
- }
-
- let have_non_protected_vm = hypervisorproperties::hypervisor_vm_supported()?.unwrap_or(false);
- if have_non_protected_vm {
- warn!("Protected VM not supported, falling back to non-protected on debuggable build");
- return Ok(false);
- }
-
- bail!("No VM support available")
-}
-
struct Callback {}
impl vmclient::VmCallback for Callback {
fn on_payload_started(&self, cid: i32) {