Merge "virtmgr: Support early VM from /system/[system_ext/product]" into main
diff --git a/android/virtmgr/src/aidl.rs b/android/virtmgr/src/aidl.rs
index f684a2a..6aecc75 100644
--- a/android/virtmgr/src/aidl.rs
+++ b/android/virtmgr/src/aidl.rs
@@ -425,6 +425,11 @@
Some(path) => path,
None => return Ok("system".to_owned()),
};
+ if path.starts_with("/system/system_ext/") {
+ return Ok("system_ext".to_owned());
+ } else if path.starts_with("/system/product/") {
+ return Ok("product".to_owned());
+ }
let mut components = path.components();
match components.nth(1) {
Some(std::path::Component::Normal(partition)) => {
@@ -482,7 +487,10 @@
.or_service_specific_exception(-1)
}
};
- if Path::new(&early_vm.path) != calling_exe_path {
+ let expected_exe_path = Path::new(&early_vm.path);
+ if expected_exe_path != calling_exe_path
+ && Path::new("/system").join(expected_exe_path) != calling_exe_path
+ {
return Err(anyhow!(
"VM '{name}' in partition '{calling_partition}' must be created with '{}', not '{}'",
&early_vm.path,
@@ -2655,6 +2663,22 @@
}
#[test]
+ fn test_symlink_to_system_ext_supported() -> Result<()> {
+ let link_path = Path::new("/system/system_ext/file");
+ let partition = find_partition(Some(link_path)).unwrap();
+ assert_eq!("system_ext", partition);
+ Ok(())
+ }
+
+ #[test]
+ fn test_symlink_to_product_supported() -> Result<()> {
+ let link_path = Path::new("/system/product/file");
+ let partition = find_partition(Some(link_path)).unwrap();
+ assert_eq!("product", partition);
+ Ok(())
+ }
+
+ #[test]
fn test_duplicated_early_vms() -> Result<()> {
let tmp_dir = tempfile::TempDir::new()?;
let tmp_dir_path = tmp_dir.path().to_owned();