From nobody Tue Feb 10 20:28:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506463634066496.1712511525692; Tue, 26 Sep 2017 15:07:14 -0700 (PDT) Received: from localhost ([::1]:51282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwy0U-0006gI-AJ for importer@patchew.org; Tue, 26 Sep 2017 18:07:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwxx2-0004JG-KI for qemu-devel@nongnu.org; Tue, 26 Sep 2017 18:03:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwxx1-00037f-JT for qemu-devel@nongnu.org; Tue, 26 Sep 2017 18:03:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwxx1-00037G-BC for qemu-devel@nongnu.org; Tue, 26 Sep 2017 18:03:35 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60059C057FA6; Tue, 26 Sep 2017 22:03:34 +0000 (UTC) Received: from localhost (ovpn-116-64.gru2.redhat.com [10.97.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id E662E5C6EC; Tue, 26 Sep 2017 22:03:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 60059C057FA6 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 26 Sep 2017 19:03:25 -0300 Message-Id: <20170926220326.12996-4-ehabkost@redhat.com> In-Reply-To: <20170926220326.12996-1-ehabkost@redhat.com> References: <20170926220326.12996-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 26 Sep 2017 22:03:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/4] qmp: query-device-type command 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: Peter Maydell , Thomas Huth , Cornelia Huck , Markus Armbruster , Igor Mammedov , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a command that returns QOM type information that is specific to device types and is not returned by qom-list-types. The returned DeviceTypeInfo struct inherits from ObjectTypeInfo, so fields returned by qom-list-types are also included. Signed-off-by: Eduardo Habkost --- qapi-schema.json | 35 +++++++++++++++++++++++++++++++++++ qmp.c | 25 +++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/qapi-schema.json b/qapi-schema.json index a3ba1c9a1c..0955380a59 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1466,6 +1466,41 @@ 'returns': [ 'DevicePropertyInfo' ] } =20 ## +# @DeviceTypeInfo: +# +# Information about a device type. +# +# @user-creatable: If true, the device can be instantiated using the -devi= ce +# command-line option. +# @hotpluggable: If true, the device can be instantiated using @device_add, +# if the machine supports the device. +# +# @description: Human-readable description of the device type. +# +# Since: 2.11 +## +{ 'struct': 'DeviceTypeInfo', + 'base': 'ObjectTypeInfo', + 'data': { 'hotpluggable': 'bool', + 'user-creatable': 'bool', + '*description': 'str' } } + +## +# @query-device-type: +# +# Query information about a device type. +# +# @typename: the name of the device type +# +# Returns: a DeviceTypeInfo struct +# +# Since: 2.11 +## +{ 'command': 'query-device-type', + 'data': { 'typename': 'str' }, + 'returns': 'DeviceTypeInfo' } + +## # @xen-set-global-dirty-log: # # Enable or disable the global dirty log mode. diff --git a/qmp.c b/qmp.c index 5ec829c09b..761fcf61c7 100644 --- a/qmp.c +++ b/qmp.c @@ -597,6 +597,31 @@ DevicePropertyInfoList *qmp_device_list_properties(con= st char *typename, return prop_list; } =20 +DeviceTypeInfo *qmp_query_device_type(const char *typename, Error **errp) +{ + DeviceTypeInfo *info =3D g_new0(DeviceTypeInfo, 1); + DeviceClass *dc =3D get_device_class(typename, errp); + + if (!dc) { + return NULL; + } + + qom_type_get_info(OBJECT_CLASS(dc), qapi_DeviceTypeInfo_base(info)); + info->user_creatable =3D dc->user_creatable; + /* + * We have non-user-creatable devices with hotpluggable=3Dtrue (becaus= e they + * are instantiated internally by hotpluggable devices), but it doesn'= t make + * sense to tell the user that device_add is supported if the device i= s not + * user-creatable + */ + info->hotpluggable =3D dc->user_creatable && dc->hotpluggable; + if (dc->desc) { + info->has_description =3D true; + info->description =3D g_strdup(dc->desc); + } + return info; +} + CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) { return arch_query_cpu_definitions(errp); --=20 2.13.5