From 7d46a82fce8c9b85637401868cec90b5204c9a4f Mon Sep 17 00:00:00 2001 Message-Id: <7d46a82fce8c9b85637401868cec90b5204c9a4f.1444668695.git.jen@redhat.com> In-Reply-To: <860bcb286a4f0cfcc02e2d5c16c2c94f85fddf12.1444668695.git.jen@redhat.com> References: <860bcb286a4f0cfcc02e2d5c16c2c94f85fddf12.1444668695.git.jen@redhat.com> From: Markus Armbruster Date: Fri, 9 Oct 2015 14:37:36 -0500 Subject: [CHANGE 09/11] qmp: Fix device-list-properties not to crash for abstract device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: rhvirt-patches@redhat.com, jen@redhat.com RH-Author: Markus Armbruster Message-id: <1444401458-7995-8-git-send-email-armbru@redhat.com> Patchwork-id: 68112 O-Subject: [RHEV-7.2 qemu-kvm-rhev PATCH v2 7/9] qmp: Fix device-list-properties not to crash for abstract device Bugzilla: 1264347 RH-Acked-by: Igor Mammedov RH-Acked-by: Paolo Bonzini RH-Acked-by: Eduardo Habkost Broken in commit f4eb32b "qmp: show QOM properties in device-list-properties", v2.1. Cc: qemu-stable@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Andreas Färber Message-Id: <1443689999-12182-9-git-send-email-armbru@redhat.com> (cherry picked from commit edb1523d90415cb79f60f83b4028ef3820d15612) --- qmp.c | 6 ++++++ tests/device-introspect-test.c | 15 ++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) Signed-off-by: Jeff E. Nelson --- qmp.c | 6 ++++++ tests/device-introspect-test.c | 15 ++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/qmp.c b/qmp.c index e6c7050..df18aeb 100644 --- a/qmp.c +++ b/qmp.c @@ -528,6 +528,12 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, return NULL; } + if (object_class_is_abstract(klass)) { + error_set(errp, QERR_INVALID_PARAMETER_VALUE, "name", + "non-abstract device type"); + return NULL; + } + obj = object_new(typename); QTAILQ_FOREACH(prop, &obj->properties, node) { diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index f240b5c..8a27b4a 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -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); -- 2.4.3