Re: [PATCH 13/17] rust/vmstate: Support vmstate_validate

2025-03-18 Thread Paolo Bonzini
Il mar 18 mar 2025, 07:16 Zhao Liu ha scritto: > > Would it be possible, or make sense, to move most of the code for > > field_exists inside .with_exist_check()? > > > > If so, the method would be like: > > pub fn with_exist_check( > mut self, > _cb: F > ) -> Self >

Re: [PATCH 13/17] rust/vmstate: Support vmstate_validate

2025-03-18 Thread Zhao Liu
> For now I would leave out a generic field-exists check, and keep the > implementation of vmstate_validate as you did it in v1. > > Once we look more in the builder concept we can think of adding also a > VMStateField (with a PhantomData bool> inside) and add > with_field_exists(). This makes se

Re: [PATCH 13/17] rust/vmstate: Support vmstate_validate

2025-03-17 Thread Zhao Liu
> > +#[doc(alias = "VMSTATE_VALIDATE")] > > +#[macro_export] > > +macro_rules! vmstate_validate { > > +($struct_name:ty, $test_name:expr, $test_fn:expr $(,)?) => { > > +$crate::bindings::VMStateField { > > +name: ::std::ffi::CStr::as_ptr($test_name), > > +// TODO

Re: [PATCH 13/17] rust/vmstate: Support vmstate_validate

2025-03-17 Thread Paolo Bonzini
On Mon, Mar 17, 2025 at 3:52 PM Zhao Liu wrote: > > In C version, VMSTATE_VALIDATE accepts the function pointer, which is > used to check if some conditions of structure could meet, although the > C version macro doesn't accept any structure as the opaque type. > > But it's hard to integrate VMSTA