From 24be92b8e38762e9ba13e32a4f68568ed26380ea Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 1 Oct 2021 16:47:12 +0200 Subject: [PATCH] qemu: validate: Move validation of device rom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the validation from 'qemuBuildRomStr' into the function which validates device info. It was originally named 'qemuValidateDomainDeviceDefAddress' but this commit renames it to 'qemuValidateDomainDeviceDefInfo'. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_command.c | 6 ------ src/qemu/qemu_validate.c | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 28c18f000d..551014b5b9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1055,12 +1055,6 @@ qemuBuildRomStr(virBuffer *buf, virDomainDeviceInfo *info) { if (info->romenabled || info->rombar || info->romfile) { - if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("ROM tuning is only supported for PCI devices")); - return -1; - } - /* Passing an empty romfile= tells QEMU to disable ROM entirely for * this device, and makes other settings irrelevant */ if (info->romenabled == VIR_TRISTATE_BOOL_NO) { diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 9270f40924..0bbf9208b8 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1403,6 +1403,14 @@ qemuValidateDomainDeviceInfo(const virDomainDeviceDef *dev, } } + if (info->romenabled || info->rombar || info->romfile) { + if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ROM tuning is only supported for PCI devices")); + return -1; + } + } + return 0; }