Skip to content
Snippets Groups Projects
Commit e64c75a9 authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Markus Armbruster
Browse files

qmp: fix object-add assert() without props


Since commit ad739706, 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: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Message-Id: <20160922203927.28241-2-marcandre.lureau@redhat.com>
Tested-by: default avatarXiao Long Jiang <zxiaol@linux.vnet.ibm.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent a65b6f27
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment