qemuDomainMachineIsQ35 is renamed to virDomainMachineIsQ35, qemuDomainMachineIsI440FX is renamed to virDomainMachineIsI440FX, both are moved from qemu_domain_address.c to domain_addr.c All these functions are being moved because they don't depend on qemu, so they have the potential to be reused for more hypervisors. --- src/conf/domain_addr.c | 19 +++++++++++++++++++ src/conf/domain_addr.h | 8 ++++++++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_alias.c | 2 +- src/qemu/qemu_capabilities.c | 4 ++-- src/qemu/qemu_command.c | 16 ++++++++-------- src/qemu/qemu_domain.c | 31 ++++++------------------------- src/qemu/qemu_domain.h | 2 -- src/qemu/qemu_domain_address.c | 4 ++-- 9 files changed, 48 insertions(+), 40 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index fcfd84a..f3a75a0 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1369,3 +1369,22 @@ virDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED, cleanup: return ret; } + + +bool +virDomainMachineIsQ35(const virDomainDef *def) +{ + return (STRPREFIX(def->os.machine, "pc-q35") || + STREQ(def->os.machine, "q35")); +} + + +bool +virDomainMachineIsI440FX(const virDomainDef *def) +{ + return (STREQ(def->os.machine, "pc") || + STRPREFIX(def->os.machine, "pc-0.") || + STRPREFIX(def->os.machine, "pc-1.") || + STRPREFIX(def->os.machine, "pc-i440") || + STRPREFIX(def->os.machine, "rhel")); +} diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 273ec0d..fb90ec9 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -238,4 +238,12 @@ virDomainCollectPCIAddress(virDomainDefPtr def, virDomainDeviceInfoPtr info, void *opaque); +bool +virDomainMachineIsQ35(const virDomainDef *def); + +bool +virDomainMachineIsI440FX(const virDomainDef *def); + + + #endif /* __DOMAIN_ADDR_H__ */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 51b3a3f..2697afa 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -93,6 +93,8 @@ virDomainCCWAddressSetFree; virDomainCCWAddressValidate; virDomainCollectPCIAddress; virDomainGetBlkioParametersAssignFromDef; +virDomainMachineIsI440FX; +virDomainMachineIsQ35; virDomainPCIAddressAsString; virDomainPCIAddressBusSetModel; virDomainPCIAddressEnsureAddr; diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index d624071..9e4e03c 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -157,7 +157,7 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef, /* for any Q35 machine, the first SATA controller is the * integrated one, and it too is hardcoded with id "ide" */ - if (qemuDomainMachineIsQ35(domainDef) && controller->idx == 0) + if (virDomainMachineIsQ35(domainDef) && controller->idx == 0) return VIR_STRDUP(controller->info.alias, "ide"); } else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) { /* first USB device is "usb", others are normal "usb%d" */ diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f600ce9..6989a87 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4045,8 +4045,8 @@ virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps, if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_VMPORT_OPT)) return false; - return qemuDomainMachineIsI440FX(def) || - qemuDomainMachineIsQ35(def) || + return virDomainMachineIsI440FX(def) || + virDomainMachineIsQ35(def) || STREQ(def->os.machine, "isapc"); } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index fe4bb88..24295bd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2823,7 +2823,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, /* first SATA controller on Q35 machines is implicit */ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA && - cont->idx == 0 && qemuDomainMachineIsQ35(def)) + cont->idx == 0 && virDomainMachineIsQ35(def)) continue; /* first IDE controller is implicit on various machines */ @@ -2833,7 +2833,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && cont->model == -1 && - !qemuDomainMachineIsQ35(def)) { + !virDomainMachineIsQ35(def)) { bool need_legacy = false; /* We're not using legacy usb controller for q35 */ @@ -2869,7 +2869,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, } if (usbcontroller == 0 && - !qemuDomainMachineIsQ35(def) && + !virDomainMachineIsQ35(def) && !qemuDomainMachineIsVirt(def) && !ARCH_IS_S390(def->os.arch)) virCommandAddArg(cmd, "-usb"); @@ -5979,7 +5979,7 @@ qemuBuildPMCommandLine(virCommandPtr cmd, if (def->pm.s3) { const char *pm_object = "PIIX4_PM"; - if (qemuDomainMachineIsQ35(def) && + if (virDomainMachineIsQ35(def) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_DISABLE_S3)) { pm_object = "ICH9-LPC"; } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX_DISABLE_S3)) { @@ -5996,7 +5996,7 @@ qemuBuildPMCommandLine(virCommandPtr cmd, if (def->pm.s4) { const char *pm_object = "PIIX4_PM"; - if (qemuDomainMachineIsQ35(def) && + if (virDomainMachineIsQ35(def) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_DISABLE_S4)) { pm_object = "ICH9-LPC"; } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX_DISABLE_S4)) { @@ -6178,7 +6178,7 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd, virDomainIOMMUModelTypeToString(def->iommu->model)); return -1; } - if (!qemuDomainMachineIsQ35(def)) { + if (!virDomainMachineIsQ35(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("IOMMU device: '%s' is only supported with " "Q35 machines"), @@ -6212,13 +6212,13 @@ qemuBuildGlobalControllerCommandLine(virCommandPtr cmd, case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: hoststr = "i440FX-pcihost"; cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_I440FX_PCI_HOLE64_SIZE); - machine = qemuDomainMachineIsI440FX(def); + machine = virDomainMachineIsI440FX(def); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: hoststr = "q35-pcihost"; cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_Q35_PCI_HOLE64_SIZE); - machine = qemuDomainMachineIsQ35(def); + machine = virDomainMachineIsQ35(def); break; default: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e51584e..8c23157 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1936,7 +1936,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, addDefaultUSB = false; break; } - if (qemuDomainMachineIsQ35(def)) { + if (virDomainMachineIsQ35(def)) { addPCIeRoot = true; addImplicitSATA = true; @@ -1949,7 +1949,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, addDefaultUSB = false; break; } - if (qemuDomainMachineIsI440FX(def)) + if (virDomainMachineIsI440FX(def)) addPCIRoot = true; break; @@ -2499,14 +2499,14 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) { if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS && - !qemuDomainMachineIsI440FX(def)) { + !virDomainMachineIsI440FX(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("pci-expander-bus controllers are only supported " "on 440fx-based machinetypes")); goto cleanup; } if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS && - !qemuDomainMachineIsQ35(def)) { + !virDomainMachineIsQ35(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("pcie-expander-bus controllers are only supported " "on q35-based machinetypes")); @@ -3213,7 +3213,7 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver, * with libvirt <= 0.9.4. Limitation doesn't apply to other archs * and can cause problems on PPC64. */ - if (ARCH_IS_X86(def->os.arch) && qemuDomainMachineIsI440FX(def) && + if (ARCH_IS_X86(def->os.arch) && virDomainMachineIsI440FX(def) && usb && usb->idx == 0 && usb->model == -1) { VIR_DEBUG("Removing default USB controller from domain '%s'" " for migration compatibility", def->name); @@ -4992,25 +4992,6 @@ qemuFindAgentConfig(virDomainDefPtr def) bool -qemuDomainMachineIsQ35(const virDomainDef *def) -{ - return (STRPREFIX(def->os.machine, "pc-q35") || - STREQ(def->os.machine, "q35")); -} - - -bool -qemuDomainMachineIsI440FX(const virDomainDef *def) -{ - return (STREQ(def->os.machine, "pc") || - STRPREFIX(def->os.machine, "pc-0.") || - STRPREFIX(def->os.machine, "pc-1.") || - STRPREFIX(def->os.machine, "pc-i440") || - STRPREFIX(def->os.machine, "rhel")); -} - - -bool qemuDomainMachineNeedsFDC(const virDomainDef *def) { char *p = STRSKIP(def->os.machine, "pc-q35-"); @@ -5238,7 +5219,7 @@ qemuDomainDefValidateMemoryHotplug(const virDomainDef *def, bool qemuDomainMachineHasBuiltinIDE(const virDomainDef *def) { - return qemuDomainMachineIsI440FX(def) || + return virDomainMachineIsI440FX(def) || STREQ(def->os.machine, "malta") || STREQ(def->os.machine, "sun4u") || STREQ(def->os.machine, "g3beige"); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index bf96ad3..81086d9 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -622,8 +622,6 @@ void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def, virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def); -bool qemuDomainMachineIsQ35(const virDomainDef *def); -bool qemuDomainMachineIsI440FX(const virDomainDef *def); bool qemuDomainMachineNeedsFDC(const virDomainDef *def); bool qemuDomainMachineIsS390CCW(const virDomainDef *def); bool qemuDomainMachineIsVirt(const virDomainDef *def); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 777aab5..02642f9 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -747,12 +747,12 @@ qemuDomainValidateDevicePCISlotsChipsets(virDomainDefPtr def, virDomainPCIAddressSetPtr addrs, bool videoPrimaryEnabled) { - if (qemuDomainMachineIsI440FX(def) && + if (virDomainMachineIsI440FX(def) && qemuDomainValidateDevicePCISlotsPIIX3(def, addrs, videoPrimaryEnabled) < 0) { return -1; } - if (qemuDomainMachineIsQ35(def) && + if (virDomainMachineIsQ35(def) && qemuDomainValidateDevicePCISlotsQ35(def, addrs, videoPrimaryEnabled) < 0) { return -1; } -- 2.7.4 (Apple Git-66) -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list