From f51c6b5b02db069a8c48ea23f35d966e2df5842d Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 18 Dec 2023 22:23:35 +0100 Subject: [PATCH] qemuDomainAssignPCIAddresses: Assign extension addresses when auto-assigning PCI address MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- src/qemu/qemu_domain_address.c | 14 ++++++++++---- .../hostdev-vfio-zpci-boundaries.s390x-latest.xml | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 099778b2a8..979bc8a9fd 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -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; } } diff --git a/tests/qemuxml2xmloutdata/hostdev-vfio-zpci-boundaries.s390x-latest.xml b/tests/qemuxml2xmloutdata/hostdev-vfio-zpci-boundaries.s390x-latest.xml index 8b0044af1c..6a4cf53313 100644 --- a/tests/qemuxml2xmloutdata/hostdev-vfio-zpci-boundaries.s390x-latest.xml +++ b/tests/qemuxml2xmloutdata/hostdev-vfio-zpci-boundaries.s390x-latest.xml @@ -21,7 +21,9 @@ -
+
+ +