Unify OS APIs into one API
There are two APIs to specify a custom OS.
* 'os' field in a payload config json inside an APK
* 'osName' field in VirtualMachinePayloadConfig aidl parcelable
But that results in confusing and tricky APIs. For example
* VirtualMachineConfig.Builder.setOs() can be called only with
VirtualMachineConfig.Builder.setPayloadBinaryName() because a payload
config json already has its own OS field. It's confusing because users
may misunderstand that customOS is only available to payload binaries.
* We need one payload config file per one supported VM, even when they
are exactly same VMs except for the OS. This makes duplicated config
files (especially for tests).
This change unifies those two OS APIs into one, under
VirtualMachineAppConfig.
* AIDL API users and VM APK developers: 'os' field in the json config
will be deprecated and it will have no effect.
* Java API users: setOs must be called if they want to use OSes other
than "microdroid".
Bug: 321130996
Test: atest MicrodroidHostTests MicrodroidTests AuthFsHostTest \
CustomPvmfwHostTestCases DebugPolicyHostTests \
ComposHostTestCases AVFHostTestCase PvmfwImgTest
Change-Id: I41a526c7001b4b9ff23a52bf612a996e114f292c
diff --git a/vm/src/run.rs b/vm/src/run.rs
index 57b7641..07e0276 100644
--- a/vm/src/run.rs
+++ b/vm/src/run.rs
@@ -127,29 +127,25 @@
if config.payload_binary_name.is_some() {
bail!("Only one of --config-path or --payload-binary-name can be defined")
}
- if config.microdroid.gki().is_some() {
- bail!("--gki cannot be defined with --config-path. Use 'os' field in the config file")
- }
Payload::ConfigPath(config_path)
} else if let Some(payload_binary_name) = config.payload_binary_name {
- let os_name = if let Some(ver) = config.microdroid.gki() {
- format!("microdroid_gki-{ver}")
- } else {
- "microdroid".to_owned()
- };
-
let extra_apk_files: Result<Vec<_>, _> = extra_apks.iter().map(File::open).collect();
let extra_apk_fds = extra_apk_files?.into_iter().map(ParcelFileDescriptor::new).collect();
Payload::PayloadConfig(VirtualMachinePayloadConfig {
payloadBinaryName: payload_binary_name,
- osName: os_name,
extraApks: extra_apk_fds,
})
} else {
bail!("Either --config-path or --payload-binary-name must be defined")
};
+ let os_name = if let Some(ver) = config.microdroid.gki() {
+ format!("microdroid_gki-{ver}")
+ } else {
+ "microdroid".to_owned()
+ };
+
let payload_config_str = format!("{:?}!{:?}", config.apk, payload);
let custom_config = CustomConfig {
@@ -180,6 +176,7 @@
memoryMib: config.common.mem.unwrap_or(0) as i32, // 0 means use the VM default
cpuTopology: config.common.cpu_topology,
customConfig: Some(custom_config),
+ osName: os_name,
});
run(
service.as_ref(),