Merge "Sign microdroid_boot and _vendor_boot"
diff --git a/apex/Android.bp b/apex/Android.bp
index 50c17f6..fa3806f 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -17,17 +17,20 @@
     arch: {
         arm64: {
             binaries: [
+                "authfs", // TODO(victorhsieh): move to microdroid once we can run the test in VM.
                 "crosvm",
             ],
         },
         x86_64: {
             binaries: [
+                "authfs", // TODO(victorhsieh): move to microdroid once we can run the test in VM.
                 "crosvm",
             ],
         },
     },
     binaries: [
         "assemble_cvd",
+        "fd_server",
         "virtmanager",
         "vm",
     ],
diff --git a/authfs/Android.bp b/authfs/Android.bp
index 9f7be93..4a20a0c 100644
--- a/authfs/Android.bp
+++ b/authfs/Android.bp
@@ -39,11 +39,13 @@
     ],
     bindgen_flags: ["--size_t-is-usize"],
     cflags: ["-D BORINGSSL_NO_CXX"],
+    apex_available: ["com.android.virt"],
 }
 
 rust_binary {
     name: "authfs",
     defaults: ["authfs_defaults"],
+    apex_available: ["com.android.virt"],
 }
 
 rust_test {
diff --git a/authfs/aidl/Android.bp b/authfs/aidl/Android.bp
index 7f3c968..35a3c4a 100644
--- a/authfs/aidl/Android.bp
+++ b/authfs/aidl/Android.bp
@@ -9,6 +9,7 @@
     backend: {
         rust: {
             enabled: true,
+            apex_available: ["com.android.virt"],
         },
     },
 }
diff --git a/authfs/fd_server/Android.bp b/authfs/fd_server/Android.bp
index f12f01f..6f010ce 100644
--- a/authfs/fd_server/Android.bp
+++ b/authfs/fd_server/Android.bp
@@ -13,4 +13,5 @@
         "liblibc",
         "liblog_rust",
     ],
+    apex_available: ["com.android.virt"],
 }
diff --git a/microdroid/README.md b/microdroid/README.md
index fe0843f..465d234 100644
--- a/microdroid/README.md
+++ b/microdroid/README.md
@@ -52,7 +52,7 @@
 future, this shall be done via [`virtmanager`](../virtmanager/).
 
 ```
-$ adb shell 'HOME=/data/local/tmp; PATH=$PATH:/apex/com.android.virt/bin; assemble_cvd < /dev/null'
+$ adb shell 'HOME=/data/local/tmp; PATH=$PATH:/apex/com.android.virt/bin; assemble_cvd -protected_vm < /dev/null'
 $ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/crosvm run --cid=5 --disable-sandbox --bios=bootloader --serial=type=stdout --disk=cuttlefish_runtime/composite.img'
 ```
 
diff --git a/tests/hostside/java/android/virt/test/MicrodroidTestCase.java b/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
index 7a45a8c..092a1dd 100644
--- a/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
+++ b/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
@@ -84,7 +84,7 @@
         // Run assemble_cvd to create composite.img
         getDevice().executeShellCommand("HOME=" + TEST_ROOT + "; "
                 + "PATH=$PATH:" + VIRT_APEX + "bin; "
-                + VIRT_APEX + "bin/assemble_cvd < /dev/null");
+                + VIRT_APEX + "bin/assemble_cvd -protected_vm < /dev/null");
 
         // Make sure that composite.img is created
         final String compositeImg = TEST_ROOT + "cuttlefish_runtime/composite.img";
diff --git a/virtmanager/Android.bp b/virtmanager/Android.bp
index 5ff5db4..9fc4f42 100644
--- a/virtmanager/Android.bp
+++ b/virtmanager/Android.bp
@@ -9,7 +9,7 @@
     edition: "2018",
     rustlibs: [
         "android.system.virtmanager-rust",
-        "libenv_logger",
+        "libandroid_logger",
         "liblog_rust",
         "libserde_json",
         "libserde",
diff --git a/virtmanager/src/aidl.rs b/virtmanager/src/aidl.rs
index 1b3819f..b7595a9 100644
--- a/virtmanager/src/aidl.rs
+++ b/virtmanager/src/aidl.rs
@@ -14,7 +14,7 @@
 
 //! Implementation of the AIDL interface of the Virt Manager.
 
-use crate::config::load_vm_config;
+use crate::config::VmConfig;
 use crate::crosvm::VmInstance;
 use crate::{Cid, FIRST_GUEST_CID};
 use android_system_virtmanager::aidl::android::system::virtmanager::IVirtManager::IVirtManager;
@@ -141,7 +141,7 @@
 /// Start a new VM instance from the given VM config filename. This assumes the VM is not already
 /// running.
 fn start_vm(config_path: &str, cid: Cid) -> binder::Result<VmInstance> {
-    let config = load_vm_config(config_path).map_err(|e| {
+    let config = VmConfig::load(config_path).map_err(|e| {
         error!("Failed to load VM config {}: {:?}", config_path, e);
         StatusCode::BAD_VALUE
     })?;
diff --git a/virtmanager/src/config.rs b/virtmanager/src/config.rs
index c0d23f0..d8cb06f 100644
--- a/virtmanager/src/config.rs
+++ b/virtmanager/src/config.rs
@@ -49,6 +49,13 @@
         }
         Ok(())
     }
+
+    /// Load the configuration for a VM from the given JSON file.
+    pub fn load(path: &str) -> Result<VmConfig, Error> {
+        let file = File::open(path).with_context(|| format!("Failed to open {}", path))?;
+        let buffered = BufReader::new(file);
+        Ok(serde_json::from_reader(buffered)?)
+    }
 }
 
 /// A disk image to be made available to the VM.
@@ -59,10 +66,3 @@
     /// Whether this disk should be writable by the VM.
     pub writable: bool,
 }
-
-/// Load the configuration for the VM with the given ID from a JSON file.
-pub fn load_vm_config(path: &str) -> Result<VmConfig, Error> {
-    let file = File::open(path).with_context(|| format!("Failed to open {}", path))?;
-    let buffered = BufReader::new(file);
-    Ok(serde_json::from_reader(buffered)?)
-}
diff --git a/virtmanager/src/main.rs b/virtmanager/src/main.rs
index 7cca4a9..486efeb 100644
--- a/virtmanager/src/main.rs
+++ b/virtmanager/src/main.rs
@@ -21,17 +21,22 @@
 use crate::aidl::{VirtManager, BINDER_SERVICE_IDENTIFIER};
 use android_system_virtmanager::aidl::android::system::virtmanager::IVirtManager::BnVirtManager;
 use android_system_virtmanager::binder::{add_service, ProcessState};
-use log::info;
+use log::{info, Level};
 
 /// The first CID to assign to a guest VM managed by the Virt Manager. CIDs lower than this are
 /// reserved for the host or other usage.
 const FIRST_GUEST_CID: Cid = 10;
 
+const LOG_TAG: &str = "VirtManager";
+
 /// The unique ID of a VM used (together with a port number) for vsock communication.
 type Cid = u32;
 
 fn main() {
-    env_logger::init();
+    android_logger::init_once(
+        android_logger::Config::default().with_tag(LOG_TAG).with_min_level(Level::Trace),
+    );
+
     let virt_manager = VirtManager::default();
     let virt_manager = BnVirtManager::new_binder(virt_manager);
     add_service(BINDER_SERVICE_IDENTIFIER, virt_manager.as_binder()).unwrap();