Skip to content

Commit 7e2cdee

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 4a09c23 commit 7e2cdee

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/vmm/src/builder.rs

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

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

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

src/vmm/src/vstate/memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ mod tests {
351351

352352
use super::*;
353353
use crate::snapshot::Snapshot;
354-
use crate::utils::{get_page_size, KIB_TO_BYTES_SHIFT};
354+
use crate::utils::{KIB_TO_BYTES_SHIFT, get_page_size};
355355

356356
#[test]
357357
fn test_anonymous() {

0 commit comments

Comments
 (0)