Skip to content

Commit d94de15

Browse files
committed
allocate and register swiotlb mem if initial_swiotlb_size != 0
Allocate the swiotlb region if requested via the /machine-config API endpoint, and register it to the VM/KVM. Signed-off-by: Patrick Roy <[email protected]>
1 parent eb53096 commit d94de15

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/vmm/src/builder.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ pub fn build_microvm_for_boot(
215215
.allocate_guest_memory()
216216
.map_err(StartMicrovmError::GuestMemory)?;
217217

218+
let swiotlb = vm_resources
219+
.allocate_swiotlb_region()
220+
.map_err(StartMicrovmError::GuestMemory)?;
221+
218222
// Clone the command-line so that a failed boot doesn't pollute the original.
219223
#[allow(unused_mut)]
220224
let mut boot_cmdline = boot_config.cmdline.clone();
@@ -235,6 +239,12 @@ pub fn build_microvm_for_boot(
235239
.register_memory_regions(guest_memory)
236240
.map_err(VmmError::Vm)?;
237241

242+
if let Some(swiotlb) = swiotlb {
243+
vmm.vm
244+
.register_swiotlb_region(swiotlb)
245+
.map_err(VmmError::Vm)?;
246+
}
247+
238248
let entry_point = load_kernel(&boot_config.kernel_file, vmm.vm.guest_memory())?;
239249
let initrd = InitrdConfig::from_config(boot_config, vmm.vm.guest_memory())?;
240250

0 commit comments

Comments
 (0)