runtime-rs: support iommu_platform for qemu virtio-net device

Note that it's only supported on CCW systems.

Signed-off-by: Pavel Mores <pmores@redhat.com>
This commit is contained in:
Pavel Mores 2024-04-24 17:57:43 +02:00
parent 0d038f20cc
commit 174fc8f44b

View File

@ -997,6 +997,7 @@ pub struct DeviceVirtioNet {
disable_modern: bool, disable_modern: bool,
num_queues: u32, num_queues: u32,
iommu_platform: bool,
} }
impl DeviceVirtioNet { impl DeviceVirtioNet {
@ -1007,6 +1008,7 @@ impl DeviceVirtioNet {
mac_address, mac_address,
disable_modern: false, disable_modern: false,
num_queues: 1, num_queues: 1,
iommu_platform: false,
} }
} }
@ -1019,6 +1021,11 @@ impl DeviceVirtioNet {
self.num_queues = num_queues; self.num_queues = num_queues;
self self
} }
fn set_iommu_platform(&mut self, iommu_platform: bool) -> &mut Self {
self.iommu_platform = iommu_platform;
self
}
} }
#[async_trait] #[async_trait]
@ -1035,6 +1042,9 @@ impl ToQemuParams for DeviceVirtioNet {
if self.disable_modern { if self.disable_modern {
params.push("disable-modern=true".to_owned()); params.push("disable-modern=true".to_owned());
} }
if self.iommu_platform {
params.push("iommu_platform=on".to_owned());
}
params.push("mq=on".to_owned()); params.push("mq=on".to_owned());
params.push(format!("vectors={}", 2 * self.num_queues + 2)); params.push(format!("vectors={}", 2 * self.num_queues + 2));
@ -1378,6 +1388,9 @@ impl<'a> QemuCmdLine<'a> {
if should_disable_modern() { if should_disable_modern() {
virtio_net_device.set_disable_modern(true); virtio_net_device.set_disable_modern(true);
} }
if self.config.device_info.enable_iommu_platform && self.bus_type() == VirtioBusType::Ccw {
virtio_net_device.set_iommu_platform(true);
}
if self.config.network_info.network_queues > 1 { if self.config.network_info.network_queues > 1 {
virtio_net_device.set_num_queues(self.config.network_info.network_queues); virtio_net_device.set_num_queues(self.config.network_info.network_queues);
} }