Skip to content

Commit 7bda68e

Browse files
committed
qdev, rust/hpet: fix type of HPET "timers" property
Signed-off-by: Paolo Bonzini <[email protected]>
1 parent d136834 commit 7bda68e

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

hw/core/qdev-properties.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,43 @@ const PropertyInfo qdev_prop_uint64_checkmask = {
442442
.set = set_uint64_checkmask,
443443
};
444444

445+
/* --- pointer-size integer --- */
446+
447+
static void get_usize(Object *obj, Visitor *v, const char *name, void *opaque,
448+
Error **errp)
449+
{
450+
const Property *prop = opaque;
451+
452+
#if HOST_LONG_BITS == 32
453+
uint32_t *ptr = object_field_prop_ptr(obj, prop);
454+
visit_type_uint32(v, name, ptr, errp);
455+
#else
456+
uint64_t *ptr = object_field_prop_ptr(obj, prop);
457+
visit_type_uint64(v, name, ptr, errp);
458+
#endif
459+
}
460+
461+
static void set_usize(Object *obj, Visitor *v, const char *name, void *opaque,
462+
Error **errp)
463+
{
464+
const Property *prop = opaque;
465+
466+
#if HOST_LONG_BITS == 32
467+
uint32_t *ptr = object_field_prop_ptr(obj, prop);
468+
visit_type_uint32(v, name, ptr, errp);
469+
#else
470+
uint64_t *ptr = object_field_prop_ptr(obj, prop);
471+
visit_type_uint64(v, name, ptr, errp);
472+
#endif
473+
}
474+
475+
const PropertyInfo qdev_prop_usize = {
476+
.type = "usize",
477+
.get = get_usize,
478+
.set = set_usize,
479+
.set_default_value = qdev_propinfo_set_default_value_uint,
480+
};
481+
445482
/* --- string --- */
446483

447484
static void release_string(Object *obj, const char *name, void *opaque)

include/hw/qdev-properties.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ extern const PropertyInfo qdev_prop_bool;
5252
extern const PropertyInfo qdev_prop_uint8;
5353
extern const PropertyInfo qdev_prop_uint16;
5454
extern const PropertyInfo qdev_prop_uint32;
55+
extern const PropertyInfo qdev_prop_usize;
5556
extern const PropertyInfo qdev_prop_int32;
5657
extern const PropertyInfo qdev_prop_uint64;
5758
extern const PropertyInfo qdev_prop_uint64_checkmask;

rust/hw/timer/hpet/src/hpet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::{
1212
use qemu_api::{
1313
bindings::{
1414
address_space_memory, address_space_stl_le, qdev_prop_bit, qdev_prop_bool,
15-
qdev_prop_uint32, qdev_prop_uint8,
15+
qdev_prop_uint32, qdev_prop_usize,
1616
},
1717
c_str,
1818
cell::{BqlCell, BqlRefCell},
@@ -859,8 +859,8 @@ qemu_api::declare_properties! {
859859
c_str!("timers"),
860860
HPETState,
861861
num_timers,
862-
unsafe { &qdev_prop_uint8 },
863-
u8,
862+
unsafe { &qdev_prop_usize },
863+
usize,
864864
default = HPET_MIN_TIMERS
865865
),
866866
qemu_api::define_property!(

0 commit comments

Comments
 (0)