vmm: Add iommu=on|off option for --pmem

Having the virtual IOMMU created with --iommu is one thing, but we also
need a way to decide if a virtio-pmem 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:
Sebastien Boeuf 2019-10-04 11:27:22 -07:00 committed by Samuel Ortiz
parent fb4769388b
commit 63869bde75
3 changed files with 15 additions and 2 deletions

View File

@ -171,7 +171,7 @@ fn main() {
.long("pmem")
.help(
"Persistent memory parameters \"file=<backing_file_path>,\
size=<persistent_memory_size>\"",
size=<persistent_memory_size>,iommu=on|off\"",
)
.takes_value(true)
.min_values(1)

View File

@ -289,6 +289,9 @@ components:
type: string
size:
type: integer
iommu:
type: boolean
default: false
ConsoleConfig:
required:

View File

@ -448,6 +448,8 @@ impl FsConfig {
pub struct PmemConfig {
pub file: PathBuf,
pub size: u64,
#[serde(default)]
pub iommu: bool,
}
impl PmemConfig {
@ -457,12 +459,15 @@ impl PmemConfig {
let mut file_str: &str = "";
let mut size_str: &str = "";
let mut iommu_str: &str = "";
for param in params_list.iter() {
if param.starts_with("file=") {
file_str = &param[5..];
} else if param.starts_with("size=") {
size_str = &param[5..];
} else if param.starts_with("iommu=") {
iommu_str = &param[6..];
}
}
@ -473,6 +478,7 @@ impl PmemConfig {
Ok(PmemConfig {
file: PathBuf::from(file_str),
size: parse_size(size_str)?,
iommu: parse_iommu(iommu_str)?,
})
}
}
@ -788,7 +794,11 @@ impl VmConfig {
if let Some(pmem_list) = &vm_params.pmem {
let mut pmem_config_list = Vec::new();
for item in pmem_list.iter() {
pmem_config_list.push(PmemConfig::parse(item)?);
let pmem_config = PmemConfig::parse(item)?;
if pmem_config.iommu {
iommu = true;
}
pmem_config_list.push(pmem_config);
}
pmem = Some(pmem_config_list);
}