Skip to content

Commit 22e9b18

Browse files
committed
allocate and register io memory if initial_swiotlb_size != 0
Allocate the swiotlb region if requested via the /machine-config API endpoint. Signed-off-by: Patrick Roy <[email protected]>
1 parent 388dc69 commit 22e9b18

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/vmm/src/builder.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ pub fn build_microvm_for_boot(
235235
.allocate_guest_memory()
236236
.map_err(StartMicrovmError::GuestMemory)?;
237237

238+
let io_memory = vm_resources
239+
.allocate_io_memory()
240+
.map_err(StartMicrovmError::GuestMemory)?;
241+
238242
// Clone the command-line so that a failed boot doesn't pollute the original.
239243
#[allow(unused_mut)]
240244
let mut boot_cmdline = boot_config.cmdline.clone();
@@ -258,6 +262,13 @@ pub fn build_microvm_for_boot(
258262
.map_err(StartMicrovmError::Internal)?;
259263
}
260264

265+
if let Some(io_memory) = io_memory {
266+
vmm.vm
267+
.register_io_region(io_memory)
268+
.map_err(VmmError::Vm)
269+
.map_err(StartMicrovmError::Internal)?;
270+
}
271+
261272
let entry_point = load_kernel(boot_config, vmm.guest_memory())?;
262273
let initrd = load_initrd_from_config(boot_config, vmm.guest_memory())?;
263274

0 commit comments

Comments
 (0)