Use staged APEXes for compilation
Add a new VM config file to be used when we want staged APEXes.
Add an option to compos_key_cmd to use staged APEXes.
Modify compos_client to allow the VM config to be overridden, and use
it to select staged APEXes in start_pending_instance.
Bug: 205296305
Test: stage an APEX, run composd_cmd staged-apex-compile
Change-Id: I379416b9798856d41492b32f6c0042262123a43b
diff --git a/compos/common/compos_client.rs b/compos/common/compos_client.rs
index 4908f94..73554bb 100644
--- a/compos/common/compos_client.rs
+++ b/compos/common/compos_client.rs
@@ -17,7 +17,7 @@
//! Support for starting CompOS in a VM and connecting to the service
use crate::timeouts::timeouts;
-use crate::{COMPOS_APEX_ROOT, COMPOS_DATA_ROOT, COMPOS_VSOCK_PORT};
+use crate::{COMPOS_APEX_ROOT, COMPOS_DATA_ROOT, COMPOS_VSOCK_PORT, DEFAULT_VM_CONFIG_PATH};
use android_system_virtualizationservice::aidl::android::system::virtualizationservice::{
IVirtualMachine::IVirtualMachine,
IVirtualMachineCallback::{BnVirtualMachineCallback, IVirtualMachineCallback},
@@ -56,6 +56,8 @@
pub struct VmParameters {
/// Whether the VM should be debuggable.
pub debug_mode: bool,
+ /// If present, overrides the path to the VM config JSON file
+ pub config_path: Option<String>,
}
impl VmInstance {
@@ -95,11 +97,12 @@
(None, DebugLevel::NONE)
};
+ let config_path = parameters.config_path.as_deref().unwrap_or(DEFAULT_VM_CONFIG_PATH);
let config = VirtualMachineConfig::AppConfig(VirtualMachineAppConfig {
apk: Some(apk_fd),
idsig: Some(idsig_fd),
instanceImage: Some(instance_fd),
- configPath: "assets/vm_config.json".to_owned(),
+ configPath: config_path.to_owned(),
debugLevel: debug_level,
..Default::default()
});
diff --git a/compos/common/lib.rs b/compos/common/lib.rs
index 4bfa81f..9b07030 100644
--- a/compos/common/lib.rs
+++ b/compos/common/lib.rs
@@ -52,3 +52,10 @@
/// The file that holds the instance image for a CompOS instance.
pub const INSTANCE_IMAGE_FILE: &str = "instance.img";
+
+/// The path within our config APK of our default VM configuration file, used at boot time.
+pub const DEFAULT_VM_CONFIG_PATH: &str = "assets/vm_config.json";
+
+/// The path within our config APK of the VM configuration file we use when compiling staged
+/// APEXes before reboot.
+pub const PREFER_STAGED_VM_CONFIG_PATH: &str = "assets/vm_config_staged.json";