mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-balloon: Add memory_actual_size to vm.info to show memory actual size
The virtio-balloon change the memory size is asynchronous. VirtioBalloonConfig.actual of balloon device show current balloon size. This commit add memory_actual_size to vm.info to show memory actual size. Signed-off-by: Hui Zhu <teawater@antfin.com>
This commit is contained in:
@@ -534,6 +534,24 @@ impl MemoryConfig {
|
||||
zones,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn total_size(&self) -> u64 {
|
||||
let mut size = self.size;
|
||||
if let Some(hotplugged_size) = self.hotplugged_size {
|
||||
size += 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
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MemoryConfig {
|
||||
|
||||
Reference in New Issue
Block a user