Skip to content

Commit 4e9c443

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 c759849 commit 4e9c443

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();
@@ -237,6 +241,12 @@ pub fn build_microvm_for_boot(
237241
.map_err(VmmError::Vm)?;
238242
}
239243

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

0 commit comments

Comments
 (0)