From: Zhao Liu <zhao1.liu@intel.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
Fabiano Rosas <farosas@suse.de>,
Manos Pitsidianakis <manos.pitsidianakis@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
qemu-rust@nongnu.org, Zhao Liu <zhao1.liu@intel.com>
Subject: Re: [PATCH for-12.0 5/6] rust: Replace vmstate_validate with post_load
Date: Fri, 20 Nov 2026 22:25:23 +0800 [thread overview]
Message-ID: <awBYUwFhba1AYpZb@intel.com> (raw)
In-Reply-To: <20261120124923.1656220-6-peterx@redhat.com>
Hi Peter,
On Fri, Nov 20, 2026 at 07:49:22AM -0500, Peter Xu wrote:
> Date: Fri, 20 Nov 2026 07:49:22 -0500
> From: Peter Xu <peterx@redhat.com>
> Subject: [PATCH for-12.0 5/6] rust: Replace vmstate_validate with post_load
> X-Mailer: git-send-email 2.56.0
>
> We dropped all of that in C, drop that in Rust too.
but rust is using the different way to address this case :)
> The goal is to remove
> the VMSTATE_VALIDATE() together with VMS_MUST_EXIST.
>
> Use post_load instead for the check.
...
> // HPETRegistersMigration is generated by ToMigrationState macro.
> impl_vmstate_struct!(
> HPETRegistersMigration,
> @@ -1109,7 +1111,6 @@ fn restore_migrated_state(
> .fields(vmstate_fields! {
> vmstate_of!(HPETState, regs),
> vmstate_of!(HPETState, num_timers_save),
> - vmstate_validate!(HPETState, VALIDATE_TIMERS_NAME, HPETState::validate_num_timers),
> vmstate_of!(HPETState, timers[0 .. num_timers_save], HPETState::validate_num_timers).with_version_id(0),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Before this patch, the test method didn't work since vmstate_validate!
has already done the check. But, IIUC, when vmstate_validate! goes away,
this test seems necessary for rust side since it can help avoid overflow
caused by num_timers_save (maybe it can be greater than HPET_MAX_TIMERS?
before the commit 7be175e65f07).
> })
So LGTM for the change in rust hpet,
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
And I find C side (in patch 3) handles this differently via using the local
"num_timers".
In this case, I think we still have the option to keep the logic
consistent between C and Rust :). We can add VMSTATE_STRUCT_VARRAY_TEST
for C side:
#define VMSTATE_STRUCT_VARRAY_TEST(_field, _state, _field_num, _test,\
_version, _vmsd, _type) {\
.name = (stringify(_field)),\
.num_indirect = vmstate_field_offset(_state, _field_num),\
.version_id = (_version),\
.field_exists = (_test),\
.vmsd = &(_vmsd),\
.size = sizeof(_type),\
.flags = VMS_STRUCT | VMS_VARRAY,\
.offset = vmstate_offset_varray(_state, _field, _type),\
}
and make C hpet use this:
VMSTATE_STRUCT_VARRAY_TEST(timer, HPETState, num_timers_save,
hpet_validate_num_timers, 0,
vmstate_hpet_timer, HPETTimer),
Alternatively, we can also have Rust use num_timers (as u8) for timers
array VMState, but this will bring back the conversion issue between u8
and usize, which is the commit b3bf86b8936d & 6e85cfe44c0e want to fix...
Thanks,
Zhao
next prev parent reply other threads:[~2026-11-20 14:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 12:49 [PATCH for-12.0 0/6] migration: Remove VMSTATE_VALIDATE() and VMS_MUST_EXIST Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 1/6] pcie/aer: Remove the usage of VMSTATE_VALIDATE() Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 2/6] hw/gpio/zaurus: Move VMSTATE_VALIDATE() check into post_load_errp() Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 3/6] hpet: Move VMSTATE_VALIDATE() check into post_load Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 4/6] arm/machine: Move all VMSTATE_VALIDATE() usages " Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 5/6] rust: Replace vmstate_validate with post_load Peter Xu
2026-11-20 14:25 ` Zhao Liu [this message]
2026-11-20 12:49 ` [PATCH for-12.0 6/6] migration: Drop VMSTATE_VALIDATE() and VMS_MUST_EXIST Peter Xu
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=awBYUwFhba1AYpZb@intel.com \
--to=zhao1.liu@intel.com \
--cc=farosas@suse.de \
--cc=manos.pitsidianakis@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.