Fix tests on aosp_cf_x86_64_only_phone
Our nested virtualization check failed on this target. Move to a
prefix check to support this device and any other ones that appear.
Also extract the code to do the check to a library, rather than
changing in two places.
Bug: 236922543
Test: Presubmit
Change-Id: Id1d424f5f107e2098d89ca2ea8089ba956f212ca
diff --git a/virtualizationservice/Android.bp b/virtualizationservice/Android.bp
index 791da24..0c9496a 100644
--- a/virtualizationservice/Android.bp
+++ b/virtualizationservice/Android.bp
@@ -35,6 +35,7 @@
"liblog_rust",
"libmicrodroid_metadata",
"libmicrodroid_payload_config",
+ "libnested_virt",
"libnix",
"libonce_cell",
"libregex",
diff --git a/virtualizationservice/src/crosvm.rs b/virtualizationservice/src/crosvm.rs
index 7ca802f..23719a7 100644
--- a/virtualizationservice/src/crosvm.rs
+++ b/virtualizationservice/src/crosvm.rs
@@ -22,7 +22,6 @@
use log::{debug, error, info};
use semver::{Version, VersionReq};
use nix::{fcntl::OFlag, unistd::pipe2};
-use rustutils::system_properties;
use shared_child::SharedChild;
use std::borrow::Cow;
use std::fs::{remove_dir_all, File};
@@ -55,18 +54,10 @@
/// The exit status which crosvm returns when it crashes due to an error.
const CROSVM_CRASH_STATUS: i32 = 33;
-fn is_nested_virtualization() -> bool {
- // Check if we are running on vsoc as a proxy for this.
- matches!(
- system_properties::read("ro.build.product").unwrap().as_deref(),
- Some("vsoc_x86_64") | Some("vsoc_x86")
- )
-}
-
lazy_static! {
/// If the VM doesn't move to the Started state within this amount time, a hang-up error is
/// triggered.
- static ref BOOT_HANGUP_TIMEOUT: Duration = if is_nested_virtualization() {
+ static ref BOOT_HANGUP_TIMEOUT: Duration = if nested_virt::is_nested_virtualization().unwrap() {
// Nested virtualization is slow, so we need a longer timeout.
Duration::from_secs(100)
} else {