[PATCH for 7.10] qemu: Fix validation of PCI option rom settings on hotplug

Peter Krempa posted 1 patch 2 years, 5 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1b2e30fb1bfce39a926b07ac19613e80747f511e.1637853866.git.pkrempa@redhat.com
src/qemu/qemu_command.c  | 6 ++++++
src/qemu/qemu_validate.c | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
[PATCH for 7.10] qemu: Fix validation of PCI option rom settings on hotplug
Posted by Peter Krempa 2 years, 5 months ago
Commit 24be92b8e moved the option rom settings validation code to the
validation callbacks, but that doesn't work properly with device hotplug
as we assign addresses only after parsing the whole XML. The check is
too strict for that and caused failures when hotplugging devices such
as:

 <interface type='network'>
   <source network='default'/>
   <model type='virtio'/>
   <rom enabled='no'/>
 </interface>

This patch relaxes the check in the validation callback to accept also
_NONE and _UNASSIGNED address types and returns the check to
'qemuBuildRomProps' so that we preserve the full validation as we've
used to.

Fixes: 24be92b8e38762e9ba13e
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2021437
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_command.c  | 6 ++++++
 src/qemu/qemu_validate.c | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7a185061d8..c47998aabd 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1147,6 +1147,12 @@ qemuBuildRomProps(virJSONValue *props,
         !info->romfile)
         return 0;

+    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;
+    }
+
     if (info->romenabled == VIR_TRISTATE_BOOL_NO) {
         romfile = "";
     } else {
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 397eea5ede..1de6e05101 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1485,7 +1485,9 @@ qemuValidateDomainDeviceInfo(const virDomainDeviceDef *dev,
     }

     if (info->romenabled || info->rombar || info->romfile) {
-        if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+        if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
+            info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+            info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("ROM tuning is only supported for PCI devices"));
             return -1;
-- 
2.31.1

Re: [PATCH for 7.10] qemu: Fix validation of PCI option rom settings on hotplug
Posted by Ján Tomko 2 years, 5 months ago
On a Thursday in 2021, Peter Krempa wrote:
>Commit 24be92b8e moved the option rom settings validation code to the
>validation callbacks, but that doesn't work properly with device hotplug
>as we assign addresses only after parsing the whole XML. The check is
>too strict for that and caused failures when hotplugging devices such
>as:
>
> <interface type='network'>
>   <source network='default'/>
>   <model type='virtio'/>
>   <rom enabled='no'/>
> </interface>
>
>This patch relaxes the check in the validation callback to accept also
>_NONE and _UNASSIGNED address types and returns the check to
>'qemuBuildRomProps' so that we preserve the full validation as we've
>used to.
>
>Fixes: 24be92b8e38762e9ba13e
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2021437
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_command.c  | 6 ++++++
> src/qemu/qemu_validate.c | 4 +++-
> 2 files changed, 9 insertions(+), 1 deletion(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano