[libvirt] [PATCH 09/10] qemu: caps: Probe events from 'query-qmp-schema' rather than 'query-events'
Eric Blake
eblake at redhat.com
Thu Feb 7 15:54:31 UTC 2019
On 2/7/19 6:28 AM, Peter Krempa wrote:
> QEMU plans to deprecate 'query-events' as it's non-extensible. Events
> are also described by 'query-qmp-schema' so we can use that one instead.
>
> This patch adds detection of events to
> virQEMUCapsProbeQMPSchemaCapabilities using the same structure declaring
> them for the old approach (virQEMUCapsEvents). This is possible as the
> name is the same in the QMP schema and our detector supports that
> trivially.
>
> For any complex queries virQEMUCapsQMPSchemaQueries can be used in the
> future.
>
> For now we still call 'query-events' and discard the result so that it's
> obvious that the tests pass. This will be cleaned up later.
>
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---
> src/qemu/qemu_capabilities.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 7f3f87c48d..9c79511b1d 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -2123,6 +2123,12 @@ virQEMUCapsProbeQMPEvents(virQEMUCapsPtr qemuCaps,
> if ((nevents = qemuMonitorGetEvents(mon, &events)) < 0)
> return -1;
>
> + /* we can probe events also from the QMP schema so we can skip this here */
> + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_QMP_SCHEMA)) {
> + virStringListFreeCount(events, nevents);
> + return 0;
> + }
Slick. For this patch, we call query-events unconditionally (as before),
but when qemu is new enough to also have introspection, we throw away
the results without using them...
> +
> virQEMUCapsProcessStringFlags(qemuCaps,
> ARRAY_CARDINALITY(virQEMUCapsEvents),
> virQEMUCapsEvents,
> @@ -4138,6 +4144,14 @@ virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCapsPtr qemuCaps,
> virQEMUCapsSet(qemuCaps, entry->flag);
> }
>
> + /* probe also for basic event support */
> + for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsEvents); i++) {
> + entry = virQEMUCapsEvents + i;
> +
> + if (virQEMUQAPISchemaPathExists(entry->value, schema))
> + virQEMUCapsSet(qemuCaps, entry->flag);
> + }
> +
...and rebuild the same results from the introspection. I like the
split, and am glad that it was fairly trivial to update to introspection
while still keeping the fallback to query-events on older qemu.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190207/b97f0b2a/attachment-0001.sig>
More information about the libvir-list
mailing list