@@ -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), \
@@ -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,
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(-)