vmm: Add iommu=on|off option for --vsock
Having the virtual IOMMU created with --iommu is one thing, but we also need a way to decide if a virtio-vsock device should be attached to this virtual IOMMU or not. That's why we introduce an extra option "iommu" with the value "on" or "off". By default, the device is not attached, which means "iommu=off". Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
32d07e40cc
commit
278ab05cbc
3 changed files with 15 additions and 2 deletions
|
|
@ -219,7 +219,7 @@ fn main() {
|
|||
.long("vsock")
|
||||
.help(
|
||||
"Virtio VSOCK parameters \"cid=<context_id>,\
|
||||
sock=<socket_path>\"",
|
||||
sock=<socket_path>,iommu=on|off\"",
|
||||
)
|
||||
.takes_value(true)
|
||||
.min_values(1)
|
||||
|
|
|
|||
|
|
@ -364,3 +364,6 @@ components:
|
|||
sock:
|
||||
type: string
|
||||
description: Path to UNIX domain socket, used to proxy vsock connections.
|
||||
iommu:
|
||||
type: boolean
|
||||
default: false
|
||||
|
|
|
|||
|
|
@ -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::<u64>().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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue