render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
6d3351
From c7a41d3b282e1d2c0ea498f1e72e89a78178243c Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <c7a41d3b282e1d2c0ea498f1e72e89a78178243c@dist-git>
6d3351
From: Andrea Bolognani <abologna@redhat.com>
6d3351
Date: Mon, 17 Jul 2017 12:09:13 +0200
6d3351
Subject: [PATCH] qemu: Format additional PHBs on the command line
6d3351
6d3351
Additional PHBs (pci-root controllers) will be created for
6d3351
the guest using the spapr-pci-host-bridge QEMU device, if
6d3351
available; the implicit default PHB, while present in the
6d3351
guest configuration, will be skipped.
6d3351
6d3351
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1431193
6d3351
6d3351
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6d3351
Reviewed-by: Laine Stump <laine@laine.org>
6d3351
(cherry picked from commit d54bc07820a12eb6ac9268c547c34690406a3667)
6d3351
6d3351
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1431193
6d3351
6d3351
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 src/qemu/qemu_command.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
6d3351
 1 file changed, 46 insertions(+), 3 deletions(-)
6d3351
6d3351
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
6d3351
index 0176f0d63f..cb0eac4668 100644
6d3351
--- a/src/qemu/qemu_command.c
6d3351
+++ b/src/qemu/qemu_command.c
6d3351
@@ -3158,6 +3158,40 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
6d3351
                                  def->opts.pciopts.numaNode);
6d3351
             break;
6d3351
         case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
6d3351
+            if (def->opts.pciopts.modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE ||
6d3351
+                def->opts.pciopts.targetIndex == -1) {
6d3351
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
6d3351
+                               _("autogenerated pci-root options not set"));
6d3351
+                goto error;
6d3351
+            }
6d3351
+
6d3351
+            /* Skip the implicit one */
6d3351
+            if (def->opts.pciopts.targetIndex == 0)
6d3351
+                goto done;
6d3351
+
6d3351
+            modelName = virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
6d3351
+            if (!modelName) {
6d3351
+                virReportError(VIR_ERR_INTERNAL_ERROR,
6d3351
+                               _("unknown pci-root model name value %d"),
6d3351
+                               def->opts.pciopts.modelName);
6d3351
+                goto error;
6d3351
+            }
6d3351
+            if (def->opts.pciopts.modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE) {
6d3351
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
6d3351
+                               _("PCI controller model name '%s' is not valid for a pci-root"),
6d3351
+                               modelName);
6d3351
+                goto error;
6d3351
+            }
6d3351
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE)) {
6d3351
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
6d3351
+                               _("the spapr-pci-host-bridge controller "
6d3351
+                                 "is not supported in this QEMU binary"));
6d3351
+                goto error;
6d3351
+            }
6d3351
+            virBufferAsprintf(&buf, "%s,index=%d,id=%s",
6d3351
+                              modelName, def->opts.pciopts.targetIndex,
6d3351
+                              def->info.alias);
6d3351
+            break;
6d3351
         case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
6d3351
         case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
6d3351
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
6d3351
@@ -3207,6 +3241,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
6d3351
     if (virBufferCheckError(&buf) < 0)
6d3351
         goto error;
6d3351
 
6d3351
+ done:
6d3351
     *devstr = virBufferContentAndReset(&buf;;
6d3351
     return 0;
6d3351
 
6d3351
@@ -3264,11 +3299,19 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
6d3351
                 continue;
6d3351
             }
6d3351
 
6d3351
-            /* skip pci-root/pcie-root */
6d3351
+            /* skip pcie-root */
6d3351
             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
6d3351
-                (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT ||
6d3351
-                 cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT))
6d3351
+                cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
6d3351
                 continue;
6d3351
+            }
6d3351
+
6d3351
+            /* Skip pci-root, except for pSeries guests (which actually
6d3351
+             * support more than one PCI Host Bridge per guest) */
6d3351
+            if (!qemuDomainIsPSeries(def) &&
6d3351
+                cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
6d3351
+                cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) {
6d3351
+                continue;
6d3351
+            }
6d3351
 
6d3351
             /* first SATA controller on Q35 machines is implicit */
6d3351
             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA &&
6d3351
-- 
6d3351
2.13.3
6d3351