Allow VM memory to be specified in app config.
Bug: 192294431
Change-Id: I42c8bb001e8c1e8905939bee01cd2d341b11f1a9
diff --git a/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineAppConfig.aidl b/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineAppConfig.aidl
index a5f7c3c..9339f82 100644
--- a/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineAppConfig.aidl
+++ b/virtualizationservice/aidl/android/system/virtualizationservice/VirtualMachineAppConfig.aidl
@@ -31,4 +31,10 @@
/** Whether to run the VM in debug mode or not */
boolean debug;
+
+ /**
+ * The amount of RAM to give the VM, in MiB. If this is 0 or negative then it will default to
+ * the value in microdroid.json, if any, or the crosvm default.
+ */
+ int memory_mib;
}
diff --git a/virtualizationservice/src/aidl.rs b/virtualizationservice/src/aidl.rs
index 1d99c2d..19e4877 100644
--- a/virtualizationservice/src/aidl.rs
+++ b/virtualizationservice/src/aidl.rs
@@ -383,6 +383,10 @@
let vm_config_file = File::open(vm_config_path)?;
let mut vm_config = VmConfig::load(&vm_config_file)?.to_parcelable()?;
+ if config.memory_mib > 0 {
+ vm_config.memory_mib = config.memory_mib;
+ }
+
// Microdroid requires an additional payload disk image and the bootconfig partition.
if os_name == "microdroid" {
let apexes = vm_payload_config.apexes.clone();
diff --git a/vm/src/run.rs b/vm/src/run.rs
index 41fdabb..1b1d5a3 100644
--- a/vm/src/run.rs
+++ b/vm/src/run.rs
@@ -62,6 +62,8 @@
instanceImage: open_parcel_file(instance, true /* writable */)?.into(),
configPath: config_path.to_owned(),
debug,
+ // Use the default.
+ memory_mib: 0,
});
run(service, &config, &format!("{:?}!{:?}", apk, config_path), daemonize, log_path)
}