From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: Zhao Liu <zhao1.liu@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org, qemu-rust@nongnu.org
Subject: Re: [PATCH 11/12] rust/hpet: Convert qdev properties to #property macro
Date: Tue, 16 Sep 2025 13:19:05 +0300 [thread overview]
Message-ID: <CAAjaMXYSjbN-0b0jHVHqbBjsTEmTzWCOT2Tr7C_D4CdWHH8OfQ@mail.gmail.com> (raw)
In-Reply-To: <20250916085557.2008344-12-zhao1.liu@intel.com>
On Tue, Sep 16, 2025 at 11:34 AM Zhao Liu <zhao1.liu@intel.com> wrote:
>
> Convert HPET's properties to #property macro:
> * num_timers: usize property.
> * flags: u32 bit property.
> * int_route_cap: u32 property.
> * hpet_offset_saved: bool property.
>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> rust/hw/timer/hpet/src/device.rs | 55 ++++----------------------------
> 1 file changed, 7 insertions(+), 48 deletions(-)
>
> diff --git a/rust/hw/timer/hpet/src/device.rs b/rust/hw/timer/hpet/src/device.rs
> index fce75415579d..86638c076666 100644
> --- a/rust/hw/timer/hpet/src/device.rs
> +++ b/rust/hw/timer/hpet/src/device.rs
> @@ -13,9 +13,8 @@
> use bql::{BqlCell, BqlRefCell};
> use common::{bitops::IntegerExt, uninit_field_mut};
> use hwcore::{
> - bindings::{qdev_prop_bit, qdev_prop_bool, qdev_prop_uint32, qdev_prop_usize},
> - declare_properties, define_property, DeviceImpl, DeviceMethods, DeviceState, InterruptSource,
> - Property, ResetType, ResettablePhasesImpl, SysBusDevice, SysBusDeviceImpl, SysBusDeviceMethods,
> + DeviceImpl, DeviceMethods, DeviceState, InterruptSource, ResetType, ResettablePhasesImpl,
> + SysBusDevice, SysBusDeviceImpl, SysBusDeviceMethods,
> };
> use migration::{
> self, impl_vmstate_struct, vmstate_fields, vmstate_of, vmstate_subsections, vmstate_validate,
> @@ -520,7 +519,7 @@ fn write(&mut self, reg: TimerRegister, value: u64, shift: u32, len: u32) {
>
> /// HPET Event Timer Block Abstraction
> #[repr(C)]
> -#[derive(qom::Object)]
> +#[derive(qom::Object, hwcore::Device)]
> pub struct HPETState {
> parent_obj: ParentField<SysBusDevice>,
> iomem: MemoryRegion,
> @@ -540,10 +539,12 @@ pub struct HPETState {
> // Internal state
> /// Capabilities that QEMU HPET supports.
> /// bit 0: MSI (or FSB) support.
> + #[property(rename = "msi", bit = HPET_FLAG_MSI_SUPPORT_SHIFT as u8, default = false)]
> flags: u32,
>
> /// Offset of main counter relative to qemu clock.
> hpet_offset: BqlCell<u64>,
> + #[property(rename = "hpet-offset-saved", default = true)]
> hpet_offset_saved: bool,
>
> irqs: [InterruptSource; HPET_NUM_IRQ_ROUTES],
> @@ -555,11 +556,13 @@ pub struct HPETState {
> /// the timers' interrupt can be routed, and is encoded in the
> /// bits 32:64 of timer N's config register:
> #[doc(alias = "intcap")]
> + #[property(rename = "hpet-intcap", default = 0)]
> int_route_cap: u32,
>
> /// HPET timer array managed by this timer block.
> #[doc(alias = "timer")]
> timers: [BqlRefCell<HPETTimer>; HPET_MAX_TIMERS],
> + #[property(rename = "timers", default = HPET_MIN_TIMERS)]
> num_timers: usize,
> num_timers_save: BqlCell<u8>,
>
> @@ -901,44 +904,6 @@ impl ObjectImpl for HPETState {
> const CLASS_INIT: fn(&mut Self::Class) = Self::Class::class_init::<Self>;
> }
>
> -// TODO: Make these properties user-configurable!
> -declare_properties! {
> - HPET_PROPERTIES,
> - define_property!(
> - c"timers",
> - HPETState,
> - num_timers,
> - unsafe { &qdev_prop_usize },
> - usize,
> - default = HPET_MIN_TIMERS
> - ),
> - define_property!(
> - c"msi",
> - HPETState,
> - flags,
> - unsafe { &qdev_prop_bit },
> - u32,
> - bit = HPET_FLAG_MSI_SUPPORT_SHIFT as u8,
> - default = false,
> - ),
> - define_property!(
> - c"hpet-intcap",
> - HPETState,
> - int_route_cap,
> - unsafe { &qdev_prop_uint32 },
> - u32,
> - default = 0
> - ),
> - define_property!(
> - c"hpet-offset-saved",
> - HPETState,
> - hpet_offset_saved,
> - unsafe { &qdev_prop_bool },
> - bool,
> - default = true
> - ),
> -}
> -
> static VMSTATE_HPET_RTC_IRQ_LEVEL: VMStateDescription<HPETState> =
> VMStateDescriptionBuilder::<HPETState>::new()
> .name(c"hpet/rtc_irq_level")
> @@ -1001,12 +966,6 @@ impl ObjectImpl for HPETState {
> ))
> .build();
>
> -// SAFETY: HPET_PROPERTIES is a valid Property array constructed with the
> -// hwcore::declare_properties macro.
> -unsafe impl hwcore::DevicePropertiesImpl for HPETState {
> - const PROPERTIES: &'static [Property] = &HPET_PROPERTIES;
> -}
> -
> impl DeviceImpl for HPETState {
> const VMSTATE: Option<VMStateDescription<Self>> = Some(VMSTATE_HPET);
> const REALIZE: Option<fn(&Self) -> util::Result<()>> = Some(Self::realize);
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-09-16 10:19 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 8:55 [PATCH 00/12] rust: miscellaneous cleanup & HPET #property conversion Zhao Liu
2025-09-16 8:55 ` [PATCH 01/12] subprojects: Update .gitignore for proc-macro2 and syn Zhao Liu
2025-09-16 9:58 ` Manos Pitsidianakis
2025-09-17 6:43 ` Zhao Liu
2025-09-16 8:55 ` [PATCH 02/12] subprojects: Ignore .wraplock file generated by meson v1.9.0 Zhao Liu
2025-09-16 9:59 ` Manos Pitsidianakis
2025-09-16 8:55 ` [PATCH 03/12] rust/qemu-macros: Fix Clippy's complaints about lambda parameter naming Zhao Liu
2025-09-16 10:00 ` Manos Pitsidianakis
2025-09-16 8:55 ` [PATCH 04/12] rust/common/uninit: Fix Clippy's complaints about lifetime Zhao Liu
2025-09-16 10:00 ` Manos Pitsidianakis
2025-09-16 8:55 ` [PATCH 05/12] rust/qdev: use addr_of! in QDevProp Zhao Liu
2025-09-16 8:55 ` [PATCH 06/12] rust/qdev: Refine the documentation for QDevProp trait Zhao Liu
2025-09-16 8:55 ` [PATCH 07/12] rust/qdev: Rename PropertyInfo field from VALUE to BASE_INFO Zhao Liu
2025-09-16 10:10 ` Manos Pitsidianakis
2025-09-17 6:46 ` Zhao Liu
2025-09-16 8:55 ` [PATCH 08/12] rust/qdev: Support property info for more common types Zhao Liu
2025-09-16 10:13 ` Manos Pitsidianakis
2025-09-17 7:13 ` Zhao Liu
2025-09-16 8:55 ` [PATCH 09/12] rust/qdev: Support bit property in #property macro Zhao Liu
2025-09-16 10:16 ` Manos Pitsidianakis
2025-09-17 7:25 ` Zhao Liu
2025-09-17 11:40 ` Paolo Bonzini
2025-09-17 9:14 ` Paolo Bonzini
2025-09-16 8:55 ` [PATCH 10/12] rust/hpet: Clean up type mismatch for num_timers property Zhao Liu
2025-09-16 8:55 ` [PATCH 11/12] rust/hpet: Convert qdev properties to #property macro Zhao Liu
2025-09-16 10:19 ` Manos Pitsidianakis [this message]
2025-09-16 8:55 ` [PATCH 12/12] rust/qdev: Drop declare_properties & define_property macros Zhao Liu
2025-09-16 10:19 ` Manos Pitsidianakis
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=CAAjaMXYSjbN-0b0jHVHqbBjsTEmTzWCOT2Tr7C_D4CdWHH8OfQ@mail.gmail.com \
--to=manos.pitsidianakis@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
--cc=zhao1.liu@intel.com \
/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).