From nobody Sat Oct 11 08:38:37 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544806943110214.75222523524303; Fri, 14 Dec 2018 09:02:23 -0800 (PST) Received: from localhost ([::1]:34531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqqz-00020e-3t for importer@patchew.org; Fri, 14 Dec 2018 12:02:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqm5-0005fp-66 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXqm3-0002BD-52 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:17 -0500 Received: from mail-eopbgr80118.outbound.protection.outlook.com ([40.107.8.118]:22409 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXqm2-0001B5-PI for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:15 -0500 Received: from DB8PR08MB4092.eurprd08.prod.outlook.com (20.179.10.210) by DB8PR08MB4010.eurprd08.prod.outlook.com (20.179.9.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.22; Fri, 14 Dec 2018 16:57:07 +0000 Received: from DB8PR08MB4092.eurprd08.prod.outlook.com ([fe80::d0e0:ff54:c6fe:1407]) by DB8PR08MB4092.eurprd08.prod.outlook.com ([fe80::d0e0:ff54:c6fe:1407%3]) with mapi id 15.20.1425.021; Fri, 14 Dec 2018 16:57:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qm1wS5NkUMjr1uQgClyOfHnm1K6kTUkODxoVUF+T8Ow=; b=X19xVeeY0Vl1LQNwyI4AXr09sk7lIMbEWMc0Xrs7WqdY5VFTRpri6JmWY3gsZQXhXlk7uoE1ct82XTqcSrz1DvJysVBC/qUnV731SuQTDUMPJ3FIK6VjGqpRb0Cqn4cQB7OnMOR9Ii+jOnLfTqdusCqx4vBQqMEyG5e8BysGYOY= From: Roman Kagan To: "qemu-devel@nongnu.org" Thread-Topic: [RFC PATCH 2/5] qmp: further consolidate listing of device and object properties Thread-Index: AQHUk84LCQlA9pH4OUiRBsr0KwD7xg== Date: Fri, 14 Dec 2018 16:57:07 +0000 Message-ID: <20181214165657.749-3-rkagan@virtuozzo.com> References: <20181214165657.749-1-rkagan@virtuozzo.com> In-Reply-To: <20181214165657.749-1-rkagan@virtuozzo.com> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [185.231.240.5] x-clientproxiedby: HE1PR0401CA0073.eurprd04.prod.outlook.com (2603:10a6:3:19::41) To DB8PR08MB4092.eurprd08.prod.outlook.com (2603:10a6:10:ab::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB8PR08MB4010; 20:Wi/lo/Dx67536rRstAXo54gVxBFCyTtD5MtNXtPfnJxWfPJEdhRWbetNVhpn6nXOPtbv/ZOhOnoREJDtaO8NYJREeGedCezLv97hjiogS6x2cN1tVoJU2oPkLArWV46OWWNKhnYXPb5eMOBNDQH50bpeS04eKXddzrjqoqW1LLE= x-ms-office365-filtering-correlation-id: a8156d06-2ac4-4303-e3a4-08d661e52e24 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:DB8PR08MB4010; x-ms-traffictypediagnostic: DB8PR08MB4010: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(3231475)(944501520)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:DB8PR08MB4010; BCL:0; PCL:0; RULEID:; SRVR:DB8PR08MB4010; x-forefront-prvs: 08864C38AC x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(346002)(136003)(39850400004)(366004)(396003)(199004)(189003)(7736002)(486006)(2351001)(71190400001)(305945005)(81166006)(5660300001)(81156014)(36756003)(217873002)(6916009)(102836004)(2501003)(105586002)(6486002)(256004)(26005)(106356001)(446003)(8936002)(6512007)(76176011)(1076002)(316002)(6506007)(14454004)(3846002)(6116002)(54906003)(186003)(99286004)(11346002)(97736004)(8676002)(25786009)(52116002)(53936002)(2906002)(68736007)(4326008)(86362001)(575784001)(476003)(2616005)(478600001)(5640700003)(71200400001)(386003)(66066001)(6436002)(309714004); DIR:OUT; SFP:1102; SCL:1; SRVR:DB8PR08MB4010; H:DB8PR08MB4092.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; 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; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Xu6hH3rhSutqpeOokjr1sNK+WgVyD2wB8IYRFZkYPpTYpquS9CnHUi4w/R4/haoJxkm5Gkcpc4PRITFnEMY+fnAG8/ibYevMSbfLVhTOh18/zpC3YIklyOh96ZUqomHYlYSzEf/pXIlANNPI38Cp5Ghj7zwLRXoJiyjan7rKawO+qwTLjI4xKevbgBGUvzo4lgPupJWgu1h1zgFQyc3xaadtPUB2IYyWy8dOa8kTV7g5QdydUjuuLHVUkWd6GxHjtp29CAzd2MlvVLSY0EtL95LUowiP0aHjhedZbz30GYT9veTdSdQ/oQv8PfOvh5hK spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8156d06-2ac4-4303-e3a4-08d661e52e24 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2018 16:57:07.1734 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4010 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.8.118 Subject: [Qemu-devel] [RFC PATCH 2/5] qmp: further consolidate listing of device and object 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: Fam Zheng , "Michael S. Tsirkin" , Amit Shah , Markus Armbruster , Paolo Bonzini , =?iso-8859-1?Q?Andreas_F=E4rber?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Take the approach of commit 35f63767dc77d85bebff6c6565aceaf74023776a "qmp: Merge ObjectPropertyInfo and DevicePropertyInfo" one step further: drop device property-specific code from qmp_device_list_properties and consolidate the resulting common part with qmp_qom_list_properties. Signed-off-by: Roman Kagan --- qmp.c | 92 ++++++++++++++--------------------------------------------- 1 file changed, 22 insertions(+), 70 deletions(-) diff --git a/qmp.c b/qmp.c index e7c0a2fd60..673dfa72ce 100644 --- a/qmp.c +++ b/qmp.c @@ -430,56 +430,22 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_imple= ments, return ret; } =20 -/* Return a DevicePropertyInfo for a qdev property. - * - * If a qdev property with the given name does not exist, use the given de= fault - * type. If the qdev property info should not be shown, return NULL. - * - * The caller must free the return value. - */ -static ObjectPropertyInfo *make_device_property_info(ObjectClass *klass, - const char *name, - const char *default_type, - const char *description) +static void push_property_info(ObjectPropertyInfoList **prop_list, + ObjectProperty *prop) { ObjectPropertyInfo *info; - Property *prop; - - do { - for (prop =3D DEVICE_CLASS(klass)->props; prop && prop->name; prop= ++) { - if (strcmp(name, prop->name) !=3D 0) { - continue; - } - - /* - * TODO Properties without a parser are just for dirty hacks. - * qdev_prop_ptr is the only such PropertyInfo. It's marked - * for removal. This conditional should be removed along with - * it. - */ - if (!prop->info->set && !prop->info->create) { - return NULL; /* no way to set it, don't show */ - } - - info =3D g_malloc0(sizeof(*info)); - info->name =3D g_strdup(prop->name); - info->type =3D default_type ? g_strdup(default_type) - : g_strdup(prop->info->name); - info->has_description =3D !!prop->info->description; - info->description =3D g_strdup(prop->info->description); - return info; - } - klass =3D object_class_get_parent(klass); - } while (klass !=3D object_class_by_name(TYPE_DEVICE)); - - /* Not a qdev property, use the default type */ - info =3D g_malloc0(sizeof(*info)); - info->name =3D g_strdup(name); - info->type =3D g_strdup(default_type); - info->has_description =3D !!description; - info->description =3D g_strdup(description); - - return info; + ObjectPropertyInfoList *entry; + + info =3D g_new0(ObjectPropertyInfo, 1); + info->name =3D g_strdup(prop->name); + info->type =3D g_strdup(prop->type); + info->has_description =3D !!prop->description; + info->description =3D g_strdup(prop->description); + + entry =3D g_new0(ObjectPropertyInfoList, 1); + entry->value =3D info; + entry->next =3D *prop_list; + *prop_list =3D entry; } =20 ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, @@ -514,9 +480,6 @@ ObjectPropertyInfoList *qmp_device_list_properties(cons= t char *typename, =20 object_property_iter_init(&iter, obj); while ((prop =3D object_property_iter_next(&iter))) { - ObjectPropertyInfo *info; - ObjectPropertyInfoList *entry; - /* Skip Object and DeviceState properties */ if (strcmp(prop->name, "type") =3D=3D 0 || strcmp(prop->name, "realized") =3D=3D 0 || @@ -533,16 +496,12 @@ ObjectPropertyInfoList *qmp_device_list_properties(co= nst char *typename, continue; } =20 - info =3D make_device_property_info(klass, prop->name, prop->type, - prop->description); - if (!info) { + /* Skip readonly properties. */ + if (!prop->set) { continue; } =20 - entry =3D g_malloc0(sizeof(*entry)); - entry->value =3D info; - entry->next =3D prop_list; - prop_list =3D entry; + push_property_info(&prop_list, prop); } =20 object_unref(obj); @@ -579,19 +538,12 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const= char *typename, object_property_iter_init(&iter, obj); } while ((prop =3D object_property_iter_next(&iter))) { - ObjectPropertyInfo *info; - ObjectPropertyInfoList *entry; + /* Skip readonly properties. */ + if (!prop->set) { + continue; + } =20 - info =3D g_malloc0(sizeof(*info)); - info->name =3D g_strdup(prop->name); - info->type =3D g_strdup(prop->type); - info->has_description =3D !!prop->description; - info->description =3D g_strdup(prop->description); - - entry =3D g_malloc0(sizeof(*entry)); - entry->value =3D info; - entry->next =3D prop_list; - prop_list =3D entry; + push_property_info(&prop_list, prop); } =20 object_unref(obj); --=20 2.19.2