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.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_command.c | 24 ++----------------------
src/qemu/qemu_domain.c | 37 +++++++++++++++++++++++++++++++------
tests/qemuxml2argvtest.c | 2 +-
tests/qemuxml2xmltest.c | 6 +++---
4 files changed, 37 insertions(+), 32 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7d4272a896..31b8784070 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6392,8 +6392,7 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
static int
qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
- const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ const virDomainDef *def)
{
size_t i;
@@ -6402,20 +6401,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:
@@ -6425,19 +6418,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);
@@ -9995,7 +9975,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)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 0c04ba9dcc..7f6daaf276 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7188,13 +7188,38 @@ 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");
- return -1;
+ 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;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 802ecc98f8..3a002bb393 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -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,
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index ee76d50a41..0eb523fd43 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -996,9 +996,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,
--
2.23.0