apply the swiotlb memory adjustment even for default size
Bug: 346770542
Test: TH
Change-Id: Ia2e24efe80dbd9cd31f30f0323930257ecde4a4b
diff --git a/virtualizationmanager/src/aidl.rs b/virtualizationmanager/src/aidl.rs
index 671a012..7d406d9 100644
--- a/virtualizationmanager/src/aidl.rs
+++ b/virtualizationmanager/src/aidl.rs
@@ -596,7 +596,12 @@
params: config.params.to_owned(),
protected: *is_protected,
debug_config,
- memory_mib: config.memoryMib.try_into().ok().and_then(NonZeroU32::new),
+ memory_mib: config
+ .memoryMib
+ .try_into()
+ .ok()
+ .and_then(NonZeroU32::new)
+ .unwrap_or(NonZeroU32::new(256).unwrap()),
cpus,
host_cpu_topology,
console_out_fd,
diff --git a/virtualizationmanager/src/crosvm.rs b/virtualizationmanager/src/crosvm.rs
index ca938f8..23018d4 100644
--- a/virtualizationmanager/src/crosvm.rs
+++ b/virtualizationmanager/src/crosvm.rs
@@ -114,7 +114,7 @@
pub params: Option<String>,
pub protected: bool,
pub debug_config: DebugConfig,
- pub memory_mib: Option<NonZeroU32>,
+ pub memory_mib: NonZeroU32,
pub cpus: Option<NonZeroU32>,
pub host_cpu_topology: bool,
pub console_out_fd: Option<File>,
@@ -942,7 +942,7 @@
command.arg("--swiotlb").arg(swiotlb_size_mib.to_string());
// b/346770542 for consistent "usable" memory across protected and non-protected VMs.
- memory_mib = memory_mib.map(|m| m.saturating_add(swiotlb_size_mib));
+ memory_mib = memory_mib.saturating_add(swiotlb_size_mib);
// Workaround to keep crash_dump from trying to read protected guest memory.
// Context in b/238324526.
@@ -965,9 +965,7 @@
command.arg("--params").arg("console=hvc0");
}
- if let Some(memory_mib) = memory_mib {
- command.arg("--mem").arg(memory_mib.to_string());
- }
+ command.arg("--mem").arg(memory_mib.to_string());
if let Some(cpus) = config.cpus {
command.arg("--cpus").arg(cpus.to_string());