Add early_virtmgr

early_virtmgr will serve early VMs available before /data mount.
early_virtmgr will use a separate domain from virtmgr because early VMs
and regular VMs differ.

Bug: 354059066
Test: run early_virtmgr
Change-Id: I783c429842e2596963d36bf1ac85c551b1133860
diff --git a/android/virtmgr/Android.bp b/android/virtmgr/Android.bp
index ae85934..a21ee6c 100644
--- a/android/virtmgr/Android.bp
+++ b/android/virtmgr/Android.bp
@@ -87,6 +87,14 @@
     apex_available: ["com.android.virt"],
 }
 
+rust_binary {
+    name: "early_virtmgr",
+    defaults: ["virtualizationmanager_defaults"],
+    srcs: ["src/main.rs"],
+    cfgs: ["early"],
+    apex_available: ["com.android.virt"],
+}
+
 rust_test {
     name: "virtualizationmanager_device_test",
     srcs: ["src/main.rs"],
diff --git a/android/virtmgr/src/main.rs b/android/virtmgr/src/main.rs
index 4e88507..445260f 100644
--- a/android/virtmgr/src/main.rs
+++ b/android/virtmgr/src/main.rs
@@ -131,7 +131,11 @@
     // Start thread pool for kernel Binder connection to VirtualizationServiceInternal.
     ProcessState::start_thread_pool();
 
-    GLOBAL_SERVICE.removeMemlockRlimit().expect("Failed to remove memlock rlimit");
+    if cfg!(early) {
+        panic!("Early VM not implemented");
+    } else {
+        GLOBAL_SERVICE.removeMemlockRlimit().expect("Failed to remove memlock rlimit");
+    }
 
     let service = VirtualizationService::init();
     let service =
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index 5e74aca..8de7b61 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -45,6 +45,7 @@
     config_namespace: "ANDROID",
     bool_variables: [
         "release_avf_enable_device_assignment",
+        "release_avf_enable_early_vm",
         "release_avf_enable_llpvm_changes",
         "release_avf_enable_network",
         "avf_remote_attestation_enabled",
@@ -63,6 +64,7 @@
         "systemserverclasspath_fragments",
         "vintf_fragments",
         "apps",
+        "binaries",
     ],
 }
 
@@ -210,6 +212,16 @@
                 "virtualizationservice.xml",
             ],
         },
+        release_avf_enable_early_vm: {
+            arch: {
+                arm64: {
+                    binaries: ["early_virtmgr"],
+                },
+                x86_64: {
+                    binaries: ["early_virtmgr"],
+                },
+            },
+        },
     },
 }