diff --git a/src/main.rs b/src/main.rs index e8576fcc9..9d2d72df2 100755 --- a/src/main.rs +++ b/src/main.rs @@ -219,7 +219,7 @@ fn main() { .long("vsock") .help( "Virtio VSOCK parameters \"cid=,\ - sock=\"", + sock=,iommu=on|off\"", ) .takes_value(true) .min_values(1) diff --git a/vmm/src/api/openapi/cloud-hypervisor.yaml b/vmm/src/api/openapi/cloud-hypervisor.yaml index fde659f8f..2db9e8b2f 100644 --- a/vmm/src/api/openapi/cloud-hypervisor.yaml +++ b/vmm/src/api/openapi/cloud-hypervisor.yaml @@ -364,3 +364,6 @@ components: sock: type: string description: Path to UNIX domain socket, used to proxy vsock connections. + iommu: + type: boolean + default: false diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 6ac94c444..a05933d4a 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -652,6 +652,8 @@ impl VhostUserNetConfig { pub struct VsockConfig { pub cid: u64, pub sock: PathBuf, + #[serde(default)] + pub iommu: bool, } impl VsockConfig { @@ -661,12 +663,15 @@ impl VsockConfig { let mut cid_str: &str = ""; let mut sock_str: &str = ""; + let mut iommu_str: &str = ""; for param in params_list.iter() { if param.starts_with("cid=") { cid_str = ¶m[4..]; } else if param.starts_with("sock=") { sock_str = ¶m[5..]; + } else if param.starts_with("iommu=") { + iommu_str = ¶m[6..]; } } @@ -677,6 +682,7 @@ impl VsockConfig { Ok(VsockConfig { cid: cid_str.parse::().map_err(Error::ParseVsockCidParam)?, sock: PathBuf::from(sock_str), + iommu: parse_iommu(iommu_str)?, }) } } @@ -855,7 +861,11 @@ impl VmConfig { if let Some(vsock_list) = &vm_params.vsock { let mut vsock_config_list = Vec::new(); for item in vsock_list.iter() { - vsock_config_list.push(VsockConfig::parse(item)?); + let vsock_config = VsockConfig::parse(item)?; + if vsock_config.iommu { + iommu = true; + } + vsock_config_list.push(vsock_config); } vsock = Some(vsock_config_list); }