[PATCH 2/3] qemu: capabilities: Condemn the use of 'device.json' capability name

Peter Krempa posted 3 patches 4 years, 1 month ago
There is a newer version of this series
[PATCH 2/3] qemu: capabilities: Condemn the use of 'device.json' capability name
Posted by Peter Krempa 4 years, 1 month ago
As a workaround for users using 'libvirt-7.9' and 'libvirt-7.10' with
'qemu-6.2' who wish to use device hot-unplug we are going to be
suggesting to filter out the 'device.json' qemu capability via either
the global 'qemu.conf' config:

  capability_filters = [ "device.json" ]

or the per-VM XML capability override:

 <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>

 [...]

  <qemu:capabilities>
    <qemu:del capability='device.json'/>
  </qemu:capabilities>
 </domain>

Doing this poisons the capability name 'device.json' for any further
use, so to ensure that we can re-add JSON usage for -device also for
users which filtered it out originally once it's fixed in qemu we need
to condemn the old name and add a new one.

To achieve this the old capability is renamed to
'X_QEMU_CAPS_DEVICE_JSON_BROKEN' and a new capability
'QEMU_CAPS_DEVICE_JSON' is mapped to 'device.json-fixed'. For now we
leave it unasserted, but this allows to keep all the code in place.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_capabilities.c | 3 ++-
 src/qemu/qemu_capabilities.h | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2efe5776f8..e650e81ab8 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -649,10 +649,11 @@ VIR_ENUM_IMPL(virQEMUCaps,
               "chardev.json", /* QEMU_CAPS_CHARDEV_JSON */

               /* 415 */
-              "device.json", /* QEMU_CAPS_DEVICE_JSON */
+              "device.json", /* X_QEMU_CAPS_DEVICE_JSON_BROKEN */
               "query-dirty-rate", /* QEMU_CAPS_QUERY_DIRTY_RATE */
               "rbd-encryption", /* QEMU_CAPS_RBD_ENCRYPTION */
               "sev-guest-kernel-hashes", /* QEMU_CAPS_SEV_GUEST_KERNEL_HASHES */
+              "device.json-fixed" /* QEMU_CAPS_DEVICE_JSON */
     );


diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index aaac20a834..43cf8464ae 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -628,10 +628,11 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
     QEMU_CAPS_CHARDEV_JSON, /* -chardev accepts JSON */

     /* 415 */
-    QEMU_CAPS_DEVICE_JSON, /* -device accepts JSON */
+    X_QEMU_CAPS_DEVICE_JSON_BROKEN, /* -device accepts JSON - unused due a qemu regression */
     QEMU_CAPS_QUERY_DIRTY_RATE, /* accepts query-dirty-rate */
     QEMU_CAPS_RBD_ENCRYPTION, /* Ceph RBD encryption support */
     QEMU_CAPS_SEV_GUEST_KERNEL_HASHES, /* sev-guest.kernel-hashes= */
+    QEMU_CAPS_DEVICE_JSON, /* -device accepts JSON */

     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
-- 
2.31.1

Re: [PATCH 2/3] qemu: capabilities: Condemn the use of 'device.json' capability name
Posted by Ján Tomko 4 years, 1 month ago
On a Monday in 2022, Peter Krempa wrote:
>As a workaround for users using 'libvirt-7.9' and 'libvirt-7.10' with
>'qemu-6.2' who wish to use device hot-unplug we are going to be
>suggesting to filter out the 'device.json' qemu capability via either
>the global 'qemu.conf' config:
>
>  capability_filters = [ "device.json" ]
>
>or the per-VM XML capability override:
>
> <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
>
> [...]
>
>  <qemu:capabilities>
>    <qemu:del capability='device.json'/>
>  </qemu:capabilities>
> </domain>
>
>Doing this poisons the capability name 'device.json' for any further
>use, so to ensure that we can re-add JSON usage for -device also for
>users which filtered it out originally once it's fixed in qemu we need
>to condemn the old name and add a new one.
>
>To achieve this the old capability is renamed to
>'X_QEMU_CAPS_DEVICE_JSON_BROKEN' and a new capability
>'QEMU_CAPS_DEVICE_JSON' is mapped to 'device.json-fixed'. For now we

I am not a fan of the new string but we can change it later once it's
clear how to probe for this in QEMU.

Jano

>leave it unasserted, but this allows to keep all the code in place.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_capabilities.c | 3 ++-
> src/qemu/qemu_capabilities.h | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
Re: [PATCH 2/3] qemu: capabilities: Condemn the use of 'device.json' capability name
Posted by Peter Krempa 4 years, 1 month ago
On Mon, Jan 03, 2022 at 16:56:32 +0100, Ján Tomko wrote:
> On a Monday in 2022, Peter Krempa wrote:
> > As a workaround for users using 'libvirt-7.9' and 'libvirt-7.10' with
> > 'qemu-6.2' who wish to use device hot-unplug we are going to be
> > suggesting to filter out the 'device.json' qemu capability via either
> > the global 'qemu.conf' config:
> > 
> >  capability_filters = [ "device.json" ]
> > 
> > or the per-VM XML capability override:
> > 
> > <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
> > 
> > [...]
> > 
> >  <qemu:capabilities>
> >    <qemu:del capability='device.json'/>
> >  </qemu:capabilities>
> > </domain>
> > 
> > Doing this poisons the capability name 'device.json' for any further
> > use, so to ensure that we can re-add JSON usage for -device also for
> > users which filtered it out originally once it's fixed in qemu we need
> > to condemn the old name and add a new one.
> > 
> > To achieve this the old capability is renamed to
> > 'X_QEMU_CAPS_DEVICE_JSON_BROKEN' and a new capability
> > 'QEMU_CAPS_DEVICE_JSON' is mapped to 'device.json-fixed'. For now we
> 
> I am not a fan of the new string but we can change it later once it's
> clear how to probe for this in QEMU.

In fact, I can leave this commit out for now, or replace it by just
noting in qemu_capabilities.h that the flag name was poisoned by
recomending users to filter it out and a new one must be picked when
re-instating this feature.