]> git.ipfire.org Git - thirdparty/qemu.git/commit
rust/vmstate: Add support for field_exists checks
authorZhao Liu <zhao1.liu@intel.com>
Mon, 14 Apr 2025 14:49:35 +0000 (22:49 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 2 May 2025 15:37:46 +0000 (17:37 +0200)
commit6f8e6aed81277ec14d5a5dcafdd00dadf7ac465c
treec2b21b2a6923c2db3e2d04476eca7bc0920022ee
parent5134cf9b5d3aee4475fe7e1c1c11b093731073cf
rust/vmstate: Add support for field_exists checks

Unfortunately, at present it's not possible to have a const
"with_exist_check" method to append test_fn after vmstate_struct (due
to error on "constant functions cannot evaluate destructors" for `F`).

Before the vmstate builder, the only way to support "test_fn" is to
extend vmstate_struct macro to add the such new optional member (and
fortunately, Rust can still parse the current expansion!).

Abstract the previous callback implementation of vmstate_validate into
a separate macro, and moves it before vmstate_struct for vmstate_struct
to call.

Note that there's no need to add any extra flag for a new test_fn added
in the VMStateField.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250414144943.1112885-2-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/qemu-api/src/vmstate.rs