render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
43fe83
From 543a43a569296df0aefa2493def35dc3fab594f0 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <543a43a569296df0aefa2493def35dc3fab594f0.1380703761.git.jdenemar@redhat.com>
43fe83
From: Laine Stump <laine@laine.org>
43fe83
Date: Fri, 27 Sep 2013 05:19:44 -0600
43fe83
Subject: [PATCH] qemu: turn if into switch in
43fe83
 qemuDomainValidateDevicePCISlotsQ35
43fe83
43fe83
This will make it simpler to add checks for other types of
43fe83
controllers.
43fe83
43fe83
This is a prerequisite for patches to resolve:
43fe83
43fe83
   https://bugzilla.redhat.com/show_bug.cgi?id=1003983
43fe83
43fe83
(cherry picked from commit c484fe16cb58174b9ea1c532eeea70be5893ca3c)
43fe83
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 src/qemu/qemu_command.c | 41 +++++++++++++++++++++++------------------
43fe83
 1 file changed, 23 insertions(+), 18 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
43fe83
index 2de7678..47bb22a 100644
43fe83
--- a/src/qemu/qemu_command.c
43fe83
+++ b/src/qemu/qemu_command.c
43fe83
@@ -2465,27 +2465,32 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
43fe83
     char *addrStr = NULL;
43fe83
     qemuDomainPCIConnectFlags flags = QEMU_PCI_CONNECT_TYPE_PCIE;
43fe83
 
43fe83
-    /* Verify that the first SATA controller is at 00:1F.2 */
43fe83
-    /* the q35 machine type *always* has a SATA controller at this address */
43fe83
     for (i = 0; i < def->ncontrollers; i++) {
43fe83
-        if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA &&
43fe83
-            def->controllers[i]->idx == 0) {
43fe83
-            if (def->controllers[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
43fe83
-                if (def->controllers[i]->info.addr.pci.domain != 0 ||
43fe83
-                    def->controllers[i]->info.addr.pci.bus != 0 ||
43fe83
-                    def->controllers[i]->info.addr.pci.slot != 0x1F ||
43fe83
-                    def->controllers[i]->info.addr.pci.function != 2) {
43fe83
-                    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
43fe83
-                                   _("Primary SATA controller must have PCI address 0:0:1f.2"));
43fe83
-                    goto cleanup;
43fe83
+        switch (def->controllers[i]->type) {
43fe83
+        case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
43fe83
+            /* Verify that the first SATA controller is at 00:1F.2 the
43fe83
+             * q35 machine type *always* has a SATA controller at this
43fe83
+             * address.
43fe83
+             */
43fe83
+            if (def->controllers[i]->idx == 0) {
43fe83
+                if (def->controllers[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
43fe83
+                    if (def->controllers[i]->info.addr.pci.domain != 0 ||
43fe83
+                        def->controllers[i]->info.addr.pci.bus != 0 ||
43fe83
+                        def->controllers[i]->info.addr.pci.slot != 0x1F ||
43fe83
+                        def->controllers[i]->info.addr.pci.function != 2) {
43fe83
+                        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
43fe83
+                                       _("Primary SATA controller must have PCI address 0:0:1f.2"));
43fe83
+                        goto cleanup;
43fe83
+                    }
43fe83
+                } else {
43fe83
+                    def->controllers[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
43fe83
+                    def->controllers[i]->info.addr.pci.domain = 0;
43fe83
+                    def->controllers[i]->info.addr.pci.bus = 0;
43fe83
+                    def->controllers[i]->info.addr.pci.slot = 0x1F;
43fe83
+                    def->controllers[i]->info.addr.pci.function = 2;
43fe83
                 }
43fe83
-            } else {
43fe83
-                def->controllers[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
43fe83
-                def->controllers[i]->info.addr.pci.domain = 0;
43fe83
-                def->controllers[i]->info.addr.pci.bus = 0;
43fe83
-                def->controllers[i]->info.addr.pci.slot = 0x1F;
43fe83
-                def->controllers[i]->info.addr.pci.function = 2;
43fe83
             }
43fe83
+            break;
43fe83
         }
43fe83
     }
43fe83
 
43fe83
-- 
43fe83
1.8.3.2
43fe83