]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/extra/0004-qmp-fix-object-add-assert-without-props
qemu2.7 : qmp-fix-object-add-assert-without-props
[pve-qemu-kvm.git] / debian / patches / extra / 0004-qmp-fix-object-add-assert-without-props
CommitLineData
907d00e2
AD
1From d803b04e8203f48901186a27ab688326aa5569ec Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
3Date: Fri, 23 Sep 2016 00:39:25 +0400
4Subject: [PATCH 1/4] qmp: fix object-add assert() without props
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Since commit ad739706bbadee49, user_creatable_add_type() expects to be
10given a qdict. However, if object-add is called without props, you reach
11the assert: "qemu/qom/object_interfaces.c:115: user_creatable_add_type:
12Assertion `qdict' failed.", because the qdict isn't created in this
13case (it's optional).
14
15Furthermore, qmp_input_visitor_new() is not meant to be called without a
16dict, and a further commit will assert in this situation.
17
18If none given, create an empty qdict in qmp to avoid the
19user_creatable_add_type() assert(qdict).
20
21Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
22Reviewed-by: Eric Blake <eblake@redhat.com>
23Message-Id: <20160922203927.28241-2-marcandre.lureau@redhat.com>
24Tested-by: Xiao Long Jiang <zxiaol@linux.vnet.ibm.com>
25Reviewed-by: Markus Armbruster <armbru@redhat.com>
26Signed-off-by: Markus Armbruster <armbru@redhat.com>
27---
28 qmp.c | 8 ++++++--
29 1 file changed, 6 insertions(+), 2 deletions(-)
30
31diff --git a/qmp.c b/qmp.c
32index b6d531e..c485abe 100644
33--- a/qmp.c
34+++ b/qmp.c
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)
38 {
39- const QDict *pdict = NULL;
40+ QDict *pdict;
41 Visitor *v;
42 Object *obj;
43
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");
46 return;
47 }
48+ QINCREF(pdict);
49+ } else {
50+ pdict = qdict_new();
51 }
52
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);
56 visit_free(v);
57 if (obj) {
58 object_unref(obj);
59 }
60+ QDECREF(pdict);
61 }
62
63 void qmp_object_del(const char *id, Error **errp)
64--
652.1.4
66