Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/qmp-unstable/tags/for-upstream'…
Browse files Browse the repository at this point in the history
… into staging

QMP pull request

# gpg: Signature made Mon May 11 14:15:19 2015 BST using RSA key ID E24ED5A7
# gpg: Good signature from "Luiz Capitulino <lcapitulino@gmail.com>"

* remotes/qmp-unstable/tags/for-upstream:
  scripts: qmp-shell: Add verbose flag
  scripts: qmp-shell: add transaction subshell
  scripts: qmp-shell: Expand support for QMP expressions
  scripts: qmp-shell: refactor helpers
  MAINTAINERS: New maintainer for QMP and QAPI
  json-parser: Accept 'null' in QMP
  qobject: Add a special null QObject
  qobject: Clean up around qtype_code
  QJSON: Use OBJECT_CHECK

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed May 12, 2015
2 parents 0403b0f + 1ceca07 commit 704eb1c
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 56 deletions.
18 changes: 9 additions & 9 deletions MAINTAINERS
Expand Up @@ -926,20 +926,19 @@ K: srat|SRAT
T: git git://github.com/ehabkost/qemu.git numa

QAPI
M: Luiz Capitulino <lcapitulino@redhat.com>
M: Markus Armbruster <armbru@redhat.com>
M: Michael Roth <mdroth@linux.vnet.ibm.com>
S: Maintained
S: Supported
F: qapi/
F: tests/qapi-schema/
T: git git://repo.or.cz/qemu/qmp-unstable.git queue/qmp
T: git git://repo.or.cz/qemu/armbru.git qapi-next

QAPI Schema
M: Eric Blake <eblake@redhat.com>
M: Luiz Capitulino <lcapitulino@redhat.com>
M: Markus Armbruster <armbru@redhat.com>
S: Supported
F: qapi-schema.json
T: git git://repo.or.cz/qemu/qmp-unstable.git queue/qmp
T: git git://repo.or.cz/qemu/armbru.git qapi-next

QObject
M: Luiz Capitulino <lcapitulino@redhat.com>
Expand All @@ -964,13 +963,14 @@ X: qom/cpu.c
F: tests/qom-test.c

QMP
M: Luiz Capitulino <lcapitulino@redhat.com>
S: Maintained
M: Markus Armbruster <armbru@redhat.com>
S: Supported
F: qmp.c
F: monitor.c
F: qmp-commands.hx
F: QMP/
T: git git://repo.or.cz/qemu/qmp-unstable.git queue/qmp
F: docs/qmp/
F: scripts/qmp/
T: git git://repo.or.cz/qemu/armbru.git qapi-next

SLIRP
M: Jan Kiszka <jan.kiszka@siemens.com>
Expand Down
3 changes: 0 additions & 3 deletions block/qapi.c
Expand Up @@ -523,9 +523,6 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
QDECREF(value);
break;
}
case QTYPE_NONE:
break;
case QTYPE_MAX:
default:
abort();
}
Expand Down
2 changes: 1 addition & 1 deletion include/hw/qdev-core.h
Expand Up @@ -226,7 +226,7 @@ struct Property {
PropertyInfo *info;
int offset;
uint8_t bitnr;
uint8_t qtype;
qtype_code qtype;
int64_t defval;
int arrayoffset;
PropertyInfo *arrayinfo;
Expand Down
13 changes: 11 additions & 2 deletions include/qapi/qmp/qobject.h
Expand Up @@ -3,7 +3,7 @@
*
* Based on ideas by Avi Kivity <avi@redhat.com>
*
* Copyright (C) 2009 Red Hat Inc.
* Copyright (C) 2009, 2015 Red Hat Inc.
*
* Authors:
* Luiz Capitulino <lcapitulino@redhat.com>
Expand Down Expand Up @@ -36,7 +36,8 @@
#include <assert.h>

typedef enum {
QTYPE_NONE,
QTYPE_NONE, /* sentinel value, no QObject has this type code */
QTYPE_QNULL,
QTYPE_QINT,
QTYPE_QSTRING,
QTYPE_QDICT,
Expand Down Expand Up @@ -110,4 +111,12 @@ static inline qtype_code qobject_type(const QObject *obj)
return obj->type->code;
}

extern QObject qnull_;

static inline QObject *qnull(void)
{
qobject_incref(&qnull_);
return &qnull_;
}

#endif /* QOBJECT_H */
10 changes: 5 additions & 5 deletions qjson.c
Expand Up @@ -24,6 +24,8 @@ struct QJSON {
bool omit_comma;
};

#define QJSON(obj) OBJECT_CHECK(QJSON, (obj), TYPE_QJSON)

static void json_emit_element(QJSON *json, const char *name)
{
/* Check whether we need to print a , before an element */
Expand Down Expand Up @@ -87,7 +89,7 @@ const char *qjson_get_str(QJSON *json)

QJSON *qjson_new(void)
{
QJSON *json = (QJSON *)object_new(TYPE_QJSON);
QJSON *json = QJSON(object_new(TYPE_QJSON));
return json;
}

Expand All @@ -98,18 +100,16 @@ void qjson_finish(QJSON *json)

static void qjson_initfn(Object *obj)
{
QJSON *json = (QJSON *)object_dynamic_cast(obj, TYPE_QJSON);
assert(json);
QJSON *json = QJSON(obj);

json->str = qstring_from_str("{ ");
json->omit_comma = true;
}

static void qjson_finalizefn(Object *obj)
{
QJSON *json = (QJSON *)object_dynamic_cast(obj, TYPE_QJSON);
QJSON *json = QJSON(obj);

assert(json);
qobject_decref(QOBJECT(json->str));
}

Expand Down
2 changes: 1 addition & 1 deletion qobject/Makefile.objs
@@ -1,3 +1,3 @@
util-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
util-obj-y = qnull.o qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
util-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
util-obj-y += qerror.o
2 changes: 2 additions & 0 deletions qobject/json-parser.c
Expand Up @@ -561,6 +561,8 @@ static QObject *parse_keyword(JSONParserContext *ctxt)
ret = QOBJECT(qbool_from_int(true));
} else if (token_is_keyword(token, "false")) {
ret = QOBJECT(qbool_from_int(false));
} else if (token_is_keyword(token, "null")) {
ret = qnull();
} else {
parse_error(ctxt, token, "invalid keyword `%s'", token_get_value(token));
goto out;
Expand Down
6 changes: 4 additions & 2 deletions qobject/qjson.c
Expand Up @@ -127,6 +127,9 @@ static void to_json_list_iter(QObject *obj, void *opaque)
static void to_json(const QObject *obj, QString *str, int pretty, int indent)
{
switch (qobject_type(obj)) {
case QTYPE_QNULL:
qstring_append(str, "null");
break;
case QTYPE_QINT: {
QInt *val = qobject_to_qint(obj);
char buffer[1024];
Expand Down Expand Up @@ -260,9 +263,8 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
}
case QTYPE_QERROR:
/* XXX: should QError be emitted? */
case QTYPE_NONE:
break;
case QTYPE_MAX:
default:
abort();
}
}
Expand Down
29 changes: 29 additions & 0 deletions qobject/qnull.c
@@ -0,0 +1,29 @@
/*
* QNull
*
* Copyright (C) 2015 Red Hat, Inc.
*
* Authors:
* Markus Armbruster <armbru@redhat.com>
*
* This work is licensed under the terms of the GNU LGPL, version 2.1
* or later. See the COPYING.LIB file in the top-level directory.
*/

#include "qemu-common.h"
#include "qapi/qmp/qobject.h"

static void qnull_destroy_obj(QObject *obj)
{
assert(0);
}

static const QType qnull_type = {
.code = QTYPE_QNULL,
.destroy = qnull_destroy_obj,
};

QObject qnull_ = {
.type = &qnull_type,
.refcnt = 1,
};

0 comments on commit 704eb1c

Please sign in to comment.