From: Roman Kagan <rkagan@virtuozzo.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "Amit Shah" <amit@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Fam Zheng" <fam@euphon.net>,
"Markus Armbruster" <armbru@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [RFC PATCH 3/5] qdev-properties: add r/o 64bit bitfield property
Date: Fri, 14 Dec 2018 16:57:08 +0000 [thread overview]
Message-ID: <20181214165657.749-4-rkagan@virtuozzo.com> (raw)
In-Reply-To: <20181214165657.749-1-rkagan@virtuozzo.com>
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 <rkagan@virtuozzo.com>
---
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,
--
2.19.2
next prev parent reply other threads:[~2018-12-14 16:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-14 16:57 [Qemu-devel] [RFC PATCH 0/5] expose negotiated virtio features in r/o properties Roman Kagan
2018-12-14 16:57 ` [Qemu-devel] [RFC PATCH 1/5] qom: preserve get/set presence in aliased properties Roman Kagan
2018-12-14 16:57 ` [Qemu-devel] [RFC PATCH 2/5] qmp: further consolidate listing of device and object properties Roman Kagan
2018-12-14 16:57 ` Roman Kagan [this message]
2018-12-14 16:57 ` [Qemu-devel] [RFC PATCH 4/5] virtio: drop DEFINE_VIRTIO_COMMON_FEATURES Roman Kagan
2018-12-14 16:57 ` [Qemu-devel] [RFC PATCH 5/5] virtio: expose negotiated features in r/o properties Roman Kagan
2018-12-23 11:05 ` [Qemu-devel] [RFC PATCH 0/5] expose negotiated virtio " no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181214165657.749-4-rkagan@virtuozzo.com \
--to=rkagan@virtuozzo.com \
--cc=afaerber@suse.de \
--cc=amit@kernel.org \
--cc=armbru@redhat.com \
--cc=fam@euphon.net \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).