diff mbox

[3/7] QMP: Assure that returned data is a QDict

Message ID 1261149905-7622-4-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino Dec. 18, 2009, 3:25 p.m. UTC
This is for debug purposes only.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Nathan Baum Dec. 21, 2009, 7:21 p.m. UTC | #1
On Fri, 2009-12-18 at 13:25 -0200, Luiz Capitulino wrote:
> This is for debug purposes only.

This breaks quite a lot of commands where the returned data is a QList,
e.g. query-commands, query-mice, query-cpus. Is the assert wrong, or are
such commands meant to be returning a QDict?

> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  monitor.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index d238660..8ef1582 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -283,6 +283,7 @@ static void monitor_protocol_emitter(Monitor *mon, QObject *data)
>      if (!monitor_has_error(mon)) {
>          /* success response */
>          if (data) {
> +            assert(qobject_type(data) == QTYPE_QDICT);
>              qobject_incref(data);
>              qdict_put_obj(qmp, "return", data);
>          } else {
Luiz Capitulino Dec. 22, 2009, 3:06 a.m. UTC | #2
On Mon, 21 Dec 2009 19:21:18 +0000
Nathan Baum <nathan@parenthephobia.org.uk> wrote:

> On Fri, 2009-12-18 at 13:25 -0200, Luiz Capitulino wrote:
> > This is for debug purposes only.
> 
> This breaks quite a lot of commands where the returned data is a QList,
> e.g. query-commands, query-mice, query-cpus. Is the assert wrong, or are
> such commands meant to be returning a QDict?

 The assert is wrong, as we've defined that returning a QList of
QDicts is ok.

 We could check for a QList too and check its contents but I think that
only dropping the assert is ok for now.

 Will submit a patch and thanks for testing QMP.
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index d238660..8ef1582 100644
--- a/monitor.c
+++ b/monitor.c
@@ -283,6 +283,7 @@  static void monitor_protocol_emitter(Monitor *mon, QObject *data)
     if (!monitor_has_error(mon)) {
         /* success response */
         if (data) {
+            assert(qobject_type(data) == QTYPE_QDICT);
             qobject_incref(data);
             qdict_put_obj(qmp, "return", data);
         } else {