From patchwork Thu Oct 8 13:02:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 527688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:4830:134:3::10]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B032F140D6E for ; Fri, 9 Oct 2015 00:08:08 +1100 (AEDT) Received: from lists.gnu.org ([208.118.235.17]:43819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkAvW-0005UV-Oe for incoming@patchwork.ozlabs.org; Thu, 08 Oct 2015 09:08:06 -0400 Received: from localhost ([::1]:34550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkAvW-0005bp-Lj for incoming@patchwork.ozlabs.org; Thu, 08 Oct 2015 09:08:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkAq0-0007ZU-1R for qemu-devel@nongnu.org; Thu, 08 Oct 2015 09:02:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkApt-0007AI-2Z for qemu-devel@nongnu.org; Thu, 08 Oct 2015 09:02:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkAps-00079m-UQ; Thu, 08 Oct 2015 09:02:17 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 86D00C0BE067; Thu, 8 Oct 2015 13:02:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t98D2E62012793 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 8 Oct 2015 09:02:16 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 88364300BD82; Thu, 8 Oct 2015 15:02:12 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 8 Oct 2015 15:02:09 +0200 Message-Id: <1444309331-17927-10-git-send-email-armbru@redhat.com> In-Reply-To: <1444309331-17927-1-git-send-email-armbru@redhat.com> References: <1444309331-17927-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-stable@nongnu.org Subject: [Qemu-devel] [PULL v2 09/11] qmp: Fix device-list-properties not to crash for abstract device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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> --- 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 057a7cb..1413de4 100644 --- a/qmp.c +++ b/qmp.c @@ -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) { 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);