Skip to content

Commit 9a90551

Browse files
committed
feat(mem): introduce KVM slots per GuestMemoryRegion
A single GuestMemoryRegion can be split into multiple KVM slots. This is used for Hotplug type regions where we can dynamically remove access to the region from the guest. Signed-off-by: Riccardo Mancini <[email protected]>
1 parent 1ec5c44 commit 9a90551

File tree

5 files changed

+245
-97
lines changed

5 files changed

+245
-97
lines changed

src/vmm/src/builder.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ pub fn build_microvm_for_boot(
180180
let hotplug_memory_region = vm_resources
181181
.allocate_memory_region(addr, mib_to_bytes(memory_hotplug.total_size_mib))
182182
.map_err(StartMicrovmError::GuestMemory)?;
183-
vm.register_hotpluggable_memory_region(hotplug_memory_region)?;
183+
vm.register_hotpluggable_memory_region(
184+
hotplug_memory_region,
185+
mib_to_bytes(memory_hotplug.slot_size_mib),
186+
)?;
184187
Some(addr)
185188
} else {
186189
None

src/vmm/src/devices/virtio/mem/device.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ pub(crate) mod test_utils {
692692
.unwrap()
693693
.pop()
694694
.unwrap(),
695+
mib_to_bytes(128),
695696
);
696697
let vm = Arc::new(vm);
697698
VirtioMem::new(vm, addr, 1024, 2, 128).unwrap()

src/vmm/src/persist.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ fn send_uffd_handshake(
571571
mod tests {
572572
use std::os::unix::net::UnixListener;
573573

574+
use bitvec::vec::BitVec;
574575
use vmm_sys_util::tempfile::TempFile;
575576

576577
use super::*;
@@ -698,6 +699,7 @@ mod tests {
698699
base_address: 0,
699700
size: 0x20000,
700701
region_type: GuestRegionType::Dram,
702+
plugged: BitVec::repeat(true, 1),
701703
}],
702704
};
703705

0 commit comments

Comments
 (0)