Add --mem option to the vm tool
The option is used to override the memoryMib value of the vm config. The
Microdroid tests are modified to use the minimum amount of memory so
that we keep track of the memory requirement.
Bug: 199703022
Bug: 194961381
Test: atest MicrodroidHostTestCases
Change-Id: Id71c756f689e8da50ea19235264cd788ea4c5f70
diff --git a/vm/src/run.rs b/vm/src/run.rs
index 0d34a97..42da6a3 100644
--- a/vm/src/run.rs
+++ b/vm/src/run.rs
@@ -49,6 +49,7 @@
daemonize: bool,
log_path: Option<&Path>,
debug: bool,
+ mem: Option<u32>,
) -> Result<(), Error> {
let apk_file = File::open(apk).context("Failed to open APK file")?;
let idsig_file = File::create(idsig).context("Failed to create idsig file")?;
@@ -76,8 +77,7 @@
instanceImage: open_parcel_file(instance, true /* writable */)?.into(),
configPath: config_path.to_owned(),
debug,
- // Use the default.
- memoryMib: 0,
+ memoryMib: mem.unwrap_or(0) as i32, // 0 means use the VM default
});
run(service, &config, &format!("{:?}!{:?}", apk, config_path), daemonize, log_path)
}
@@ -88,10 +88,14 @@
config_path: &Path,
daemonize: bool,
log_path: Option<&Path>,
+ mem: Option<u32>,
) -> Result<(), Error> {
let config_file = File::open(config_path).context("Failed to open config file")?;
- let config =
+ let mut config =
VmConfig::load(&config_file).context("Failed to parse config file")?.to_parcelable()?;
+ if let Some(mem) = mem {
+ config.memoryMib = mem as i32;
+ }
run(
service,
&VirtualMachineConfig::RawConfig(config),