From 94f6e2f9fcd8cf764e9dbfc7258971165798f62e Mon Sep 17 00:00:00 2001 From: Daniel Henrique Barboza Date: Tue, 17 Dec 2019 21:36:03 -0300 Subject: [PATCH] qemu: command: move validation of vmcoreinfo to qemu_domain.c 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. Reviewed-by: Cole Robinson Signed-off-by: Daniel Henrique Barboza --- 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 1d6607db2c..9cb1af6723 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9223,21 +9223,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; } @@ -9939,7 +9931,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); -- GitLab