From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzY49-0001KD-Ho for qemu-devel@nongnu.org; Fri, 02 Sep 2011 14:02:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QzY47-00076H-Qd for qemu-devel@nongnu.org; Fri, 02 Sep 2011 14:02:09 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:51119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzY47-000765-O1 for qemu-devel@nongnu.org; Fri, 02 Sep 2011 14:02:07 -0400 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by e7.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p82Gfxud031770 for ; Fri, 2 Sep 2011 12:41:59 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p82I26P4247692 for ; Fri, 2 Sep 2011 14:02:06 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p82E1rfP021143 for ; Fri, 2 Sep 2011 11:01:53 -0300 Message-ID: <4E611A1C.4070100@us.ibm.com> Date: Fri, 02 Sep 2011 13:02:04 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <20110902142302.506bf6d0@doriath> In-Reply-To: <20110902142302.506bf6d0@doriath> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/6] QMP: Reserve namespace for complex object classes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: Jan Kiszka , qemu-devel On 09/02/2011 12:23 PM, Luiz Capitulino wrote: > On Fri, 26 Aug 2011 16:48:13 +0200 > Jan Kiszka wrote: > >> This reserves JSON objects that contain the key '__class__' for QMP-specific >> complex objects. First user will be the buffer class. BTW, we need to teach QAPI how handle these types. QAPI already has the information about the class that it's working with. I think that means you can probably do something like this (completely untested): diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index 4419a31..9895792 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -105,6 +105,8 @@ static void qmp_output_start_struct(Visitor *v, void **obj, qmp_output_add(qov, name, dict); qmp_output_push(qov, dict); + + visit_type_str(v, "__class__", kind, errp); } static void qmp_output_end_struct(Visitor *v, Error **errp) That will add class information for every type that gets written by QAPI. Likewise: diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c index fcf8bf9..77e7ab4 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -86,6 +86,7 @@ static void qmp_input_start_struct(Visitor *v, void **obj, con { QmpInputVisitor *qiv = to_qiv(v); const QObject *qobj = qmp_input_get_object(qiv, name); + char *type; if (!qobj || qobject_type(qobj) != QTYPE_QDICT) { error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", @@ -101,6 +102,15 @@ static void qmp_input_start_struct(Visitor *v, void **obj, if (obj) { *obj = g_malloc0(size); } + + visit_type_str(v, &type, "__class__", errp); + if (error_is_set(errp)) { + return; + } Will do type checking on incoming data. Maybe we should relax that and only do the type checking if __class__ is specified.. Regards, Anthony Liguori >> >> CC: Luiz Capitulino >> Signed-off-by: Jan Kiszka >> --- >> QMP/qmp-spec.txt | 16 +++++++++++++--- >> 1 files changed, 13 insertions(+), 3 deletions(-) >> >> diff --git a/QMP/qmp-spec.txt b/QMP/qmp-spec.txt >> index 9d30a8c..fa1dd62 100644 >> --- a/QMP/qmp-spec.txt >> +++ b/QMP/qmp-spec.txt >> @@ -146,6 +146,15 @@ The format is: >> For a listing of supported asynchronous events, please, refer to the >> qmp-events.txt file. >> >> +2.6 Complex object classes >> +-------------------------- >> + >> +JSON objects that contain the key-value pair '"__class__": json-string' are >> +reserved for QMP-specific complex object classes that. QMP specifies which > > Can I just drop the period or is it misplaced? > >> +further keys each of these objects include and how they are encoded. >> + >> +So far, no complex object class is specified. >> + >> 3. QMP Examples >> =============== >> >> @@ -229,9 +238,10 @@ avoid modifying QMP. Both upstream and downstream need to take care to >> preserve long-term compatibility and interoperability. >> >> To help with that, QMP reserves JSON object member names beginning with >> -'__' (double underscore) for downstream use ("downstream names"). This >> -means upstream will never use any downstream names for its commands, >> -arguments, errors, asynchronous events, and so forth. >> +'__' (double underscore) for downstream use ("downstream names"). Downstream >> +names MUST NOT end with '__' as this pattern is reserved for QMP-defined JSON >> +object classes. Upstream will never use any downstream names for its >> +commands, arguments, errors, asynchronous events, and so forth. >> >> Any new names downstream wishes to add must begin with '__'. To >> ensure compatibility with other downstreams, it is strongly >