Move the validation of vmcoreinfo from qemuBuildVMCoreInfoCommandLine()
to qemuDomainDefValidateFeatures(), allowing for validation
at domain define time.
qemuxml2xmltest.c was changed to account for this caps being
now validated at this earlier stage.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_command.c | 12 ++----------
src/qemu/qemu_domain.c | 11 ++++++++++-
tests/qemuxml2xmltest.c | 2 +-
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 67f7caf9c6..44cc647359 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9217,21 +9217,13 @@ qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd,
static int
qemuBuildVMCoreInfoCommandLine(virCommandPtr cmd,
- const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ const virDomainDef *def)
{
virTristateSwitch vmci = def->features[VIR_DOMAIN_FEATURE_VMCOREINFO];
if (vmci != VIR_TRISTATE_SWITCH_ON)
return 0;
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMCOREINFO)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("vmcoreinfo is not available "
- "with this QEMU binary"));
- return -1;
- }
-
virCommandAddArgList(cmd, "-device", "vmcoreinfo", NULL);
return 0;
}
@@ -9933,7 +9925,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildNVRAMCommandLine(cmd, def) < 0)
return NULL;
- if (qemuBuildVMCoreInfoCommandLine(cmd, def, qemuCaps) < 0)
+ if (qemuBuildVMCoreInfoCommandLine(cmd, def) < 0)
return NULL;
if (qemuBuildSEVCommandLine(vm, cmd, def->sev) < 0)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f6683d11e0..2dbe6f6454 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5149,6 +5149,16 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
}
break;
+ case VIR_DOMAIN_FEATURE_VMCOREINFO:
+ if (def->features[i] == VIR_TRISTATE_SWITCH_ON &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMCOREINFO)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("vmcoreinfo is not available "
+ "with this QEMU binary"));
+ return -1;
+ }
+ break;
+
case VIR_DOMAIN_FEATURE_ACPI:
case VIR_DOMAIN_FEATURE_APIC:
case VIR_DOMAIN_FEATURE_PAE:
@@ -5159,7 +5169,6 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
case VIR_DOMAIN_FEATURE_PVSPINLOCK:
case VIR_DOMAIN_FEATURE_CAPABILITIES:
case VIR_DOMAIN_FEATURE_PMU:
- case VIR_DOMAIN_FEATURE_VMCOREINFO:
case VIR_DOMAIN_FEATURE_MSRS:
case VIR_DOMAIN_FEATURE_LAST:
break;
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 64321bcb80..5ab00e5552 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1330,7 +1330,7 @@ mymain(void)
DO_TEST("cpu-check-default-none2", NONE);
DO_TEST("cpu-check-default-partial", NONE);
DO_TEST("cpu-check-default-partial2", NONE);
- DO_TEST("vmcoreinfo", NONE);
+ DO_TEST("vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO);
DO_TEST("smartcard-host", QEMU_CAPS_CCID_EMULATED);
DO_TEST("smartcard-host-certificates", QEMU_CAPS_CCID_EMULATED);
--
2.23.0