All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Peter Krempa <pkrempa@redhat.com>
Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berrange@redhat.com,
	libvir-list@redhat.com, eblake@redhat.com,
	mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org,
	marcandre.lureau@redhat.com, jsnow@redhat.com,
	libguestfs@redhat.com
Subject: Re: [PATCH RFC 1/5] qapi: Enable enum member introspection to show more than name
Date: Sat, 09 Oct 2021 10:08:40 +0200	[thread overview]
Message-ID: <87r1cu39iv.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <YUha7xwblG1cqeNx@angien.pipo.sk> (Peter Krempa's message of "Mon, 20 Sep 2021 11:57:03 +0200")

Peter Krempa <pkrempa@redhat.com> writes:

> On Mon, Sep 20, 2021 at 11:08:59 +0200, Markus Armbruster wrote:
>> Peter Krempa <pkrempa@redhat.com> writes:
>> 
>> > On Wed, Sep 15, 2021 at 21:24:21 +0200, Markus Armbruster wrote:
>> >> The next commit will add feature flags to enum members.  There's a
>> >> problem, though: query-qmp-schema shows an enum type's members as an
>> >> array of member names (SchemaInfoEnum member @values).  If it showed
>> >> an array of objects with a name member, we could simply add more
>> >> members to these objects.  Since it's just strings, we can't.
>> >> 
>> >> I can see three ways to correct this design mistake:
>> >> 
>> >> 1. Do it the way we should have done it, plus compatibility goo.
>> >> 
>> >>    We want a ['SchemaInfoEnumMember'] member in SchemaInfoEnum.  Since
>> >>    changing @values would be a compatibility break, add a new member
>> >>    @members instead.
>> >> 
>> >>    @values is now redundant.  We should be able to get rid of it
>> >>    eventually.
>> >> 
>> >>    In my testing, output of qemu-system-x86_64's query-qmp-schema
>> >>    grows by 11% (18.5KiB).
>> >
>> > I prefer this one. While the schema output grows, nobody is really
>> > reading it manually.
>> 
>> True, but growing schema output can only slow down client startup.
>> Negligible for libvirt, I presume?
>
> Libvirt employs caching, so unless it's the first VM started after a
> qemu/libvirt upgrade, the results are already processed and cached.

Good!

> In fact we don't even keep the full schema around, we just extract
> information and store them as capability bits. For now we didn't run
> into the need to have the full schema around when starting a VM.
>
> [...]
>
>> >> 3. Versioned query-qmp-schema.
>> >> 
>> >>    query-qmp-schema provides either @values or @members.  The QMP
>> >>    client can select which version it wants.
>> >
>> > At least for libvirt this poses a chicken & egg problem. We'd have to
>> > query the schema to see that it has the switch to do the selection and
>> > then probe with the modern one.
>> 
>> The simplest solution is to try the versions the management application
>> can understand in order of preference (newest to oldest) until one
>> succeeds.  I'd expect the first try to work most of the time.  Only when
>> you combine new libvirt with old QEMU, the fallback has to kick in.
>> 
>> Other parts of the management application should remain oblivous of the
>> differences.
>
> That would certainly work and be reasonably straightforward for libvirt
> to implement, but:
>  1) libvirt's code for using the QMP schema would be exactly the same as
>     with approach 1), as we need to handle old clients too and the new
>     way is simply a superset of what we have

Yes, libvirt would need the same code for processing old and new.  The
only difference would be how it decides which method to use.  With 1,
it's "if @members is present, use it, else @values".  With 2, it's "if
the version we use is new enough, use @members, else @values".

>  2) qemu's deprecation approach itself wouldn't be any easier in either
>     of those scenarios
>
> Basically the only thing this would gain us is that if the deprecation
> period is over old clients which were not fixed could fail silently:
>
> Assuming that 'query-qmp-schema' gains a boolean option such as
> 'fancier-enums' and setting that to true returns the new format of
> schema, after the deprecation is over you could simply return an error
> if a caller omits 'fancier-enums' or sets it to false, which creates a
> clean cut for the removal.

Yes.

> With approach 1) itself, clients which were not adapted would start
> lacking information based on enum values.
>
> Now for those it depends on how they actually handled it until now. E.g.
> old libvirt would report that the QMP schema is broken if 'values' would
> be missing.

Which I consider the sensible thing to do.

> Whether that's a worthwhile thing to do? I'm not really persuaded. (And
> I'm biased since libvirt handles it correctly).

I think 3 has the following advantages over 1:

* As you noted, it ensures outmoded clients fail cleanly.  Not much of
  an advantage for clients that handle missing @values sensibly.
  Perhaps it could enable better error messages.

* It avoids duplicated contents in old an new format.  Not much of an
  advantage for clients that cache their schema interrogation.

* It can enable more radical introspection changes.  Without versioning,
  the common rules for compatible evolution apply (section
  "Compatibility considerations" in qapi-code-gen.rst).  With
  versioning, they don't.

I agree this is not really compelling just for the problem at hand.  We
can reconsider when we run into more problems.

>> We could of course try to reduce the number of roundtrips, say by
>> putting sufficient information into the QMP greeting (one roundtrip), or
>> the output of query-qmp-schema (try oldest to find the best one, then
>> try the best one unless it's the oldest).  I doubt that's worthwhile.
>
> In this particular scenario, I'd doubt that it's worthwhile as the
> change isn't really fundamental and issuing one extra QMP call isn't as
> problematic as other cases, e.g probing of CPU features which results in
> a QMP call per feature when starting a VM.
>
> Currently libvirt issues 50 + 5 QMP commands(kvm, and non-kvm) for
> probing capabilities.
>
>> I'm not trying to talk you into this solution.  We're just exploring the
>> solution space together, and with an open mind.
>
> The idea of unconditionally trying a newer approach is a good one to
> hold onto when we'll need it in the future!

Only where the failure modes are simple enough to make misinterpretation
basically impossible.



  reply	other threads:[~2021-10-09  8:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15 19:24 [PATCH RFC 0/5] Subject: [PATCH RFC 0/5] qapi: Add feature flags to enum members Markus Armbruster
2021-09-15 19:24 ` [PATCH RFC 1/5] qapi: Enable enum member introspection to show more than name Markus Armbruster
2021-09-17 13:56   ` Eric Blake
2021-09-20  8:57     ` Markus Armbruster
2021-09-17 14:49   ` Peter Krempa
2021-09-20  9:08     ` Markus Armbruster
2021-09-20  9:57       ` Peter Krempa
2021-10-09  8:08         ` Markus Armbruster [this message]
2021-09-15 19:24 ` [PATCH RFC 2/5] qapi: Add feature flags to enum members Markus Armbruster
2021-09-17 14:41   ` Eric Blake
2021-09-17 14:53   ` Peter Krempa
2021-09-15 19:24 ` [PATCH RFC 3/5] qapi: Move compat policy from QObject to generic visitor Markus Armbruster
2021-09-17 14:45   ` Eric Blake
2021-09-15 19:24 ` [PATCH RFC 4/5] qapi: Implement deprecated-input={reject, crash} for enum values Markus Armbruster
2021-09-15 19:24 ` [PATCH RFC 5/5] block: Deprecate transaction type drive-backup Markus Armbruster
2021-09-16  7:18 ` [PATCH RFC 0/5] Subject: [PATCH RFC 0/5] qapi: Add feature flags to enum members Vladimir Sementsov-Ogievskiy
2021-09-16 12:57   ` Markus Armbruster
2021-09-16 13:28     ` Vladimir Sementsov-Ogievskiy
2021-09-16 14:12       ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r1cu39iv.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=libguestfs@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.