mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Add iommu=on|off option for --device
Having the virtual IOMMU created with --iommu is one thing, but we also need a way to decide if a VFIO device should be attached to the 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:
committed by
Samuel Ortiz
parent
3bb51d4d5e
commit
5fc3f37c9b
@@ -353,6 +353,9 @@ components:
|
||||
properties:
|
||||
path:
|
||||
type: string
|
||||
iommu:
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
VhostUserConfig:
|
||||
required:
|
||||
|
||||
@@ -572,12 +572,29 @@ impl ConsoleConfig {
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct DeviceConfig {
|
||||
pub path: PathBuf,
|
||||
#[serde(default)]
|
||||
pub iommu: bool,
|
||||
}
|
||||
|
||||
impl DeviceConfig {
|
||||
pub fn parse(device: &str) -> Result<Self> {
|
||||
// Split the parameters based on the comma delimiter
|
||||
let params_list: Vec<&str> = device.split(',').collect();
|
||||
|
||||
let mut path_str: &str = "";
|
||||
let mut iommu_str: &str = "";
|
||||
|
||||
for param in params_list.iter() {
|
||||
if param.starts_with("path=") {
|
||||
path_str = ¶m[5..];
|
||||
} else if param.starts_with("iommu=") {
|
||||
iommu_str = ¶m[6..];
|
||||
}
|
||||
}
|
||||
|
||||
Ok(DeviceConfig {
|
||||
path: PathBuf::from(device),
|
||||
path: PathBuf::from(path_str),
|
||||
iommu: parse_iommu(iommu_str)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -843,7 +860,11 @@ impl VmConfig {
|
||||
if let Some(device_list) = &vm_params.devices {
|
||||
let mut device_config_list = Vec::new();
|
||||
for item in device_list.iter() {
|
||||
device_config_list.push(DeviceConfig::parse(item)?);
|
||||
let device_config = DeviceConfig::parse(item)?;
|
||||
if device_config.iommu {
|
||||
iommu = true;
|
||||
}
|
||||
device_config_list.push(device_config);
|
||||
}
|
||||
devices = Some(device_config_list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user