]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainAssignPCIAddresses: Assign extension addresses when auto-assigning PCI...
authorPeter Krempa <pkrempa@redhat.com>
Mon, 18 Dec 2023 21:23:35 +0000 (22:23 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 17 Jan 2024 16:31:12 +0000 (17:31 +0100)
Assigning a PCI address needs to also assign any extension addresses
right away. Otherwise they'd be assigned only after subsequent
format->parse cycle and thus be potentially missing on first run after
defining the VM and thus could change.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain_address.c
tests/qemuxml2xmloutdata/hostdev-vfio-zpci-boundaries.s390x-latest.xml

index 099778b2a863baf836eee40c85c24ea670e3dd4f..979bc8a9fdfd90bb868108bf5d1aace1eaf14cd4 100644 (file)
@@ -2829,10 +2829,16 @@ qemuDomainAssignPCIAddresses(virDomainDef *def,
              * controllers don't plug into any other PCI controller, hence
              * they should skip this step */
             if (bus->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT &&
-                bus->model != VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT &&
-                qemuDomainPCIAddressReserveNextAddr(addrs,
-                                                    &dev.data.controller->info) < 0) {
-                goto cleanup;
+                bus->model != VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
+                if (qemuDomainPCIAddressReserveNextAddr(addrs,
+                                                        &dev.data.controller->info) < 0)
+                    goto cleanup;
+
+                if (qemuDomainFillDevicePCIExtensionFlagsIter(NULL, &dev, &dev.data.controller->info, qemuCaps) < 0)
+                    goto cleanup;
+
+                if (qemuDomainAssignPCIAddressExtension(NULL, NULL, &dev.data.controller->info, addrs) < 0)
+                    goto cleanup;
             }
         }
 
index 8b0044af1c57a7bbc161a09027f6e3cdafc429b6..6a4cf533133a0c5db0abac0b6600a87e034b5973 100644 (file)
@@ -21,7 +21,9 @@
     <controller type='pci' index='1' model='pci-bridge'>
       <model name='pci-bridge'/>
       <target chassisNr='1'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'>
+        <zpci uid='0x0002' fid='0x00000001'/>
+      </address>
     </controller>
     <audio id='1' type='none'/>
     <hostdev mode='subsystem' type='pci' managed='no'>