]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: improve error message when a PCI controller can't be auto-added
authorLaine Stump <laine@redhat.com>
Tue, 26 Aug 2025 18:41:32 +0000 (14:41 -0400)
committerLaine Stump <laine@redhat.com>
Wed, 10 Sep 2025 17:12:41 +0000 (13:12 -0400)
Log a slightly different message when the missing-but-required slot is
conventional PCI vs PCIe. Also correct/improve the comments about why
auto-add of a PCI controller isn't supported when we're trying to
create a slot for various different pci controllers.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_addr.c
tests/qemuxmlconfdata/pcie-root-port-too-many.x86_64-latest.err

index 7d58e2222af7280f347660be8b239ad3290139da..ef1b2bd69aa37e4791e3c92350fd5552475b3704 100644 (file)
@@ -704,7 +704,7 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSet *addrs,
          *  and we can't automatically decide which numa node to
          *  associate it with)
          *
-         * VIR_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT - we ndon't
+         * VIR_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT - we don't
          *  support this, because it can only plug into an
          *  upstream-port, and the upstream port might need a
          *  root-port; supporting this extra layer needlessly
@@ -717,20 +717,41 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSet *addrs,
          *  devices on the host, and are also outside the scope of our
          *  "automatic-bus-expansion".
          *
-         * VIR_PCI_CONNECT_TYPE_PCI_BRIDGE (when the root bus is
-         *  pci-root) - see the comment above in the case that handles
-         *  adding a slot for pci-bridge to a guest with pcie-root.
+         * VIR_PCI_CONNECT_TYPE_PCI_BRIDGE if the root bus is pci-root
+         *  but there are no free slots already available to plug in a
+         *  pci-bridge, then the battle is already lost - the only way
+         *  to get another open slot would be to auto-add a pci-bridge
+         *  device, but that's what we're already trying to do - by
+         *  definition either we wouldn't get here in the first place,
+         *  or it's already too late.
+         *
+         *  Alternatively if the root bus *isn't* pci-root, then
+         *  either the root bus is pcie-root (in which case the user
+         *  should be using a pcie-to-pci-bridge instead), or there is
+         *  no PCI supported *at all*, and in both of those cases we
+         *  should fail.
+         *
+         * Additionally, we obviously can't auto-add any type of PCIe
+         * controller if the root bus is pci-root, or if there is no
+         * PCI supported at all.
          *
          */
         int existingContModel = virDomainPCIControllerConnectTypeToModel(flags);
 
         if (existingContModel >= 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("a PCI slot is needed to connect a PCI controller model='%1$s', but none is available, and it cannot be automatically added"),
-                           virDomainControllerModelPCITypeToString(existingContModel));
+            if (existingContModel == VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS ||
+                existingContModel == VIR_PCI_CONNECT_TYPE_PCI_BRIDGE) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("a conventional PCI slot is needed to connect a PCI controller model='%1$s', but none is available, and it cannot be automatically added"),
+                               virDomainControllerModelPCITypeToString(existingContModel));
+            } else {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("a PCIe slot is needed to connect a PCI controller model='%1$s', but none is available, and it cannot be automatically added"),
+                               virDomainControllerModelPCITypeToString(existingContModel));
+            }
         } else {
             virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Cannot automatically add a new PCI bus for a device with connect flags %1$.2x"),
+                           _("Cannot automatically add a new PCI bus for a device with unrecognized connect flags %1$.2x"),
                            flags);
         }
         return -1;
index 9b24cfb7e04ec50aedf40503d16130006e85f13e..e1d543a50a8e11684e85adef6f0bd3a310ba00e1 100644 (file)
@@ -1 +1 @@
-internal error: a PCI slot is needed to connect a PCI controller model='pcie-root-port', but none is available, and it cannot be automatically added
+internal error: a PCIe slot is needed to connect a PCI controller model='pcie-root-port', but none is available, and it cannot be automatically added