From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXBll-0006HV-Cd for qemu-devel@nongnu.org; Thu, 25 Sep 2014 12:19:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXBlf-00031W-8Y for qemu-devel@nongnu.org; Thu, 25 Sep 2014 12:19:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40866) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXBle-00030j-Qq for qemu-devel@nongnu.org; Thu, 25 Sep 2014 12:19:43 -0400 From: Markus Armbruster References: <1411165504-18198-1-git-send-email-eblake@redhat.com> <1411165504-18198-13-git-send-email-eblake@redhat.com> <87h9zw9mqy.fsf@blackfin.pond.sub.org> <87y4t85dlc.fsf@blackfin.pond.sub.org> <54241FFB.2000104@redhat.com> Date: Thu, 25 Sep 2014 18:19:32 +0200 In-Reply-To: <54241FFB.2000104@redhat.com> (Eric Blake's message of "Thu, 25 Sep 2014 08:00:27 -0600") Message-ID: <87fvffwu3v.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 12/19] qapi: Add some type check tests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Luiz Capitulino , Fam Zheng , qemu-devel@nongnu.org, wenchaoqemu@gmail.com Eric Blake writes: > On 09/25/2014 02:06 AM, Markus Armbruster wrote: > >>> >>> The QAPI schema's 'returns' becomes "return" on the wire. We suck. >>> >>> qmp-spec.txt is *wrong*! We actually use json-array in addition to >>> json-object. >> >> Actually, we use json-int and json-str as well: >> query-migrate-cache-size, ringbuf-read, human-monitor-command. >> >>> Similar argument on types wanted as for 'data' / "arguments" above. I >>> think we should permit exactly the same QAPI types, plus lists. >> >> The similarity to 'data' just isn't there. Separate analysis needed. > > Correct. 'data' and 'returns' are different beasts when it comes to > acceptable types. And different still from the acceptable type of each > member of a dictionary. But my check_type function in 13/19 is flexible > enough to cover all the cases. > >> >> Any QAPI types that don't make sense, other than list with length != 1? > > Return of an anon union isn't used yet, but _might_ make sense (as the > only feasible way of changing existing commands that return an array or > primitive extensible to instead return a dict) - Good point. > except that back-compat > demands that we can't return a dict in place of a primitive unless the > arguments of the command are also enhanced (that is, older callers are > not expecting a dict, so we can't return a dict unless the caller > witnesses they are new enough by explicitly asking for a dict return). I think we can keep things simple for now and reject anonymous unions. We can always relax the check when we run into a use. You're giving the generator a good shove from "god knows what it accepts, but as long as you stick to stuff that is being used already, probably generates something that works" towards "if it accepts it, it works". I like it.