From patchwork Tue Oct 11 20:41:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 680923 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3stptv0y4Sz9sBr for ; Wed, 12 Oct 2016 07:46:31 +1100 (AEDT) Received: from localhost ([::1]:57950 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bu3wS-0004Dh-2Z for incoming@patchwork.ozlabs.org; Tue, 11 Oct 2016 16:46:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bu3rn-0000em-6X for qemu-devel@nongnu.org; Tue, 11 Oct 2016 16:41:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bu3rl-0000Tx-NT for qemu-devel@nongnu.org; Tue, 11 Oct 2016 16:41:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bu3rl-0000To-HT for qemu-devel@nongnu.org; Tue, 11 Oct 2016 16:41:37 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BBBDC05490E; Tue, 11 Oct 2016 20:41:37 +0000 (UTC) Received: from localhost (ovpn-116-77.phx2.redhat.com [10.3.116.77]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9BKfZ2k019853; Tue, 11 Oct 2016 16:41:36 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 11 Oct 2016 17:41:18 -0300 Message-Id: <1476218479-3592-6-git-send-email-ehabkost@redhat.com> In-Reply-To: <1476218479-3592-1-git-send-email-ehabkost@redhat.com> References: <1476218479-3592-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 11 Oct 2016 20:41:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/6] qmp: Support abstract classes on device-list-properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , =?UTF-8?q?Andreas=20F=C3=A4rber?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When an abstract class is used on device-list-properties, we can simply return the class properties registered for the class. This will be useful if management software needs to query for CPU options that are supported by all CPU models, for example. Signed-off-by: Eduardo Habkost --- qmp.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/qmp.c b/qmp.c index b3ba9ef..dd6090d 100644 --- a/qmp.c +++ b/qmp.c @@ -518,7 +518,7 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, Error **errp) { ObjectClass *klass; - Object *obj; + Object *obj = NULL; ObjectProperty *prop; ObjectPropertyIterator iter; DevicePropertyInfoList *prop_list = NULL; @@ -537,19 +537,16 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, } if (object_class_is_abstract(klass)) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "name", - "non-abstract device type"); - return NULL; - } - - if (DEVICE_CLASS(klass)->cannot_destroy_with_object_finalize_yet) { - error_setg(errp, "Can't list properties of device '%s'", typename); - return NULL; + object_class_property_iter_init(&iter, klass); + } else { + if (DEVICE_CLASS(klass)->cannot_destroy_with_object_finalize_yet) { + error_setg(errp, "Can't list properties of device '%s'", typename); + return NULL; + } + obj = object_new(typename); + object_property_iter_init(&iter, obj); } - obj = object_new(typename); - - object_property_iter_init(&iter, obj); while ((prop = object_property_iter_next(&iter))) { DevicePropertyInfo *info; DevicePropertyInfoList *entry;