]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Assign PCI address to virtio-iommu
authorAndrea Bolognani <abologna@redhat.com>
Thu, 23 Sep 2021 17:29:07 +0000 (19:29 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 1 Apr 2022 17:30:59 +0000 (19:30 +0200)
The device is configured to be an integrated endpoint, as is
necessary for it to function correctly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain_address.c
tests/qemuxml2xmloutdata/virtio-iommu-aarch64.aarch64-latest.xml
tests/qemuxml2xmloutdata/virtio-iommu-x86_64.x86_64-latest.xml

index 205610c53e3141530e242aaf2583334a6def72eb..753733d1b95859cac8aef9ab1e44f7f839a3a66f 100644 (file)
@@ -1005,7 +1005,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
     case VIR_DOMAIN_DEVICE_IOMMU:
         switch ((virDomainIOMMUModel) dev->data.iommu->model) {
             case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
-                return 0;
+                return virtioFlags | VIR_PCI_CONNECT_INTEGRATED;
 
             case VIR_DOMAIN_IOMMU_MODEL_INTEL:
             case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
@@ -2386,6 +2386,10 @@ qemuDomainAssignDevicePCISlots(virDomainDef *def,
 
         switch ((virDomainIOMMUModel) iommu->model) {
         case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
+            if (virDeviceInfoPCIAddressIsWanted(&iommu->info) &&
+                qemuDomainPCIAddressReserveNextAddr(addrs, &iommu->info) < 0) {
+                return -1;
+            }
             break;
 
         case VIR_DOMAIN_IOMMU_MODEL_INTEL:
index 336f99d539e9403826d0f7f133b374f0d0a1f2e8..c6560e9a91d820833fff3a6f246d6bffb82c029a 100644 (file)
@@ -27,6 +27,8 @@
     <controller type='pci' index='0' model='pcie-root'/>
     <audio id='1' type='none'/>
     <memballoon model='none'/>
-    <iommu model='virtio'/>
+    <iommu model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </iommu>
   </devices>
 </domain>
index 0b6c2d0eaf8d9c965ed6cc0a79521859d0f58aa3..ad3a702b0ba5ac811b41d704e033e37cdf3be3d6 100644 (file)
@@ -29,6 +29,8 @@
     <input type='keyboard' bus='ps2'/>
     <audio id='1' type='none'/>
     <memballoon model='none'/>
-    <iommu model='virtio'/>
+    <iommu model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </iommu>
   </devices>
 </domain>