提交 83d7dadc 编写于 作者: D Daniel Henrique Barboza 提交者: Cole Robinson

qemu: command: move pcihole64 validation to qemu_domain.c

Move the pcihole64 validation being done by
qemuBuildGlobalControllerCommandLine() to the existing function
qemuDomainDeviceDefValidateControllerPCI(), which provides
domain define time validation.

The existing pcihole64 validations in qemu_domain.c were replaced
by the ones moved from qemu_command.c. The reason is that they
are more specific, allowing VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT
and VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT to have distinct validation,
with exclusive QEMU caps and machine types.

Tests were adapted to consider the new caps being needed in
this earlier stage.
Reviewed-by: NCole Robinson <crobinso@redhat.com>
Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
上级 7be4bfd2
......@@ -6435,8 +6435,7 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
static int
qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
const virDomainDef *def)
{
size_t i;
......@@ -6445,20 +6444,14 @@ qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
cont->opts.pciopts.pcihole64) {
const char *hoststr = NULL;
bool cap = false;
bool machine = false;
switch (cont->model) {
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
hoststr = "i440FX-pcihost";
cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
machine = qemuDomainIsI440FX(def);
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
hoststr = "q35-pcihost";
cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_Q35_PCI_HOLE64_SIZE);
machine = qemuDomainIsQ35(def);
break;
default:
......@@ -6468,19 +6461,6 @@ qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
return -1;
}
if (!machine) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Setting the 64-bit PCI hole size is not "
"supported for machine '%s'"), def->os.machine);
return -1;
}
if (!cap) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("64-bit PCI hole size setting is not supported "
"with this QEMU binary"));
return -1;
}
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "%s.pci-hole64-size=%luK", hoststr,
cont->opts.pciopts.pcihole64size);
......@@ -10043,7 +10023,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildIOMMUCommandLine(cmd, def, qemuCaps) < 0)
return NULL;
if (qemuBuildGlobalControllerCommandLine(cmd, def, qemuCaps) < 0)
if (qemuBuildGlobalControllerCommandLine(cmd, def) < 0)
return NULL;
if (qemuBuildControllersCommandLine(cmd, def, qemuCaps) < 0)
......
......@@ -7255,14 +7255,39 @@ qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *cont,
/* pcihole64 */
switch ((virDomainControllerModelPCI) cont->model) {
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
if (pciopts->pcihole64 || pciopts->pcihole64size != 0) {
if (!qemuDomainIsI440FX(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Setting the 64-bit PCI hole size is not "
"supported for machine '%s'"), def->os.machine);
return -1;
}
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_I440FX_PCI_HOLE64_SIZE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("64-bit PCI hole size setting is not supported "
"with this QEMU binary"));
return -1;
}
}
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
/* The pcihole64 option only applies to x86 guests */
if ((pciopts->pcihole64 ||
pciopts->pcihole64size != 0) &&
!ARCH_IS_X86(def->os.arch)) {
virReportControllerInvalidOption(cont, model, modelName, "pcihole64");
if (pciopts->pcihole64 || pciopts->pcihole64size != 0) {
if (!qemuDomainIsQ35(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Setting the 64-bit PCI hole size is not "
"supported for machine '%s'"), def->os.machine);
return -1;
}
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_Q35_PCI_HOLE64_SIZE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("64-bit PCI hole size setting is not supported "
"with this QEMU binary"));
return -1;
}
}
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
......
......@@ -2526,7 +2526,7 @@ mymain(void)
QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_SCSI);
DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
DO_TEST_FAILURE("pcihole64-none", NONE);
DO_TEST_PARSE_ERROR("pcihole64-none", NONE);
DO_TEST("pcihole64-q35",
QEMU_CAPS_DEVICE_IOH3420,
QEMU_CAPS_ICH9_AHCI,
......
......@@ -991,9 +991,9 @@ mymain(void)
DO_TEST("s390-serial-console",
QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
DO_TEST("pcihole64", NONE);
DO_TEST("pcihole64-gib", NONE);
DO_TEST("pcihole64-none", NONE);
DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
DO_TEST("pcihole64-gib", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
DO_TEST("pcihole64-none", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
DO_TEST("pcihole64-q35",
QEMU_CAPS_DEVICE_IOH3420,
QEMU_CAPS_ICH9_AHCI,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册