From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu5Kd-00073c-8G for qemu-devel@nongnu.org; Tue, 02 Jul 2013 14:29:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uu5Ka-00058h-Kp for qemu-devel@nongnu.org; Tue, 02 Jul 2013 14:29:39 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:58858) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu5Ka-00058c-GL for qemu-devel@nongnu.org; Tue, 02 Jul 2013 14:29:36 -0400 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 Jul 2013 19:29:36 +0100 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 790CF38C8045 for ; Tue, 2 Jul 2013 14:29:33 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r62ISYUM182122 for ; Tue, 2 Jul 2013 14:28:34 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r62ISWSt021137 for ; Tue, 2 Jul 2013 15:28:33 -0300 From: Anthony Liguori In-Reply-To: <51D309AB.2040403@redhat.com> References: <1371644677-11041-1-git-send-email-akong@redhat.com> <878v1pqak4.fsf@codemonkey.ws> <51D2F1B3.1080903@redhat.com> <87a9m4j3i7.fsf@codemonkey.ws> <51D309AB.2040403@redhat.com> Date: Tue, 02 Jul 2013 13:28:28 -0500 Message-ID: <87a9m4olyr.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH] full introspection support for QMP List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: armbru@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, qiaonuohan@cn.fujitsu.com, pbonzini@redhat.com, Amos Kong Eric Blake writes: > On 07/02/2013 11:06 AM, Anthony Liguori wrote: >>> Because qapi-schema.json requires further parsing. For example, how is >>> a client supposed to know that '*foo':'int' means that there is an >>> argument named 'foo' but it is optional? The rule of thumb with QMP is >>> that if you have to post-process JSON output, then the JSON was not >>> designed correctly. >> >> Then we should fix qapi-schema.json. >> > >> One reasonable compromise would be: >> >> { "command": "foo", "arguments": { "name": "str", "id": "int" }, >> "optional": { "bar": "bool" } } >> >> Then libvirt only has to test 'does command["optional"] contain key >> "bar"' to test for an optional parameter. > > Yes, that might be a reasonable compromise - at least that way, the > optional parameter names are listed directly, and libvirt doesn't have > to probe every single parameter to name to see which begin with '*'. > >> >> Although to be honest, '*bar' in command['arguments'] is reasonable too >> IMHO. > > It may be reasonable, but it forces every QMP client to reimplement the > post-processing step, rather than presenting the parameter names already > in isolation. > > Food for thought - suppose we wanted to start expressing in the .json > file what the default value is for any parameter that is listed as > optional? What representation is most compact for that purpose, while > still being valid JSON and not requiring QMP clients to reimplement > post-processing? We won't do that. It would be way too hard to retrofit it for very little value. Regards, Anthony Liguori > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org