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,