runtime-rs: Add reclaim_guest_freed_memory cloud-hypervisor support

Add reclaim_guest_freed_memory config to cloud-hypervisor in runtime-rs.

Fixes: #10710

Signed-off-by: Hui Zhu <teawater@antgroup.com>
This commit is contained in:
Hui Zhu
2025-01-07 08:48:52 +08:00
parent 487171d992
commit 185b94b7fa
2 changed files with 20 additions and 0 deletions

View File

@@ -158,6 +158,16 @@ virtio_fs_cache = "@DEFVIRTIOFSCACHE@"
# > 5 --> will be set to 5
default_bridges = @DEFBRIDGES@
# Reclaim guest freed memory.
# Enabling this will result in the VM balloon device having f_reporting=on set.
# Then the hypervisor will use it to reclaim guest freed memory.
# This is useful for reducing the amount of memory used by a VM.
# Enabling this feature may sometimes reduce the speed of memory access in
# the VM.
#
# Default false
#reclaim_guest_freed_memory = true
# Block storage driver to be used for the hypervisor in case the container
# rootfs is backed by a block device.
block_device_driver = "virtio-blk-pci"

View File

@@ -180,6 +180,15 @@ impl TryFrom<NamedHypervisorConfig> for VmConfig {
let platform = get_platform_cfg(guest_protection_to_use);
let balloon = if cfg.device_info.reclaim_guest_freed_memory {
Some(crate::BalloonConfig {
free_page_reporting: true,
..Default::default()
})
} else {
None
};
let cfg = VmConfig {
cpus,
memory,
@@ -193,6 +202,7 @@ impl TryFrom<NamedHypervisorConfig> for VmConfig {
vsock: Some(vsock),
rng,
platform,
balloon,
..Default::default()
};