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:
@@ -176,6 +176,28 @@ pub trait VirtioDevice: Send {
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper to allow common implementation of write_config
|
||||
fn write_config_helper(&self, config: &mut [u8], offset: u64, data: &[u8]) {
|
||||
let config_len = config.len() as u64;
|
||||
let data_len = data.len() as u64;
|
||||
if offset + data_len > config_len {
|
||||
error!(
|
||||
"Out-of-bound access to configuration: config_len = {} offset = {:x} length = {} for {}",
|
||||
config_len,
|
||||
offset,
|
||||
data_len,
|
||||
self.device_type()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(end) = offset.checked_add(config.len() as u64) {
|
||||
let mut offset_config =
|
||||
&mut config[offset as usize..std::cmp::min(end, config_len) as usize];
|
||||
offset_config.write_all(data).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait providing address translation the same way a physical DMA remapping
|
||||
|
||||
Reference in New Issue
Block a user