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
This commit is contained in:
Laine Stump 2013-09-25 06:59:46 -04:00
parent b83d26f6c4
commit c484fe16cb
1 changed files with 23 additions and 18 deletions

View File

@ -2534,27 +2534,32 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
char *addrStr = NULL; char *addrStr = NULL;
qemuDomainPCIConnectFlags flags = QEMU_PCI_CONNECT_TYPE_PCIE; 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++) { for (i = 0; i < def->ncontrollers; i++) {
if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA && switch (def->controllers[i]->type) {
def->controllers[i]->idx == 0) { case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
if (def->controllers[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { /* Verify that the first SATA controller is at 00:1F.2 the
if (def->controllers[i]->info.addr.pci.domain != 0 || * q35 machine type *always* has a SATA controller at this
def->controllers[i]->info.addr.pci.bus != 0 || * address.
def->controllers[i]->info.addr.pci.slot != 0x1F || */
def->controllers[i]->info.addr.pci.function != 2) { if (def->controllers[i]->idx == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", if (def->controllers[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
_("Primary SATA controller must have PCI address 0:0:1f.2")); if (def->controllers[i]->info.addr.pci.domain != 0 ||
goto cleanup; 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;
} }
} }