vmm: memory_actual_size reflects hotplug state

It is desirable to be able to track the progress of memory hotplug.
Update the memory_actual_size field to query the current plugged size
from virtio-mem to enable this.

Signed-off-by: Jared White <git@jaredwhite.dev>
This commit is contained in:
Jared White
2026-04-05 21:36:07 -07:00
committed by Bo Chen
parent aef0a43b52
commit 77ce3f6cbf
5 changed files with 45 additions and 15 deletions
+17 -14
View File
@@ -1039,21 +1039,24 @@ impl MemoryConfig {
}
pub fn total_size(&self) -> u64 {
let mut size = self.size;
if let Some(hotplugged_size) = self.hotplugged_size {
size += hotplugged_size;
}
self.size
+ self
.zones
.iter()
.flatten()
.map(|zone| zone.size)
.sum::<u64>()
+ self.hotplugged_size()
}
if let Some(zones) = &self.zones {
for zone in zones.iter() {
size += zone.size;
if let Some(hotplugged_size) = zone.hotplugged_size {
size += hotplugged_size;
}
}
}
size
pub fn hotplugged_size(&self) -> u64 {
self.hotplugged_size.unwrap_or(0)
+ self
.zones
.iter()
.flatten()
.filter_map(|zone| zone.hotplugged_size)
.sum::<u64>()
}
}