From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQz8h-0006Tx-75 for qemu-devel@nongnu.org; Wed, 03 Feb 2016 10:14:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQz8e-0001MN-02 for qemu-devel@nongnu.org; Wed, 03 Feb 2016 10:14:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQz8d-0001MJ-O8 for qemu-devel@nongnu.org; Wed, 03 Feb 2016 10:14:35 -0500 References: <1453963872-13549-1-git-send-email-vsementsov@virtuozzo.com> <1453963872-13549-3-git-send-email-vsementsov@virtuozzo.com> <56B129CC.4010005@redhat.com> <56B1EBCA.30201@virtuozzo.com> From: Eric Blake Message-ID: <56B2195A.4040503@redhat.com> Date: Wed, 3 Feb 2016 08:14:34 -0700 MIME-Version: 1.0 In-Reply-To: <56B1EBCA.30201@virtuozzo.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uqrCxCRqiIC1wplmEotTEFq2I7qMfWljn" Subject: Re: [Qemu-devel] [PATCH 2/3] pcdimm: add 'type' field to PCDIMMDeviceInfo List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org Cc: Xiao Guangrong , "Michael S. Tsirkin" , Markus Armbruster , Stefan Hajnoczi , Igor Mammedov , "Denis V. Lunev" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --uqrCxCRqiIC1wplmEotTEFq2I7qMfWljn Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/03/2016 05:00 AM, Vladimir Sementsov-Ogievskiy wrote: >>> +# @type: device type: 'pc-dimm' or 'nvdimm' (since 2.6) >>> +# >>> # Since: 2.1 >>> ## >>> { 'struct': 'PCDIMMDeviceInfo', >>> @@ -3934,7 +3936,8 @@ >>> 'node': 'int', >>> 'memdev': 'str', >>> 'hotplugged': 'bool', >>> - 'hotpluggable': 'bool' >>> + 'hotpluggable': 'bool', >>> + 'type': 'str' >> No. Since it is a finite set of values (just two possible), you should= >> be using an enum here rather than open-coded 'str'. Something like: >> >> { 'enum': 'DIMMType', 'data': [ 'pc-dimm', 'nvdimm' ] } >> >=20 > Are you sure? This is only output Info, so user will never "set" this > field. Also, qemu type system (as I understand) is based on string > names. object_dynamic_cast and other functions uses "const char > *typename". This enum will be out of qemu type system and we will have > to sync it.. Is there already some practice of translating string > typenames to enum values? Yes, exposing a finite set of strings as an enum is ideal for the user interface, even if we carry string values instead of enum values in other places in the code. QAPI already includes convenience methods for translating between strings and enum values (EnumName_lookup[] to go from int to string, and qapi_enum_parse() to reverse from string back to enum). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --uqrCxCRqiIC1wplmEotTEFq2I7qMfWljn Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWshlaAAoJEKeha0olJ0NquGgIAK8RCLvsB54KvyvCtlFOIfr9 ORs1wHrScOIRyK+z+WapJ+hSd5cCqXqFD/l3vHLRb9+5U5gzWuC9bFFZnWU9+6Zs Cx1HAlzHLodJ9Fq910mrnPFvItuJhF0Z3hWPcFHVPyfn61xnV7orErN9LXmFBToS RasvlDG0V+4HoynPV/C5wt18MK7pu/lP7Y/E4pIILnlwqRpX1FZWqDLyN4tGzda7 bK5rrku5ufRRtCSHTlFODu1gbbkq4bBngnn7+SejF5yeGhY9sdkYYIjOZppn+4yt D3ShqBLFr0KeNBnKxrNLtCpUOnqwYLX4HsZcQTnnrFjk15m3r5x3QWBstue0m2w= =w6yg -----END PGP SIGNATURE----- --uqrCxCRqiIC1wplmEotTEFq2I7qMfWljn--