mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 19:16:23 +00:00
runtime-rs: add representation of '-device intel-iommu' to qemu-rs
Following the golang shim example, the values are hardcoded. Signed-off-by: Pavel Mores <pmores@redhat.com>
This commit is contained in:
parent
702bf0d35e
commit
0859f47a17
@ -1118,6 +1118,36 @@ impl ToQemuParams for Rtc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct DeviceIntelIommu {
|
||||||
|
intremap: bool,
|
||||||
|
device_iotlb: bool,
|
||||||
|
caching_mode: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DeviceIntelIommu {
|
||||||
|
fn new() -> DeviceIntelIommu {
|
||||||
|
DeviceIntelIommu {
|
||||||
|
intremap: true,
|
||||||
|
device_iotlb: true,
|
||||||
|
caching_mode: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl ToQemuParams for DeviceIntelIommu {
|
||||||
|
async fn qemu_params(&self) -> Result<Vec<String>> {
|
||||||
|
let mut params = Vec::new();
|
||||||
|
params.push("intel-iommu".to_owned());
|
||||||
|
let to_onoff = |b| if b { "on" } else { "off" };
|
||||||
|
params.push(format!("intremap={}", to_onoff(self.intremap)));
|
||||||
|
params.push(format!("device-iotlb={}", to_onoff(self.device_iotlb)));
|
||||||
|
params.push(format!("caching-mode={}", to_onoff(self.caching_mode)));
|
||||||
|
Ok(vec!["-device".to_owned(), params.join(",")])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn is_running_in_vm() -> Result<bool> {
|
fn is_running_in_vm() -> Result<bool> {
|
||||||
let res = read_to_string("/proc/cpuinfo")?
|
let res = read_to_string("/proc/cpuinfo")?
|
||||||
.lines()
|
.lines()
|
||||||
|
Loading…
Reference in New Issue
Block a user