rust: pl011: fix migration stream
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 10 Dec 2024 11:53:22 +0000 (12:53 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 19 Dec 2024 18:36:38 +0000 (19:36 +0100)
commit6b4f7b0705be31c7df6ea01c81a42a42950959a9
tree062f78bf7a7dbeae50556c9facacedc368b91b07
parente2e0828e0f25042a09b1cbada41a436d1258fdb8
rust: pl011: fix migration stream

The Rust vmstate macros lack the type-safety of their C equivalents (so
safe, much abstraction), and therefore they were predictably wrong.

The registers have already been changed to 32-bits in the previous patch,
but read_pos/read_count/read_trigger also have to be u32 instead of usize.
The easiest way to do so is to let the FIFO use u32 indices instead
of usize.

My plan for making VMStateField typesafe is to have a trait to retrieve
a basic VMStateField; for example something like vmstate_uint32 would
become an implementation of the VMState trait on u32.  Then you'd write
something like "vmstate_of!(Type, field).with_version_id(2)".  That is,
vmstate_of retrieves the basic VMStateField and fills in the offset,
and then more changes can be applied on top.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/hw/char/pl011/src/device.rs
rust/hw/char/pl011/src/device_class.rs
rust/qemu-api/src/vmstate.rs