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 <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-09-14 22:36:58 +02:00
parent 3faf8605f3
commit de2b917f55
2 changed files with 6 additions and 1 deletions

View File

@@ -2449,7 +2449,7 @@ impl DeviceManager {
.map_err(DeviceManagerError::TryCloneVirtioMemResize)?, .map_err(DeviceManagerError::TryCloneVirtioMemResize)?,
self.seccomp_action.clone(), self.seccomp_action.clone(),
node_id, node_id,
0, virtio_mem_zone.hotplugged_size(),
) )
.map_err(DeviceManagerError::CreateVirtioMem)?, .map_err(DeviceManagerError::CreateVirtioMem)?,
)); ));

View File

@@ -67,6 +67,7 @@ struct HotPlugState {
pub struct VirtioMemZone { pub struct VirtioMemZone {
region: Arc<GuestRegionMmap>, region: Arc<GuestRegionMmap>,
resize_handler: virtio_devices::Resize, resize_handler: virtio_devices::Resize,
hotplugged_size: u64,
} }
impl VirtioMemZone { impl VirtioMemZone {
@@ -76,6 +77,9 @@ impl VirtioMemZone {
pub fn resize_handler(&self) -> &virtio_devices::Resize { pub fn resize_handler(&self) -> &virtio_devices::Resize {
&self.resize_handler &self.resize_handler
} }
pub fn hotplugged_size(&self) -> u64 {
self.hotplugged_size
}
} }
#[derive(Default)] #[derive(Default)]
@@ -612,6 +616,7 @@ impl MemoryManager {
region, region,
resize_handler: virtio_devices::Resize::new() resize_handler: virtio_devices::Resize::new()
.map_err(Error::EventFdFail)?, .map_err(Error::EventFdFail)?,
hotplugged_size: zone.hotplugged_size.unwrap_or(0),
}); });
start_of_device_area = start_addr.unchecked_add(hotplug_size); start_of_device_area = start_addr.unchecked_add(hotplug_size);