From de2b917f5597c521de2cbbfd50befdc701425f7f Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 14 Sep 2020 22:36:58 +0200 Subject: [PATCH] vmm: Add hotplugged_size to VirtioMemZone Adding a new field to VirtioMemZone structure, as it lets us associate with a particular virtio-mem region the amount of memory that should be plugged in at boot. Signed-off-by: Sebastien Boeuf --- vmm/src/device_manager.rs | 2 +- vmm/src/memory_manager.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 40a88371a..fea423409 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -2449,7 +2449,7 @@ impl DeviceManager { .map_err(DeviceManagerError::TryCloneVirtioMemResize)?, self.seccomp_action.clone(), node_id, - 0, + virtio_mem_zone.hotplugged_size(), ) .map_err(DeviceManagerError::CreateVirtioMem)?, )); diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 2cfdbbbee..95b589009 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -67,6 +67,7 @@ struct HotPlugState { pub struct VirtioMemZone { region: Arc, resize_handler: virtio_devices::Resize, + hotplugged_size: u64, } impl VirtioMemZone { @@ -76,6 +77,9 @@ impl VirtioMemZone { pub fn resize_handler(&self) -> &virtio_devices::Resize { &self.resize_handler } + pub fn hotplugged_size(&self) -> u64 { + self.hotplugged_size + } } #[derive(Default)] @@ -612,6 +616,7 @@ impl MemoryManager { region, resize_handler: virtio_devices::Resize::new() .map_err(Error::EventFdFail)?, + hotplugged_size: zone.hotplugged_size.unwrap_or(0), }); start_of_device_area = start_addr.unchecked_add(hotplug_size);