]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Move index number checking to drivers
authorAndrea Bolognani <abologna@redhat.com>
Fri, 24 Feb 2017 15:45:13 +0000 (16:45 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Sat, 15 Jul 2017 12:50:42 +0000 (14:50 +0200)
pSeries guests will soon be allowed to have multiple
PHBs (pci-root controllers), which of course means that
all but one of them will have a non-zero index; hence,
we'll need to relax the current check.

However, right now the check is performed in the conf
module, which is generic rather than tied to the QEMU
driver, and where we don't have information such as the
guest machine type available.

To make this change of behavior possible down the line,
we need to move the check from the XML parser to the
drivers. Luckily, only QEMU and bhyve are using PCI
controllers, so this doesn't result in much duplication.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
src/bhyve/bhyve_domain.c
src/conf/domain_conf.c
src/qemu/qemu_domain.c

index 20c82937b5eb973b2f7a06c952fa8950c16ef898..71764554eb11c4443faf689dfb9baf99ce229910 100644 (file)
@@ -122,6 +122,21 @@ bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
             bhyveDomainDiskDefAssignAddress(driver, disk, def) < 0)
             return -1;
     }
+
+    if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) {
+        virDomainControllerDefPtr cont = dev->data.controller;
+
+        if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
+            (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT ||
+             cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) &&
+            cont->idx != 0) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("pci-root and pcie-root controllers "
+                             "should have index 0"));
+            return -1;
+        }
+    }
+
     return 0;
 }
 
index b87fc869a6bcbd68464ef131ee4727e7efd6c86d..90d5cc036207475e2ac6ea14d8bffeb012949562 100644 (file)
@@ -9302,12 +9302,6 @@ virDomainControllerDefParseXML(xmlNodePtr node,
                                  "have an address"));
                 goto error;
             }
-            if (def->idx > 0) {
-                virReportError(VIR_ERR_XML_ERROR, "%s",
-                               _("pci-root and pcie-root controllers "
-                                 "should have index 0"));
-                goto error;
-            }
             if ((rc = virDomainParseScaledValue("./pcihole64", NULL,
                                                 ctxt, &bytes, 1024,
                                                 1024ULL * ULONG_MAX, false)) < 0)
index 78e75f130a1f3434c2c47d579a6052ac3715addd..bf6c6701430ab8bdba3e434ad1d93715e8cc9157 100644 (file)
@@ -3426,6 +3426,15 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
         break;
 
     case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
+        if  ((cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT ||
+              cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) &&
+             cont->idx != 0) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("pci-root and pcie-root controllers "
+                             "should have index 0"));
+            return -1;
+        }
+
         if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS &&
             !qemuDomainIsI440FX(def)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",