From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCyWl-0006cj-3q for qemu-devel@nongnu.org; Mon, 10 Feb 2014 16:36:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCyWe-0000qx-EK for qemu-devel@nongnu.org; Mon, 10 Feb 2014 16:36:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCyWe-0000qo-5M for qemu-devel@nongnu.org; Mon, 10 Feb 2014 16:36:24 -0500 Message-ID: <52F94654.8080401@redhat.com> Date: Mon, 10 Feb 2014 14:36:20 -0700 From: Eric Blake MIME-Version: 1.0 References: <20140210161600.4f9b34a1@redhat.com> In-Reply-To: <20140210161600.4f9b34a1@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="W5DuORTCdJheTO9fqqqrUvrX45dX7fJ9H" Subject: Re: [Qemu-devel] [PATCH v3] qmp: expose list of supported character device backends List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino , Martin Kletzander Cc: qemu-devel@nongnu.org, Anthony Liguori , Markus Armbruster This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --W5DuORTCdJheTO9fqqqrUvrX45dX7fJ9H Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/10/2014 02:16 PM, Luiz Capitulino wrote: > On Sat, 1 Feb 2014 12:52:42 +0100 > Martin Kletzander wrote: >=20 >> Introduce 'query-chardev-backends' QMP command which lists all >> supported character device backends. >> >> Signed-off-by: Martin Kletzander >> --- >> +## >> +{ 'type': 'ChardevBackendInfo', 'data': {'name': 'str'} } >=20 > We already have ChardevBackend, it's an union though. I'm wondering if > you could change it to an enum and use it instead of plain 'str'? Hmm, right now, the ChardevBackend union pre-dates when we added flat unions. For flat unions, we can set a discriminator to be an enum type [1], at which point the code generator then validates that we cover all values of the enum in branches of the union; maybe it's worth retro-fitting simple unions to also take advantage of the additional coverage of the discriminator being an enum. That is, right now, we have: { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', 'serial' : 'ChardevHostdev', and we also document in qapi-code-gen.txt that when using 'discriminator', you either have to have a base class (and the discriminator is a string-typed member of that base class), or the discriminator is {} because it is an anonymous union. But I'm asking about yet another situation, of having a typed discriminator with no change to the wire format (no base class), something like: { 'enum': 'ChardevBackendTypes', [ 'file', 'serial', ... ] } { 'union': 'ChardevBackend', 'discriminator': 'ChardevBackendTypes', 'data': { 'file': 'ChardevFile', ... The benefit of such a plan is that we then have an introspectible enum of all possible backends known at compile time (ChardevBackendTypes), and the new addition in this patch becomes: { 'type': 'ChardevBackendInfo', 'data': {'name', 'ChardevBackendTypes' } } rather than raw 'str', while still allowing potential future additions of additional backend info. Note that there would still be a difference between ChardevBackendTypes (an enum of all possible known types at compile time) vs. query-chardev-backends (a runtime list of the possible types that can be used for this particular machine, even if it is a subset of all possible ChardevBackendTypes). [1] actually, did those patches ever get applied, and we just missed documenting it in qapi-code-gen.txt, or are they still pending review? >=20 >> + >> +## >> +# @query-chardev-backends: >> +# >> +# Returns information about character device backends. >=20 > Actually, it returns information about registered backends (registratio= n > is done by register_char_driver_qapi(). So, I think it's good thing to > mention that this list is about available backends. Again, it sounds like you want to emphasize an enum of all possible types (compile time, learned via introspection, whenever we get that) vs. registered backends (possibly a subset based on what libraries were used in building this qemu binary, and learned via the new QMP command). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --W5DuORTCdJheTO9fqqqrUvrX45dX7fJ9H Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJS+UZUAAoJEKeha0olJ0Nq7bEIAICMwokR0XFbFLXTU1S7yUQ4 ZvAf08zOnN97dxvkN3RzewzuAedsoq3kRFmgHS6wbo3BOPG4cHSxQP9Q9yy6/Kkh z+2YWUSSa1BOf5nGm0OY96f+zmPe6YCHThY+2JzBYSmDb7S4BVRwl5MkoqL+09eu UqGnrJyWS6FwqVLXJWL/OxvL/UoGkFHxeDr5ZgrLx5gnllje1gy98abwDSWI8JFv ztDlmrE1oF7l5wt9HSds2f7/o+pdoAalrTyQv6MujxU0SA0nYFWp9xEi0qQqHGQP yucxn1XnAZZ1OtACK3c1AsggKT8uvLFwourpiJkn8zJI3WVu6tDoIus/iZjFgUQ= =iZa5 -----END PGP SIGNATURE----- --W5DuORTCdJheTO9fqqqrUvrX45dX7fJ9H--