From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PULL v2 01/11] qmp: fix object-add assert() without props
Date: Fri, 7 Oct 2016 20:16:12 +0200 [thread overview]
Message-ID: <1475864182-16550-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1475864182-16550-1-git-send-email-armbru@redhat.com>
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Since commit ad739706bbadee49, user_creatable_add_type() expects to be
given a qdict. However, if object-add is called without props, you reach
the assert: "qemu/qom/object_interfaces.c:115: user_creatable_add_type:
Assertion `qdict' failed.", because the qdict isn't created in this
case (it's optional).
Furthermore, qmp_input_visitor_new() is not meant to be called without a
dict, and a further commit will assert in this situation.
If none given, create an empty qdict in qmp to avoid the
user_creatable_add_type() assert(qdict).
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20160922203927.28241-2-marcandre.lureau@redhat.com>
Tested-by: Xiao Long Jiang <zxiaol@linux.vnet.ibm.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
qmp.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/qmp.c b/qmp.c
index 621f6ae..b3ba9ef 100644
--- a/qmp.c
+++ b/qmp.c
@@ -660,7 +660,7 @@ void qmp_add_client(const char *protocol, const char *fdname,
void qmp_object_add(const char *type, const char *id,
bool has_props, QObject *props, Error **errp)
{
- const QDict *pdict = NULL;
+ QDict *pdict;
Visitor *v;
Object *obj;
@@ -670,14 +670,18 @@ void qmp_object_add(const char *type, const char *id,
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
return;
}
+ QINCREF(pdict);
+ } else {
+ pdict = qdict_new();
}
- v = qmp_input_visitor_new(props, true);
+ v = qmp_input_visitor_new(QOBJECT(pdict), true);
obj = user_creatable_add_type(type, id, pdict, v, errp);
visit_free(v);
if (obj) {
object_unref(obj);
}
+ QDECREF(pdict);
}
void qmp_object_del(const char *id, Error **errp)
--
2.5.5
next prev parent reply other threads:[~2016-10-07 18:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-07 18:16 [Qemu-devel] [PULL v2 00/11] QAPI patches for 2016-10-07 Markus Armbruster
2016-10-07 18:16 ` Markus Armbruster [this message]
2016-10-07 18:16 ` [Qemu-devel] [PULL v2 02/11] qapi: Fix crash when 'any' or 'null' parameter is missing Markus Armbruster
2016-10-07 18:16 ` [Qemu-devel] [PULL v2 03/11] tests/test-qmp-input-strict: Cover missing struct members Markus Armbruster
2016-10-07 18:16 ` [Qemu-devel] [PULL v2 04/11] qapi: add assert about root value Markus Armbruster
2016-10-07 18:16 ` [Qemu-devel] [PULL v2 05/11] qapi: assert list entry has a value Markus Armbruster
2016-10-07 18:16 ` [Qemu-devel] [PULL v2 06/11] qapi: return a 'missing parameter' error Markus Armbruster
2016-10-07 18:16 ` [Qemu-devel] [PULL v2 07/11] MAINTAINERS: Pass the HMP staff from Luiz to David Markus Armbruster
2016-10-07 18:16 ` [Qemu-devel] [PULL v2 08/11] MAINTAINERS: Pass the QObject staff from Luiz to Markus Markus Armbruster
2016-10-07 18:16 ` [Qemu-devel] [PULL v2 09/11] qmp: Disable query-cpu-* commands when they're unavailable Markus Armbruster
2016-10-07 18:16 ` [Qemu-devel] [PULL v2 10/11] docs: Belatedly update for move of qmp-commands.txt Markus Armbruster
2016-10-07 18:16 ` [Qemu-devel] [PULL v2 11/11] docs: Belatedly update for move of QMP/* to docs/ Markus Armbruster
2016-10-10 11:50 ` [Qemu-devel] [PULL v2 00/11] QAPI patches for 2016-10-07 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1475864182-16550-2-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).