]> git.proxmox.com Git - pve-qemu-kvm.git/blob - 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
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
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
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
13 case (it's optional).
14
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.
17
18 If none given, create an empty qdict in qmp to avoid the
19 user_creatable_add_type() assert(qdict).
20
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>
27 ---
28 qmp.c | 8 ++++++--
29 1 file changed, 6 insertions(+), 2 deletions(-)
30
31 diff --git a/qmp.c b/qmp.c
32 index 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 --
65 2.1.4
66