From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PATCH] qdev, rust/hpet: fix type of HPET "timers" property
Date: Thu, 20 Mar 2025 09:23:25 +0100 [thread overview]
Message-ID: <20250320082325.788273-1-pbonzini@redhat.com> (raw)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/hw/qdev-properties.h | 1 +
hw/core/qdev-properties.c | 35 ++++++++++++++++++++++++++++++++++
rust/hw/timer/hpet/src/hpet.rs | 6 +++---
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 15fcec5260c..2c99856caac 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -52,6 +52,7 @@ extern const PropertyInfo qdev_prop_bool;
extern const PropertyInfo qdev_prop_uint8;
extern const PropertyInfo qdev_prop_uint16;
extern const PropertyInfo qdev_prop_uint32;
+extern const PropertyInfo qdev_prop_usize;
extern const PropertyInfo qdev_prop_int32;
extern const PropertyInfo qdev_prop_uint64;
extern const PropertyInfo qdev_prop_uint64_checkmask;
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index c04df3b337a..dce323a0c90 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -442,6 +442,41 @@ const PropertyInfo qdev_prop_uint64_checkmask = {
.set = set_uint64_checkmask,
};
+/* --- pointer-size integer --- */
+
+static void get_usize(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
+{
+ const Property *prop = opaque;
+ size_t *ptr = object_field_prop_ptr(obj, prop);
+
+#if HOST_LONG_BITS == 32
+ visit_type_uint32(v, name, ptr, errp);
+#else
+ visit_type_uint64(v, name, ptr, errp);
+#endif
+}
+
+static void set_usize(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
+{
+ const Property *prop = opaque;
+ size_t *ptr = object_field_prop_ptr(obj, prop);
+
+#if HOST_LONG_BITS == 32
+ visit_type_uint32(v, name, ptr, errp);
+#else
+ visit_type_uint64(v, name, ptr, errp);
+#endif
+}
+
+const PropertyInfo qdev_prop_usize = {
+ .type = "usize",
+ .get = get_usize,
+ .set = set_usize,
+ .set_default_value = qdev_propinfo_set_default_value_uint,
+};
+
/* --- string --- */
static void release_string(Object *obj, const char *name, void *opaque)
diff --git a/rust/hw/timer/hpet/src/hpet.rs b/rust/hw/timer/hpet/src/hpet.rs
index 20e0afdfca8..63c1971f0b5 100644
--- a/rust/hw/timer/hpet/src/hpet.rs
+++ b/rust/hw/timer/hpet/src/hpet.rs
@@ -12,7 +12,7 @@
use qemu_api::{
bindings::{
address_space_memory, address_space_stl_le, qdev_prop_bit, qdev_prop_bool,
- qdev_prop_uint32, qdev_prop_uint8,
+ qdev_prop_uint32, qdev_prop_usize,
},
c_str,
cell::{BqlCell, BqlRefCell},
@@ -859,8 +859,8 @@ impl ObjectImpl for HPETState {
c_str!("timers"),
HPETState,
num_timers,
- unsafe { &qdev_prop_uint8 },
- u8,
+ unsafe { &qdev_prop_usize },
+ usize,
default = HPET_MIN_TIMERS
),
qemu_api::define_property!(
--
2.48.1
reply other threads:[~2025-03-20 8:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250320082325.788273-1-pbonzini@redhat.com \
--to=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).