[PATCH 052/103] qemu: validate: Move validation of device rom

Peter Krempa pkrempa at redhat.com
Thu Oct 7 15:17:40 UTC 2021


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 <pkrempa at redhat.com>
---
 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 75a30f75ff..95395805e5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1048,12 +1048,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 499c9ed571..08f7fb2f42 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1362,6 +1362,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;
 }

-- 
2.31.1




More information about the libvir-list mailing list