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