Make extra APKs easier to specify
Allow extra APKs to be specified in VirtualMachineAppConfig as an
alternative to the config file, so the paths don't need to be fixed.
This involves adding:
- the extra_apk_count to the metadata proto, which is persisted in the
instance image.
- the extra APK fds to VirtualMachinePayloadConfig, so it can be
included in VirtualMachineAppConfig iff there is no config file.
And then a whole lot of plumbing to make it all work.
Using this requires the USE_CUSTOM_VIRTUAL_MACHINE permission, and is
behind the multi-tenant feature flag.
I've not attempted to add API yet (this CL is already big), but I have
extended the vm command to allow it to be exercised.
Bug: 303201498
Test: Start a VM with an extra APK specified on the `vm run-app`
command line.
Change-Id: Ib5da40a33960fd9639b62e8d77e865aeb1f6398b
diff --git a/vm/src/main.rs b/vm/src/main.rs
index 5c07eed..de9291c 100644
--- a/vm/src/main.rs
+++ b/vm/src/main.rs
@@ -34,7 +34,7 @@
#[derive(Debug)]
struct Idsigs(Vec<PathBuf>);
-#[derive(Args)]
+#[derive(Args, Default)]
/// Collection of flags that are at VM level and therefore applicable to all subcommands
pub struct CommonConfig {
/// Name of VM
@@ -59,7 +59,7 @@
protected: bool,
}
-#[derive(Args)]
+#[derive(Args, Default)]
/// Collection of flags for debugging
pub struct DebugConfig {
/// Debug level of the VM. Supported values: "full" (default), and "none".
@@ -84,7 +84,7 @@
gdb: Option<NonZeroU16>,
}
-#[derive(Args)]
+#[derive(Args, Default)]
/// Collection of flags that are Microdroid specific
pub struct MicrodroidConfig {
/// Path to the file backing the storage.
@@ -145,7 +145,7 @@
}
}
-#[derive(Args)]
+#[derive(Args, Default)]
/// Flags for the run_app subcommand
pub struct RunAppConfig {
#[command(flatten)]
@@ -175,12 +175,30 @@
#[arg(alias = "payload_path")]
payload_binary_name: Option<String>,
+ /// Paths to extra apk files.
+ #[cfg(multi_tenant)]
+ #[arg(long = "extra-apk")]
+ #[clap(conflicts_with = "config_path")]
+ extra_apks: Vec<PathBuf>,
+
/// Paths to extra idsig files.
#[arg(long = "extra-idsig")]
extra_idsigs: Vec<PathBuf>,
}
-#[derive(Args)]
+impl RunAppConfig {
+ #[cfg(multi_tenant)]
+ fn extra_apks(&self) -> &[PathBuf] {
+ &self.extra_apks
+ }
+
+ #[cfg(not(multi_tenant))]
+ fn extra_apks(&self) -> &[PathBuf] {
+ &[]
+ }
+}
+
+#[derive(Args, Default)]
/// Flags for the run_microdroid subcommand
pub struct RunMicrodroidConfig {
#[command(flatten)]
@@ -199,7 +217,7 @@
work_dir: Option<PathBuf>,
}
-#[derive(Args)]
+#[derive(Args, Default)]
/// Flags for the run subcommand
pub struct RunCustomVmConfig {
#[command(flatten)]