From patchwork Fri Dec 14 16:57:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10731465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD7BD746 for ; Fri, 14 Dec 2018 16:58:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34B9D28759 for ; Fri, 14 Dec 2018 16:58:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2072C2D3DD; Fri, 14 Dec 2018 16:58:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 91BEC2D395 for ; Fri, 14 Dec 2018 16:58:38 +0000 (UTC) Received: from localhost ([::1]:34498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqnN-0007ui-GS for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Dec 2018 11:58:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqm4-0005fZ-Ks for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXqm2-00024X-7y for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:16 -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 1gXqm1-0001B5-RY for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:14 -0500 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=eKM5IIDoFnP5W7dP0bARCtLt1iK8oWGTegqjKqceU6g=; b=R0sbl2+tTCMUWjVpwqz7fldxQOLemwlkO1jO5vaNIEnx4wPTWXo3qRB9laBXPlu2LmLVeSGLtASkXLfI4Jcit84vFZwcSU8flZF7jqcmpQ1PBzj4Q3R6GHY5XjDOoRr+zpOPhGpfDh0jx+KzPOqZN454OF//fhScmLuHGXPZxIw= 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:06 +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:06 +0000 From: Roman Kagan To: "qemu-devel@nongnu.org" Thread-Topic: [RFC PATCH 1/5] qom: preserve get/set presence in aliased properties Thread-Index: AQHUk84LeeJQlcq0qUeD2xgF7dLiJA== Date: Fri, 14 Dec 2018 16:57:06 +0000 Message-ID: <20181214165657.749-2-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:8ib7rRtKLibqfTOvAnDqZ25gEemA7c1s3lFHIBFxruZgD35OMbX9RiTUq73WDurDT4VBFkwGV5hOEJZNTn2i4yRC8s2LGQ24H4YriIYJAb9uoGXp66I2p/5e/A7vgvjnfpm2F4mB6/jg2QLP8RBsUzX/w4q5tUJwGb4wub4wb2s= x-ms-office365-filtering-correlation-id: 82a20ab8-041e-43fc-9a0e-08d661e52d9a 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)(14444005)(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); 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: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: yOm94qfLdwuoIpO6ZYFkwsAKoje6GsLpclyHAIFS+smHgG4wvPfRN4G1Yg7bvIGGbXK6GGai2GggFteg8BpK1E0UFVV80+ScQTwNLrbrpsJeOjSLhFBj6OIJnLW3Xi7EwZ5I6gTfdrENl4aG9SR5k/zEOVGVbitV5AoMPgnt7lQfAPLiJmDddJ9Z72xeTIPoKr38EUxOpcIUVjd9iKhNqbnrPZTvXuZF9KZepLyYNddwPcvOdxZTxJWduvgSunWYAnEU7TbuAQpObVNVkatBdkkOwBZWfMPVXWDHqulVSuHkbNmIC3sMopm2yntIfVnJ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82a20ab8-041e-43fc-9a0e-08d661e52d9a X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2018 16:57:06.2515 (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 1/5] qom: preserve get/set presence in aliased 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Usually in order to tell if a property is read-only, write-only, or read-write, one has to look at whether it has .get or .set methods. However, property aliases are always defined with both, and it's not until the call to the getter or setter when the support for the corresponding operation can be found out. To make it easier to determine if an operation is supported for an alias property, only assign it getter and setter if the target property has the corresponding method. Signed-off-by: Roman Kagan --- qom/object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qom/object.c b/qom/object.c index 17921c0a71..b362ebab19 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2382,8 +2382,8 @@ void object_property_add_alias(Object *obj, const char *name, prop->target_name = g_strdup(target_name); op = object_property_add(obj, name, prop_type, - property_get_alias, - property_set_alias, + target_prop->get ? property_get_alias : NULL, + target_prop->set ? property_set_alias : NULL, property_release_alias, prop, &local_err); if (local_err) { From patchwork Fri Dec 14 16:57:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10731473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B02A924 for ; Fri, 14 Dec 2018 17:01:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5AB02D8A2 for ; Fri, 14 Dec 2018 17:01:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A742A2D8AA; Fri, 14 Dec 2018 17:01:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2094D2D8A2 for ; Fri, 14 Dec 2018 17:01:45 +0000 (UTC) Received: from localhost ([::1]:34505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqqN-0000i8-T4 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Dec 2018 12:01:44 -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 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= 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 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: 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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_implements, return ret; } -/* Return a DevicePropertyInfo for a qdev property. - * - * If a qdev property with the given name does not exist, use the given default - * 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 = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) { - if (strcmp(name, prop->name) != 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 = g_malloc0(sizeof(*info)); - info->name = g_strdup(prop->name); - info->type = default_type ? g_strdup(default_type) - : g_strdup(prop->info->name); - info->has_description = !!prop->info->description; - info->description = g_strdup(prop->info->description); - return info; - } - klass = object_class_get_parent(klass); - } while (klass != object_class_by_name(TYPE_DEVICE)); - - /* Not a qdev property, use the default type */ - info = g_malloc0(sizeof(*info)); - info->name = g_strdup(name); - info->type = g_strdup(default_type); - info->has_description = !!description; - info->description = g_strdup(description); - - return info; + ObjectPropertyInfoList *entry; + + info = g_new0(ObjectPropertyInfo, 1); + info->name = g_strdup(prop->name); + info->type = g_strdup(prop->type); + info->has_description = !!prop->description; + info->description = g_strdup(prop->description); + + entry = g_new0(ObjectPropertyInfoList, 1); + entry->value = info; + entry->next = *prop_list; + *prop_list = entry; } ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, @@ -514,9 +480,6 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, object_property_iter_init(&iter, obj); while ((prop = object_property_iter_next(&iter))) { - ObjectPropertyInfo *info; - ObjectPropertyInfoList *entry; - /* Skip Object and DeviceState properties */ if (strcmp(prop->name, "type") == 0 || strcmp(prop->name, "realized") == 0 || @@ -533,16 +496,12 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, continue; } - info = make_device_property_info(klass, prop->name, prop->type, - prop->description); - if (!info) { + /* Skip readonly properties. */ + if (!prop->set) { continue; } - entry = g_malloc0(sizeof(*entry)); - entry->value = info; - entry->next = prop_list; - prop_list = entry; + push_property_info(&prop_list, prop); } object_unref(obj); @@ -579,19 +538,12 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, object_property_iter_init(&iter, obj); } while ((prop = object_property_iter_next(&iter))) { - ObjectPropertyInfo *info; - ObjectPropertyInfoList *entry; + /* Skip readonly properties. */ + if (!prop->set) { + continue; + } - info = g_malloc0(sizeof(*info)); - info->name = g_strdup(prop->name); - info->type = g_strdup(prop->type); - info->has_description = !!prop->description; - info->description = g_strdup(prop->description); - - entry = g_malloc0(sizeof(*entry)); - entry->value = info; - entry->next = prop_list; - prop_list = entry; + push_property_info(&prop_list, prop); } object_unref(obj); From patchwork Fri Dec 14 16:57:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10731479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 259406C5 for ; Fri, 14 Dec 2018 17:04:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F7812D861 for ; Fri, 14 Dec 2018 17:04:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 734BC2D8DA; Fri, 14 Dec 2018 17:04:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E079E2D861 for ; Fri, 14 Dec 2018 17:04:40 +0000 (UTC) Received: from localhost ([::1]:34638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqtE-0005F1-3o for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Dec 2018 12:04:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqm5-0005gC-UY 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 1gXqm4-0002GD-2N 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 1gXqm3-0001B5-M1 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:15 -0500 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=taWRYvaXYdW81h0o5VVu4ZAFoKf1kaOEdp+/mhqMcW0=; b=BRWoZzjF+CjRsWu5lX4yrbweU5NbPzYn7WA5XcyeyHNp5hg7d706+pn5mmh2Jy1jIFjsH4TVoq7jJFWz60SxN/Dq/gVm4MZ8zk1ydrzQi/bWO9J9q9UvbWNF1H2hZwqfcS9DE60QKMC+AoHIFA1w7OJjQbfhuinj0f0aKRfztFs= 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:08 +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:08 +0000 From: Roman Kagan To: "qemu-devel@nongnu.org" Thread-Topic: [RFC PATCH 3/5] qdev-properties: add r/o 64bit bitfield property Thread-Index: AQHUk84M4eh5obVh1UKJYI2sPHnMhg== Date: Fri, 14 Dec 2018 16:57:08 +0000 Message-ID: <20181214165657.749-4-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:7d82uUpK0TAe6AZDRSbLi8gedunj+1QeZFHFEQp9isSAqR+whQ/1X9TmadOjdE0b8Xm77oosbDQc6k1pIr2cBIPhJH8T0I3XJAYou9izFJLl0pdWoj+GErnDfiArvJmLYa9wFB9n6YWCU3j4FBGGfkL4rgwPAlVe/ernISLOh9k= x-ms-office365-filtering-correlation-id: 8a308e03-bbbd-4460-8fa0-08d661e52eb1 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)(14444005)(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)(476003)(2616005)(478600001)(5640700003)(71200400001)(386003)(66066001)(6436002); 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: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: sRVl3TOHQVk6vETaa2JVPZywX0yJBJ7nrVHq5v7Wo7ZN51vtYoEV40WBvrOfKagFu9/9MX4AlO4sFJd/Qjk8msZks8zzP6IEnf2UV/gncFYWuYICw7wpJqJLzAOsiwtGaxxt+MpiuG55WGZZjmZtSnBn34QWVccQzriuBjZ37SIe17lPTyoEaqpRBhvPekh+63R70vaWGhx6GNPdqedebneFDGm1QfNCUL4kfWnpwGvK38kyGRJMYAyfjM6ALWU1zFpIP2rcLBLY4qaqcvtC5g26OYQUjPA3kdpUi5YbpfGMQBgdrl9hDaWDEgEhTdJX spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a308e03-bbbd-4460-8fa0-08d661e52eb1 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2018 16:57:08.0328 (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 3/5] qdev-properties: add r/o 64bit bitfield property 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a version 64bit bitfield property with no setter, useful for introspecting the device state without being able to modify it. Signed-off-by: Roman Kagan --- include/hw/qdev-properties.h | 9 +++++++++ hw/core/qdev-properties.c | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 3ab9cd2eb6..24df135ff8 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -9,6 +9,7 @@ extern const PropertyInfo qdev_prop_bit; extern const PropertyInfo qdev_prop_bit64; +extern const PropertyInfo qdev_prop_bit64_ro; extern const PropertyInfo qdev_prop_bool; extern const PropertyInfo qdev_prop_uint8; extern const PropertyInfo qdev_prop_uint16; @@ -96,6 +97,14 @@ extern const PropertyInfo qdev_prop_off_auto_pcibar; .defval.u = (bool)_defval, \ } +#define DEFINE_PROP_BIT64_RO(_name, _state, _field, _bit) { \ + .name = (_name), \ + .info = &(qdev_prop_bit64_ro), \ + .bitnr = (_bit), \ + .offset = offsetof(_state, _field) \ + + type_check(uint64_t, typeof_field(_state, _field)), \ + } + #define DEFINE_PROP_BOOL(_name, _state, _field, _defval) { \ .name = (_name), \ .info = &(qdev_prop_bool), \ diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index bd84c4ea4c..bb9bd48e5c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -146,7 +146,8 @@ const PropertyInfo qdev_prop_bit = { static uint64_t qdev_get_prop_mask64(Property *prop) { - assert(prop->info == &qdev_prop_bit64); + assert(prop->info == &qdev_prop_bit64 || + prop->info == &qdev_prop_bit64_ro); return 0x1ull << prop->bitnr; } @@ -201,6 +202,12 @@ const PropertyInfo qdev_prop_bit64 = { .set_default_value = set_default_value_bool, }; +const PropertyInfo qdev_prop_bit64_ro = { + .name = "bool", + .description = "on/off", + .get = prop_get_bit64, +}; + /* --- bool --- */ static void get_bool(Object *obj, Visitor *v, const char *name, void *opaque, From patchwork Fri Dec 14 16:57:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10731469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 142BD924 for ; Fri, 14 Dec 2018 16:58:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 704E72D0A5 for ; Fri, 14 Dec 2018 16:58:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6447B2D1A8; Fri, 14 Dec 2018 16:58:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BD23F2D0A5 for ; Fri, 14 Dec 2018 16:58:48 +0000 (UTC) Received: from localhost ([::1]:34496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqnX-0005p2-BT for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Dec 2018 11:58:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqm7-0005hQ-OS for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXqm4-0002MS-Tw for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:19 -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 1gXqm4-0001B5-IR for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:16 -0500 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=p3oVtzoNhtOvesTXszUFCX9SbHzUcPc44nJPcxekv5w=; b=DcdNyu70WgqR3hxnWRfLGfxZG7nnSlJJVK5L7vvEVa18SU1fl42OpRAKiQfSTbHFiSBrOEBCHRAoLmW6PtmAv0t2ji8dI4kcXaJIAlOBQOsqQMAKzGgoHxqnvqF1D/Rxw4ezP8n7chDv9Go0ASkmDcV17CX1pqs/3R6iO7vpGoc= 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:09 +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:09 +0000 From: Roman Kagan To: "qemu-devel@nongnu.org" Thread-Topic: [RFC PATCH 4/5] virtio: drop DEFINE_VIRTIO_COMMON_FEATURES Thread-Index: AQHUk84MZwNBPHp0q0+qy1IhnsqV7w== Date: Fri, 14 Dec 2018 16:57:08 +0000 Message-ID: <20181214165657.749-5-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:tc0JmakU99h/UInrvlnZm3+Kpv54KL7yTx65uR8URwW/nNzWD7Jfn3tJ/wpnqG8/byElvaOFutNxcgrIw/E9Nu/KXjpNaWihSwE5GIa72iamkAw3rA8e/19CYvMZKIYqmLLJNfYu0NU4HOid/iomTqO6iEUsAKj1UUTa+LYlckc= x-ms-office365-filtering-correlation-id: 61c5a727-3275-495b-b21c-08d661e52f34 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)(476003)(2616005)(478600001)(5640700003)(71200400001)(386003)(66066001)(6436002); 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: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: p/iqDZbYRHThg1srPHHeUPIlQs2iYBCPFo6PGALWyjJcLUfkUd1eqs3OTZ0hcsuoRPvJWwv2YzWsO4aiZPgslaMukJQuEWDdSJTVB3j7SuxhkPAKqmD/KhU8MAqQbZFT4gB1d3AX7S6jYxZELXIwf77GqAys3W6KVVz2BM+H13vb6A+LoZ11hR9Fd0Tqi6zKelj1WHl63ZGP1pXiv0XExxvbpsvB92w1Fp710/iM7Z0z+5/MCl1Osd6mdQ3aSrs4wnptWF6udWVMNhNgAmPkhllLfTf+Kz3KNGlRpV62PXsYIM9aUZ4EmEk/nRbUE3Pq spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61c5a727-3275-495b-b21c-08d661e52f34 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2018 16:57:08.9391 (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 4/5] virtio: drop DEFINE_VIRTIO_COMMON_FEATURES 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This macro is only used in one place so seems to be unnecessary. Signed-off-by: Roman Kagan --- include/hw/virtio/virtio.h | 12 ------------ hw/virtio/virtio.c | 11 ++++++++++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 9c1fa07d6d..cea356efed 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -254,18 +254,6 @@ typedef struct virtio_input_conf virtio_input_conf; typedef struct VirtIOSCSIConf VirtIOSCSIConf; typedef struct VirtIORNGConf VirtIORNGConf; -#define DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) \ - DEFINE_PROP_BIT64("indirect_desc", _state, _field, \ - VIRTIO_RING_F_INDIRECT_DESC, true), \ - DEFINE_PROP_BIT64("event_idx", _state, _field, \ - VIRTIO_RING_F_EVENT_IDX, true), \ - DEFINE_PROP_BIT64("notify_on_empty", _state, _field, \ - VIRTIO_F_NOTIFY_ON_EMPTY, true), \ - DEFINE_PROP_BIT64("any_layout", _state, _field, \ - VIRTIO_F_ANY_LAYOUT, true), \ - DEFINE_PROP_BIT64("iommu_platform", _state, _field, \ - VIRTIO_F_IOMMU_PLATFORM, false) - hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n); hwaddr virtio_queue_get_avail_addr(VirtIODevice *vdev, int n); hwaddr virtio_queue_get_used_addr(VirtIODevice *vdev, int n); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 22bd1ac34e..99d396c516 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2601,7 +2601,16 @@ static void virtio_device_instance_finalize(Object *obj) } static Property virtio_properties[] = { - DEFINE_VIRTIO_COMMON_FEATURES(VirtIODevice, host_features), + DEFINE_PROP_BIT64("indirect_desc", VirtIODevice, host_features, + VIRTIO_RING_F_INDIRECT_DESC, true), + DEFINE_PROP_BIT64("event_idx", VirtIODevice, host_features, + VIRTIO_RING_F_EVENT_IDX, true), + DEFINE_PROP_BIT64("notify_on_empty", VirtIODevice, host_features, + VIRTIO_F_NOTIFY_ON_EMPTY, true), + DEFINE_PROP_BIT64("any_layout", VirtIODevice, host_features, + VIRTIO_F_ANY_LAYOUT, true), + DEFINE_PROP_BIT64("iommu_platform", VirtIODevice, host_features, + VIRTIO_F_IOMMU_PLATFORM, false), DEFINE_PROP_END_OF_LIST(), }; From patchwork Fri Dec 14 16:57:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10731471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12114746 for ; Fri, 14 Dec 2018 16:58:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F53C2D63C for ; Fri, 14 Dec 2018 16:58:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 633082D649; Fri, 14 Dec 2018 16:58:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 616122D63C for ; Fri, 14 Dec 2018 16:58:52 +0000 (UTC) Received: from localhost ([::1]:34501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqnb-00086H-1r for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Dec 2018 11:58:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXqmB-0005lT-La for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXqm5-0002TJ-TT for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:21 -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 1gXqm5-0001B5-EZ for qemu-devel@nongnu.org; Fri, 14 Dec 2018 11:57:17 -0500 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=l8PPnUIrlwxX4IvLCSYQVG8e44kP/XQ74gVJd+u7fYw=; b=irEN/n1gaTBOacPvNNQB55Vceh7hfjcFuTZFyeEWt+oDHBigL+h2Q16yqRuiDSYbX3h8W731oBmXIL+v6oJFbFEK80VRBLSVjEOoE7egcGdfkeOym9TEQstQf0z/FAOvr1aDsFr5F17ZUwreBaqpHsRvpQxuE2rarbkj2BdNPug= 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:09 +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:09 +0000 From: Roman Kagan To: "qemu-devel@nongnu.org" Thread-Topic: [RFC PATCH 5/5] virtio: expose negotiated features in r/o properties Thread-Index: AQHUk84N0sxPzHgOuEKzMlTSypVCdw== Date: Fri, 14 Dec 2018 16:57:09 +0000 Message-ID: <20181214165657.749-6-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:Q4kdZ5fieb63ThuLV+9tqalEqCjGWqakkPrPLP5AHd0iTyr0N1/JMWcSBkIz3feQDypMdiorHGuXtc0uH7NfJrakU113T8El5MPWzIfnrMVG3Hg9mTmt9G/RSv/6WGohIJZpRKaJyz6TLZ1kxITTOR7DB7TC35pw6GsFLd3VWsU= x-ms-office365-filtering-correlation-id: dd1719df-052a-40a7-fbae-08d661e52fbe 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)(4744004)(25786009)(52116002)(53936002)(2906002)(68736007)(4326008)(86362001)(575784001)(476003)(2616005)(478600001)(5640700003)(71200400001)(386003)(66066001)(6436002); 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: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: eY2iBpvZn3Ir/wSoBM6kZm22eJ96LYY2C4d3SvRM8JJusQ8xfUkxdW+OUtrxafkmSUkZvNU9LCPN4N9NC1DkCD5/DH9BqyahDVKi/A6D7nVDH4ugHf/3FTBTZIPtkmh5duv4Z45x4dDWTi++yzAwfPWM1TI74PtR3CSKiCwY7oPCSO4C7h4y68stnMYOBnZSUgbWkWFtGj4znisaoPokIGIsoDZib01NSe8XbZkRYLzP2x5ofCrUqQiQtQ39XIgjW7GgBePKYS6V1wuI8zVveD131j2KuicAtSk5N5QN7hdxOmEjYIM7aqm3HPmrmsq4 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd1719df-052a-40a7-fbae-08d661e52fbe X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2018 16:57:09.8298 (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 5/5] virtio: expose negotiated features in r/o 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Make virtio features acknowledged by the guest visible through QOM as read-only properties. One potential usecase of this is debugging; another is when the upper layer needs to do something only when/if the guest has acknowledged the support for a feature (e.g. hot-plug a VFIO device once the guest claims VIRTIO_NET_F_STANDBY support). Since most of the feature bits already have associated properties for host_features, reuse those definitions by creating a new macro that combines the original definition for the host_features bit property and a definition of a read-only guest_features bit property with the same name prefixed with "negotiated-". For the features which have no associated host_features bit property, only the latter is defined. Note #1: the macro is somewhat fragile as it produces two values separated by a comma, to be used for initializing consecutive elements in an array Note #2: due to note #1, it fails checkpatch. Note #3: it is also somewhat fragile as it assumes its first argument to be a string literal Note #4: for RFC purposes I only converted some virtio devices. Signed-off-by: Roman Kagan --- include/hw/virtio/virtio-scsi.h | 2 +- include/hw/virtio/virtio.h | 8 +++ hw/char/virtio-serial-bus.c | 6 ++- hw/net/virtio-net.c | 88 ++++++++++++++++++--------------- hw/scsi/virtio-scsi.c | 4 +- hw/virtio/virtio.c | 20 ++++---- 6 files changed, 73 insertions(+), 55 deletions(-) diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h index 4c0bcdb788..9b412bd2c3 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -86,7 +86,7 @@ typedef struct VirtIOSCSI { bool dataplane_starting; bool dataplane_stopping; bool dataplane_fenced; - uint32_t host_features; + uint64_t host_features; } VirtIOSCSI; typedef struct VirtIOSCSIReq { diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index cea356efed..a4690e6176 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -254,6 +254,14 @@ typedef struct virtio_input_conf virtio_input_conf; typedef struct VirtIOSCSIConf VirtIOSCSIConf; typedef struct VirtIORNGConf VirtIORNGConf; +#define DEFINE_VIRTIO_FEATURE_BIT_NEGOTIATED(_name, _bit) \ + DEFINE_PROP_BIT64_RO("negotiated-" _name, VirtIODevice, \ + guest_features, _bit) + +#define DEFINE_VIRTIO_FEATURE_BIT(_name, _state, _field, _bit, _defval) \ + DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval), \ + DEFINE_VIRTIO_FEATURE_BIT_NEGOTIATED(_name, _bit) + hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n); hwaddr virtio_queue_get_avail_addr(VirtIODevice *vdev, int n); hwaddr virtio_queue_get_used_addr(VirtIODevice *vdev, int n); diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 04e3ebe352..07bf729891 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1154,8 +1154,10 @@ static const VMStateDescription vmstate_virtio_console = { static Property virtio_serial_properties[] = { DEFINE_PROP_UINT32("max_ports", VirtIOSerial, serial.max_virtserial_ports, 31), - DEFINE_PROP_BIT64("emergency-write", VirtIOSerial, host_features, - VIRTIO_CONSOLE_F_EMERG_WRITE, true), + DEFINE_VIRTIO_FEATURE_BIT_NEGOTIATED("multiport", + VIRTIO_CONSOLE_F_MULTIPORT), + DEFINE_VIRTIO_FEATURE_BIT("emergency-write", VirtIOSerial, host_features, + VIRTIO_CONSOLE_F_EMERG_WRITE, true), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 385b1a03e9..d4df3394ee 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2144,46 +2144,54 @@ static const VMStateDescription vmstate_virtio_net = { }; static Property virtio_net_properties[] = { - DEFINE_PROP_BIT64("csum", VirtIONet, host_features, - VIRTIO_NET_F_CSUM, true), - DEFINE_PROP_BIT64("guest_csum", VirtIONet, host_features, - VIRTIO_NET_F_GUEST_CSUM, true), - DEFINE_PROP_BIT64("gso", VirtIONet, host_features, VIRTIO_NET_F_GSO, true), - DEFINE_PROP_BIT64("guest_tso4", VirtIONet, host_features, - VIRTIO_NET_F_GUEST_TSO4, true), - DEFINE_PROP_BIT64("guest_tso6", VirtIONet, host_features, - VIRTIO_NET_F_GUEST_TSO6, true), - DEFINE_PROP_BIT64("guest_ecn", VirtIONet, host_features, - VIRTIO_NET_F_GUEST_ECN, true), - DEFINE_PROP_BIT64("guest_ufo", VirtIONet, host_features, - VIRTIO_NET_F_GUEST_UFO, true), - DEFINE_PROP_BIT64("guest_announce", VirtIONet, host_features, - VIRTIO_NET_F_GUEST_ANNOUNCE, true), - DEFINE_PROP_BIT64("host_tso4", VirtIONet, host_features, - VIRTIO_NET_F_HOST_TSO4, true), - DEFINE_PROP_BIT64("host_tso6", VirtIONet, host_features, - VIRTIO_NET_F_HOST_TSO6, true), - DEFINE_PROP_BIT64("host_ecn", VirtIONet, host_features, - VIRTIO_NET_F_HOST_ECN, true), - DEFINE_PROP_BIT64("host_ufo", VirtIONet, host_features, - VIRTIO_NET_F_HOST_UFO, true), - DEFINE_PROP_BIT64("mrg_rxbuf", VirtIONet, host_features, - VIRTIO_NET_F_MRG_RXBUF, true), - DEFINE_PROP_BIT64("status", VirtIONet, host_features, - VIRTIO_NET_F_STATUS, true), - DEFINE_PROP_BIT64("ctrl_vq", VirtIONet, host_features, - VIRTIO_NET_F_CTRL_VQ, true), - DEFINE_PROP_BIT64("ctrl_rx", VirtIONet, host_features, - VIRTIO_NET_F_CTRL_RX, true), - DEFINE_PROP_BIT64("ctrl_vlan", VirtIONet, host_features, - VIRTIO_NET_F_CTRL_VLAN, true), - DEFINE_PROP_BIT64("ctrl_rx_extra", VirtIONet, host_features, - VIRTIO_NET_F_CTRL_RX_EXTRA, true), - DEFINE_PROP_BIT64("ctrl_mac_addr", VirtIONet, host_features, - VIRTIO_NET_F_CTRL_MAC_ADDR, true), - DEFINE_PROP_BIT64("ctrl_guest_offloads", VirtIONet, host_features, - VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, true), - DEFINE_PROP_BIT64("mq", VirtIONet, host_features, VIRTIO_NET_F_MQ, false), + DEFINE_VIRTIO_FEATURE_BIT("csum", VirtIONet, host_features, + VIRTIO_NET_F_CSUM, true), + DEFINE_VIRTIO_FEATURE_BIT("guest_csum", VirtIONet, host_features, + VIRTIO_NET_F_GUEST_CSUM, true), + DEFINE_VIRTIO_FEATURE_BIT_NEGOTIATED("mtu", + VIRTIO_NET_F_MTU), + DEFINE_VIRTIO_FEATURE_BIT_NEGOTIATED("mac", + VIRTIO_NET_F_MAC), + DEFINE_VIRTIO_FEATURE_BIT("gso", VirtIONet, host_features, + VIRTIO_NET_F_GSO, true), + DEFINE_VIRTIO_FEATURE_BIT("guest_tso4", VirtIONet, host_features, + VIRTIO_NET_F_GUEST_TSO4, true), + DEFINE_VIRTIO_FEATURE_BIT("guest_tso6", VirtIONet, host_features, + VIRTIO_NET_F_GUEST_TSO6, true), + DEFINE_VIRTIO_FEATURE_BIT("guest_ecn", VirtIONet, host_features, + VIRTIO_NET_F_GUEST_ECN, true), + DEFINE_VIRTIO_FEATURE_BIT("guest_ufo", VirtIONet, host_features, + VIRTIO_NET_F_GUEST_UFO, true), + DEFINE_VIRTIO_FEATURE_BIT("guest_announce", VirtIONet, host_features, + VIRTIO_NET_F_GUEST_ANNOUNCE, true), + DEFINE_VIRTIO_FEATURE_BIT("host_tso4", VirtIONet, host_features, + VIRTIO_NET_F_HOST_TSO4, true), + DEFINE_VIRTIO_FEATURE_BIT("host_tso6", VirtIONet, host_features, + VIRTIO_NET_F_HOST_TSO6, true), + DEFINE_VIRTIO_FEATURE_BIT("host_ecn", VirtIONet, host_features, + VIRTIO_NET_F_HOST_ECN, true), + DEFINE_VIRTIO_FEATURE_BIT("host_ufo", VirtIONet, host_features, + VIRTIO_NET_F_HOST_UFO, true), + DEFINE_VIRTIO_FEATURE_BIT("mrg_rxbuf", VirtIONet, host_features, + VIRTIO_NET_F_MRG_RXBUF, true), + DEFINE_VIRTIO_FEATURE_BIT("status", VirtIONet, host_features, + VIRTIO_NET_F_STATUS, true), + DEFINE_VIRTIO_FEATURE_BIT("ctrl_vq", VirtIONet, host_features, + VIRTIO_NET_F_CTRL_VQ, true), + DEFINE_VIRTIO_FEATURE_BIT("ctrl_rx", VirtIONet, host_features, + VIRTIO_NET_F_CTRL_RX, true), + DEFINE_VIRTIO_FEATURE_BIT("ctrl_vlan", VirtIONet, host_features, + VIRTIO_NET_F_CTRL_VLAN, true), + DEFINE_VIRTIO_FEATURE_BIT("ctrl_rx_extra", VirtIONet, host_features, + VIRTIO_NET_F_CTRL_RX_EXTRA, true), + DEFINE_VIRTIO_FEATURE_BIT("ctrl_mac_addr", VirtIONet, host_features, + VIRTIO_NET_F_CTRL_MAC_ADDR, true), + DEFINE_VIRTIO_FEATURE_BIT("ctrl_guest_offloads", VirtIONet, host_features, + VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, true), + DEFINE_VIRTIO_FEATURE_BIT("mq", VirtIONet, host_features, + VIRTIO_NET_F_MQ, false), + DEFINE_VIRTIO_FEATURE_BIT_NEGOTIATED("speed_duplex", + VIRTIO_NET_F_SPEED_DUPLEX), DEFINE_NIC_PROPERTIES(VirtIONet, nic_conf), DEFINE_PROP_UINT32("x-txtimer", VirtIONet, net_conf.txtimer, TX_TIMER_INTERVAL), diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 3aa99717e2..6272faa180 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -923,9 +923,9 @@ static Property virtio_scsi_properties[] = { 0xFFFF), DEFINE_PROP_UINT32("cmd_per_lun", VirtIOSCSI, parent_obj.conf.cmd_per_lun, 128), - DEFINE_PROP_BIT("hotplug", VirtIOSCSI, host_features, + DEFINE_VIRTIO_FEATURE_BIT("hotplug", VirtIOSCSI, host_features, VIRTIO_SCSI_F_HOTPLUG, true), - DEFINE_PROP_BIT("param_change", VirtIOSCSI, host_features, + DEFINE_VIRTIO_FEATURE_BIT("param_change", VirtIOSCSI, host_features, VIRTIO_SCSI_F_CHANGE, true), DEFINE_PROP_LINK("iothread", VirtIOSCSI, parent_obj.conf.iothread, TYPE_IOTHREAD, IOThread *), diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 99d396c516..2020327eb8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2601,16 +2601,16 @@ static void virtio_device_instance_finalize(Object *obj) } static Property virtio_properties[] = { - DEFINE_PROP_BIT64("indirect_desc", VirtIODevice, host_features, - VIRTIO_RING_F_INDIRECT_DESC, true), - DEFINE_PROP_BIT64("event_idx", VirtIODevice, host_features, - VIRTIO_RING_F_EVENT_IDX, true), - DEFINE_PROP_BIT64("notify_on_empty", VirtIODevice, host_features, - VIRTIO_F_NOTIFY_ON_EMPTY, true), - DEFINE_PROP_BIT64("any_layout", VirtIODevice, host_features, - VIRTIO_F_ANY_LAYOUT, true), - DEFINE_PROP_BIT64("iommu_platform", VirtIODevice, host_features, - VIRTIO_F_IOMMU_PLATFORM, false), + DEFINE_VIRTIO_FEATURE_BIT("indirect_desc", VirtIODevice, host_features, + VIRTIO_RING_F_INDIRECT_DESC, true), + DEFINE_VIRTIO_FEATURE_BIT("event_idx", VirtIODevice, host_features, + VIRTIO_RING_F_EVENT_IDX, true), + DEFINE_VIRTIO_FEATURE_BIT("notify_on_empty", VirtIODevice, host_features, + VIRTIO_F_NOTIFY_ON_EMPTY, true), + DEFINE_VIRTIO_FEATURE_BIT("any_layout", VirtIODevice, host_features, + VIRTIO_F_ANY_LAYOUT, true), + DEFINE_VIRTIO_FEATURE_BIT("iommu_platform", VirtIODevice, host_features, + VIRTIO_F_IOMMU_PLATFORM, false), DEFINE_PROP_END_OF_LIST(), };