From 2d8a60fab1dc4a00fcc86d58045c6735bfd1ee19 Mon Sep 17 00:00:00 2001 From: Daniel Henrique Barboza Date: Fri, 9 Oct 2020 17:09:03 -0300 Subject: [PATCH] qemu_command.c: move QEMU_CAPS_FW_CFG validation to qemu_validate.c Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_command.c | 9 +-------- src/qemu/qemu_validate.c | 9 ++++++++- tests/qemuxml2xmltest.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f350800ff0..87d76827e8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5758,7 +5758,6 @@ qemuBuildSmbiosCommandLine(virCommandPtr cmd, static int qemuBuildSysinfoCommandLine(virCommandPtr cmd, - virQEMUCapsPtr qemuCaps, const virDomainDef *def) { size_t i; @@ -5771,12 +5770,6 @@ qemuBuildSysinfoCommandLine(virCommandPtr cmd, if (def->sysinfo[i]->type != VIR_SYSINFO_FWCFG) continue; - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_FW_CFG)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("fw_cfg is not supported with this QEMU")); - return -1; - } - for (j = 0; j < def->sysinfo[i]->nfw_cfgs; j++) { const virSysinfoFWCfgDef *f = &def->sysinfo[i]->fw_cfgs[j]; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; @@ -9928,7 +9921,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildSmbiosCommandLine(cmd, driver, def) < 0) return NULL; - if (qemuBuildSysinfoCommandLine(cmd, qemuCaps, def) < 0) + if (qemuBuildSysinfoCommandLine(cmd, def) < 0) return NULL; if (qemuBuildVMGenIDCommandLine(cmd, def) < 0) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 6906c313dd..4a7a25ae8e 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -778,10 +778,17 @@ qemuValidateDefGetVcpuHotplugGranularity(const virDomainDef *def) static int qemuValidateDomainDefSysinfo(const virSysinfoDef *def, - virQEMUCapsPtr qemuCaps G_GNUC_UNUSED) + virQEMUCapsPtr qemuCaps) { size_t i; + if (def->type == VIR_SYSINFO_FWCFG && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_FW_CFG)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("fw_cfg is not supported with this QEMU")); + return -1; + } + for (i = 0; i < def->nfw_cfgs; i++) { const virSysinfoFWCfgDef *f = &def->fw_cfgs[i]; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 2213dc8615..6c551f18ab 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1153,7 +1153,7 @@ mymain(void) QEMU_CAPS_DEVICE_IVSHMEM_PLAIN, QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL); DO_TEST("smbios", NONE); DO_TEST("smbios-multiple-type2", NONE); - DO_TEST("smbios-type-fwcfg", NONE); + DO_TEST("smbios-type-fwcfg", QEMU_CAPS_FW_CFG); DO_TEST_CAPS_LATEST("os-firmware-bios"); DO_TEST_CAPS_LATEST("os-firmware-efi");