From 66a2dc48aef3866bde5fb03770c39e4b89459d7b Mon Sep 17 00:00:00 2001 From: Pavel Mores Date: Wed, 24 Apr 2024 17:34:30 +0200 Subject: [PATCH] runtime-rs: support iommu_platform for qemu vhost-vsock device iommu_platform addition is controlled solely by the configuration file. Signed-off-by: Pavel Mores --- .../hypervisor/src/qemu/cmdline_generator.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs b/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs index 5cca822644..5346b89e00 100644 --- a/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs +++ b/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs @@ -823,6 +823,7 @@ struct VhostVsock { vhostfd: tokio::fs::File, guest_cid: u32, disable_modern: bool, + iommu_platform: bool, } impl VhostVsock { @@ -832,6 +833,7 @@ impl VhostVsock { vhostfd, guest_cid, disable_modern: false, + iommu_platform: false, } } @@ -839,6 +841,11 @@ impl VhostVsock { self.disable_modern = disable_modern; self } + + fn set_iommu_platform(&mut self, iommu_platform: bool) -> &mut Self { + self.iommu_platform = iommu_platform; + self + } } #[async_trait] @@ -849,6 +856,9 @@ impl ToQemuParams for VhostVsock { if self.disable_modern { params.push("disable-modern=true".to_owned()); } + if self.iommu_platform { + params.push("iommu_platform=on".to_owned()); + } params.push(format!("vhostfd={}", self.vhostfd.as_raw_fd())); params.push(format!("guest-cid={}", self.guest_cid)); @@ -1282,6 +1292,10 @@ impl<'a> QemuCmdLine<'a> { vhost_vsock_pci.set_disable_modern(true); } + if self.config.device_info.enable_iommu_platform { + vhost_vsock_pci.set_iommu_platform(true); + } + self.devices.push(Box::new(vhost_vsock_pci)); Ok(()) }