Skip to content

Commit 15e96b6

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 666f5c1 commit 15e96b6

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
@@ -183,7 +183,10 @@ pub fn build_microvm_for_boot(
183183
let hotplug_memory_region = vm_resources
184184
.allocate_memory_region(addr, mib_to_bytes(memory_hotplug.total_size_mib))
185185
.map_err(StartMicrovmError::GuestMemory)?;
186-
vm.register_hotpluggable_memory_region(hotplug_memory_region)?;
186+
vm.register_hotpluggable_memory_region(
187+
hotplug_memory_region,
188+
mib_to_bytes(memory_hotplug.slot_size_mib),
189+
)?;
187190
Some(addr)
188191
} else {
189192
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::*;
@@ -694,6 +695,7 @@ mod tests {
694695
base_address: 0,
695696
size: 0x20000,
696697
region_type: GuestRegionType::Dram,
698+
plugged: BitVec::repeat(true, 1),
697699
}],
698700
};
699701

0 commit comments

Comments
 (0)