On 1/8/25 04:28, Zhao Liu wrote:
+ #[must_use]
+ pub const fn with_varray_flag<T: VMState>(mut self, flag: VMStateFlags) ->
VMStateField {
+ assert!((self.flags.0 & VMStateFlags::VMS_ARRAY.0) != 0);
I understand you checked VMS_ARRAY here since [T; N] has this array
flag.
What if a Rust device just store a pointer to the array? If we allow
this use, then it seems also possible to set varray flags...Then what
about dropping this limitation?
Box can be added for that purpose:
impl_vmstate_pointer!(Box<T> where T: VMState);
Also I need to drop Option<NonNull<>> because of
if (field->flags & VMS_POINTER) {
first_elem = *(void **)first_elem;
assert(first_elem || !n_elems || !size);
}
in migration/vmstate.c.
However, I also doube that pointer usage is bad; we should always use
Vec.
Vec support is a bit tricky because the number of elements is not
accessible from C. But unbounded arrays are rare in devices. We can
think about it later.
Paolo