Skip to content

Commit

Permalink
qmp: Fix device-list-properties not to crash for abstract device
Browse files Browse the repository at this point in the history
Broken in commit f4eb32b "qmp: show QOM properties in
device-list-properties", v2.1.

Cc: qemu-stable@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Message-Id: <1443689999-12182-9-git-send-email-armbru@redhat.com>
  • Loading branch information
Markus Armbruster committed Oct 9, 2015
1 parent 2d1abb8 commit edb1523
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
6 changes: 6 additions & 0 deletions qmp.c
Expand Up @@ -515,6 +515,12 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
return NULL;
}

if (object_class_is_abstract(klass)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "name",
"non-abstract device type");
return NULL;
}

obj = object_new(typename);

QTAILQ_FOREACH(prop, &obj->properties, node) {
Expand Down
15 changes: 4 additions & 11 deletions tests/device-introspect-test.c
Expand Up @@ -45,17 +45,10 @@ static void test_one_device(const char *type)
QDict *resp;
char *help, *qom_tree;

/*
* Skip this part for the abstract device test case, because
* device-list-properties crashes for such devices.
* FIXME fix it not to crash
*/
if (strcmp(type, "device")) {
resp = qmp("{'execute': 'device-list-properties',"
" 'arguments': {'typename': %s}}",
type);
QDECREF(resp);
}
resp = qmp("{'execute': 'device-list-properties',"
" 'arguments': {'typename': %s}}",
type);
QDECREF(resp);

help = hmp("device_add \"%s,help\"", type);
g_free(help);
Expand Down

0 comments on commit edb1523

Please sign in to comment.