1 From d803b04e8203f48901186a27ab688326aa5569ec Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
3 Date: Fri, 23 Sep 2016 00:39:25 +0400
4 Subject: [PATCH 1/4] qmp: fix object-add assert() without props
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Since commit ad739706bbadee49, user_creatable_add_type() expects to be
10 given a qdict. However, if object-add is called without props, you reach
11 the assert: "qemu/qom/object_interfaces.c:115: user_creatable_add_type:
12 Assertion `qdict' failed.", because the qdict isn't created in this
15 Furthermore, qmp_input_visitor_new() is not meant to be called without a
16 dict, and a further commit will assert in this situation.
18 If none given, create an empty qdict in qmp to avoid the
19 user_creatable_add_type() assert(qdict).
21 Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
22 Reviewed-by: Eric Blake <eblake@redhat.com>
23 Message-Id: <20160922203927.28241-2-marcandre.lureau@redhat.com>
24 Tested-by: Xiao Long Jiang <zxiaol@linux.vnet.ibm.com>
25 Reviewed-by: Markus Armbruster <armbru@redhat.com>
26 Signed-off-by: Markus Armbruster <armbru@redhat.com>
29 1 file changed, 6 insertions(+), 2 deletions(-)
31 diff --git a/qmp.c b/qmp.c
32 index b6d531e..c485abe 100644
35 @@ -654,7 +654,7 @@ void qmp_add_client(const char *protocol, const char *fdname,
36 void qmp_object_add(const char *type, const char *id,
37 bool has_props, QObject *props, Error **errp)
39 - const QDict *pdict = NULL;
44 @@ -664,14 +664,18 @@ void qmp_object_add(const char *type, const char *id,
45 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
50 + pdict = qdict_new();
53 - v = qmp_input_visitor_new(props, true);
54 + v = qmp_input_visitor_new(QOBJECT(pdict), true);
55 obj = user_creatable_add_type(type, id, pdict, v, errp);
63 void qmp_object_del(const char *id, Error **errp)