Virtualizationservice makes payload disk image
with given APK, idsig, and config file.
To exercise the new execution mode, 'vm run-app' sub command is added.
$ vm <apk_path> <idsig_path> <config_path>
For example,
$ vm /data/local/tmp/MyApp.apk /data/local/tmp/MyApp.apk.idsig \
assets/config.json
Bug: 190503456
Test: MicrodroidHostTestCases, VirtualizationTestCases
Change-Id: Iceec9b34e9785a1ae36452bfc2653c3c045f4dfa
diff --git a/vm/src/main.rs b/vm/src/main.rs
index 8f16eb5..d7bae30 100644
--- a/vm/src/main.rs
+++ b/vm/src/main.rs
@@ -20,7 +20,7 @@
use android_system_virtualizationservice::aidl::android::system::virtualizationservice::IVirtualizationService::IVirtualizationService;
use android_system_virtualizationservice::binder::{wait_for_interface, ProcessState, Strong, ParcelFileDescriptor};
use anyhow::{Context, Error};
-use run::command_run;
+use run::{command_run, command_run_app};
use std::convert::TryInto;
use std::fs::OpenOptions;
use std::path::{PathBuf, Path};
@@ -33,6 +33,27 @@
#[derive(StructOpt)]
#[structopt(no_version, global_settings = &[AppSettings::DisableVersion])]
enum Opt {
+ /// Run a virtual machine with a config in APK
+ RunApp {
+ /// Path to VM Payload APK
+ #[structopt(parse(from_os_str))]
+ apk: PathBuf,
+
+ /// Path to idsig of the APK
+ #[structopt(parse(from_os_str))]
+ idsig: PathBuf,
+
+ /// Path to VM config JSON within APK (e.g. assets/vm_config.json)
+ config_path: String,
+
+ /// Detach VM from the terminal and run in the background
+ #[structopt(short, long)]
+ daemonize: bool,
+
+ /// Path to file for VM log output.
+ #[structopt(short, long)]
+ log: Option<PathBuf>,
+ },
/// Run a virtual machine
Run {
/// Path to VM config JSON
@@ -76,6 +97,9 @@
.context("Failed to find VirtualizationService")?;
match opt {
+ Opt::RunApp { apk, idsig, config_path, daemonize, log } => {
+ command_run_app(service, &apk, &idsig, &config_path, daemonize, log.as_deref())
+ }
Opt::Run { config, daemonize, log } => {
command_run(service, &config, daemonize, log.as_deref())
}