qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 3/6] QMP: Reserve namespace for complex object classes
Date: Fri, 02 Sep 2011 13:02:04 -0500	[thread overview]
Message-ID: <4E611A1C.4070100@us.ibm.com> (raw)
In-Reply-To: <20110902142302.506bf6d0@doriath>

On 09/02/2011 12:23 PM, Luiz Capitulino wrote:
> On Fri, 26 Aug 2011 16:48:13 +0200
> Jan Kiszka<jan.kiszka@siemens.com>  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<lcapitulino@redhat.com>
>> Signed-off-by: Jan Kiszka<jan.kiszka@siemens.com>
>> ---
>>   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
>

  parent reply	other threads:[~2011-09-02 18:02 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26 14:48 [Qemu-devel] [PATCH 0/6] Device state visualization reloaded Jan Kiszka
2011-08-26 14:48 ` [Qemu-devel] [PATCH 1/6] monitor: return length of printed string via monitor_[v]printf Jan Kiszka
2011-08-26 14:48 ` [Qemu-devel] [PATCH 2/6] Add base64 encoder/decoder Jan Kiszka
2011-08-26 15:21   ` Peter Maydell
2011-08-26 15:23     ` Jan Kiszka
2011-08-26 15:47       ` Jan Kiszka
2011-08-26 18:02         ` Jan Kiszka
2011-09-02 17:22           ` Luiz Capitulino
2011-09-05 13:55         ` [Qemu-devel] required glib version? " Gerd Hoffmann
2011-08-26 14:48 ` [Qemu-devel] [PATCH 3/6] QMP: Reserve namespace for complex object classes Jan Kiszka
2011-09-02 17:23   ` Luiz Capitulino
2011-09-02 17:47     ` Jan Kiszka
2011-09-02 18:02     ` Anthony Liguori [this message]
2011-08-26 14:48 ` [Qemu-devel] [PATCH 4/6] QMP: Add QBuffer Jan Kiszka
2011-08-26 18:23   ` [Qemu-devel] [PATCH v2 " Jan Kiszka
2011-08-26 14:48 ` [Qemu-devel] [PATCH 5/6] monitor: Add basic device state visualization Jan Kiszka
2011-08-26 14:48 ` [Qemu-devel] [PATCH 6/6] qdev: Generate IDs for anonymous devices Jan Kiszka
2011-08-29 19:23   ` Anthony Liguori
2011-08-29 20:56     ` Jan Kiszka
2011-08-29 21:19       ` Anthony Liguori
2011-08-31 18:31         ` Jan Kiszka
2011-09-07  9:50           ` Gleb Natapov
2011-09-07 10:27             ` Jan Kiszka
2011-09-07 10:34               ` Gleb Natapov
2011-09-07 10:58                 ` Jan Kiszka
2011-08-29 19:22 ` [Qemu-devel] [PATCH 0/6] Device state visualization reloaded Anthony Liguori
2011-08-29 20:54   ` Jan Kiszka
2011-09-02 17:27 ` Luiz Capitulino
2011-09-06 14:48 ` Michael S. Tsirkin
2011-09-06 15:45   ` Jan Kiszka
2011-09-06 15:51     ` Anthony Liguori
2011-09-06 16:05       ` Jan Kiszka
2011-09-06 16:08         ` Anthony Liguori
2011-09-06 16:33           ` Jan Kiszka
2011-09-06 16:09       ` Michael S. Tsirkin
2011-09-06 16:28         ` Anthony Liguori
2011-09-06 17:05           ` Michael S. Tsirkin
2011-09-07  9:37             ` Kevin Wolf
2011-09-07 13:06               ` Michael S. Tsirkin
2011-09-07 13:13                 ` Jan Kiszka
2011-09-07 13:17                   ` Michael S. Tsirkin
2011-09-07 13:23                     ` Anthony Liguori
2011-09-07 13:29                       ` Jan Kiszka
2011-09-07 13:33                       ` Michael S. Tsirkin
2011-09-06 16:29         ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E611A1C.4070100@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=jan.kiszka@siemens.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).