From: Fabiano Rosas <farosas@suse.de>
To: qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
Alexandr Moshkov <dtalexundeer@yandex-team.ru>,
"Michael S . Tsirkin" <mst@redhat.com>,
Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Subject: [PATCH v2 3/8] migration: Remove redundant flags
Date: Tue, 18 Aug 2026 15:24:36 -0300 [thread overview]
Message-ID: <20260818182441.404790-4-farosas@suse.de> (raw)
In-Reply-To: <20260818182441.404790-1-farosas@suse.de>
Remove the VMS_VARRAY and VMS_VBUFFER flags that became redundant due
to the previous commit which stores the size of the vmstate offset
variables along with the offset itself.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
include/migration/vmstate.h | 74 +++++++++++-------------------
migration/savevm.c | 6 +--
migration/vmstate.c | 3 +-
rust/bindings/migration-sys/lib.rs | 7 +--
rust/migration/src/vmstate.rs | 6 +--
rust/tests/tests/vmstate_tests.rs | 4 +-
6 files changed, 37 insertions(+), 63 deletions(-)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 12bfa64fb92..a168651a062 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -69,8 +69,9 @@ enum VMStateFlags {
* }). Dereference the pointer before using it as basis for
* further pointer arithmetic (see e.g. VMS_ARRAY). Does not
* affect the meaning of VMStateField.num_indirect or
- * VMStateField.size_indirect; see VMS_VARRAY* and VMS_VBUFFER for
- * those. */
+ * VMStateField.size_indirect; see VMS_VARRAY and VMS_VBUFFER for
+ * those.
+ */
VMS_POINTER = 0x002,
/* The field is an array of fixed size. VMStateField.num contains
@@ -80,12 +81,13 @@ enum VMStateFlags {
* VMS_MULTIPLY. Each array entry will be processed individually
* (VMStateField.info.get()/put() if VMS_STRUCT is not set,
* recursion into VMStateField.vmsd if VMS_STRUCT is set). May not
- * be combined with VMS_VARRAY*. */
+ * be combined with VMS_VARRAY.
+ */
VMS_ARRAY = 0x004,
/* The field is itself a struct, containing one or more
* fields. Recurse into VMStateField.vmsd. Most useful in
- * combination with VMS_ARRAY / VMS_VARRAY*, recursing into each
+ * combination with VMS_ARRAY / VMS_VARRAY, recursing into each
* array entry. */
VMS_STRUCT = 0x008,
@@ -93,9 +95,9 @@ enum VMStateFlags {
* The field is an array of variable size. The integer at opaque +
* VMStateField.num_indirect contains the number of entries in the
* array. See the VMS_ARRAY description regarding array handling
- * in general. May not be combined with VMS_ARRAY or any other
- * VMS_VARRAY*. */
- VMS_VARRAY_INT32 = 0x010,
+ * in general. May not be combined with VMS_ARRAY.
+ */
+ VMS_VARRAY = 0x010,
/* Ignored */
VMS_BUFFER = 0x020,
@@ -103,18 +105,12 @@ enum VMStateFlags {
/* The field is a (fixed-size or variable-size) array of pointers
* (e.g. struct a { uint8_t *b[]; }). Dereference each array entry
* before using it. Note: Does not imply any one of VMS_ARRAY /
- * VMS_VARRAY*; these need to be set explicitly. */
+ * VMS_VARRAY; these need to be set explicitly.
+ */
VMS_ARRAY_OF_POINTER = 0x040,
- /* The field is an array of variable size. The uint16_t at opaque
- * + VMStateField.num_indirect
- * contains the number of entries in the array. See the VMS_ARRAY
- * description regarding array handling in general. May not be
- * combined with VMS_ARRAY or any other VMS_VARRAY*. */
- VMS_VARRAY_UINT16 = 0x080,
-
/* The size of the individual entries (a single array entry if
- * VMS_ARRAY or any of VMS_VARRAY* are set, or the field itself if
+ * VMS_ARRAY or VMS_VARRAY are set, or the field itself if
* neither is set) is variable (i.e. not known at compile-time),
* but the same for all entries. Use the integer at opaque +
* VMStateField.size_indirect (subject to VMS_MULTIPLY) to determine
@@ -128,20 +124,6 @@ enum VMStateFlags {
* allocated. Only valid in combination with VMS_VBUFFER. */
VMS_MULTIPLY = 0x200,
- /* The field is an array of variable size. The uint8_t at opaque +
- * VMStateField.num_indirect
- * contains the number of entries in the array. See the VMS_ARRAY
- * description regarding array handling in general. May not be
- * combined with VMS_ARRAY or any other VMS_VARRAY*. */
- VMS_VARRAY_UINT8 = 0x400,
-
- /* The field is an array of variable size. The uint32_t at opaque
- * + VMStateField.num_indirect
- * contains the number of entries in the array. See the VMS_ARRAY
- * description regarding array handling in general. May not be
- * combined with VMS_ARRAY or any other VMS_VARRAY*. */
- VMS_VARRAY_UINT32 = 0x800,
-
/* Fail loading the serialised VM state if this field is missing
* from the input. */
VMS_MUST_EXIST = 0x1000,
@@ -530,7 +512,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.info = &(_info), \
.size = sizeof(_type), \
- .flags = VMS_VARRAY_INT32|VMS_POINTER, \
+ .flags = VMS_VARRAY | VMS_POINTER, \
.offset = vmstate_offset_pointer(_state, _field, _type), \
}
@@ -540,7 +522,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.info = &(_info), \
.size = sizeof(_type), \
- .flags = VMS_VARRAY_UINT32|VMS_POINTER, \
+ .flags = VMS_VARRAY | VMS_POINTER, \
.offset = vmstate_offset_pointer(_state, _field, _type), \
}
@@ -550,7 +532,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.info = &(_info), \
.size = sizeof(_type), \
- .flags = VMS_VARRAY_INT32 | VMS_POINTER | VMS_ALLOC, \
+ .flags = VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \
.offset = vmstate_offset_pointer(_state, _field, _type), \
}
@@ -560,7 +542,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.info = &(_info), \
.size = sizeof(_type), \
- .flags = VMS_VARRAY_UINT32|VMS_POINTER|VMS_ALLOC, \
+ .flags = VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \
.offset = vmstate_offset_pointer(_state, _field, _type), \
}
@@ -570,7 +552,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.info = &(_info), \
.size = sizeof(_type), \
- .flags = VMS_VARRAY_UINT16 | VMS_POINTER | VMS_ALLOC, \
+ .flags = VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \
.offset = vmstate_offset_pointer(_state, _field, _type), \
}
@@ -580,7 +562,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.info = &(_info), \
.size = sizeof(_type), \
- .flags = VMS_VARRAY_UINT16, \
+ .flags = VMS_VARRAY, \
.offset = vmstate_offset_varray(_state, _field, _type), \
}
@@ -659,7 +641,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.vmsd = &(_vmsd), \
.size = sizeof(_type), \
- .flags = VMS_POINTER | VMS_VARRAY_UINT8 | \
+ .flags = VMS_POINTER | VMS_VARRAY | \
VMS_ARRAY_OF_POINTER | VMS_STRUCT | \
VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \
.offset = vmstate_offset_pointer(_state, _field, _type *), \
@@ -672,7 +654,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.vmsd = &(_vmsd), \
.size = sizeof(_type), \
- .flags = VMS_POINTER | VMS_VARRAY_UINT32 | \
+ .flags = VMS_POINTER | VMS_VARRAY | \
VMS_ARRAY_OF_POINTER | VMS_STRUCT | \
VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \
.offset = vmstate_offset_pointer(_state, _field, _type *), \
@@ -683,7 +665,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.version_id = (_version), \
.num_indirect = vmstate_field_offset(_state, _field_num), \
.info = &(_info), \
- .flags = VMS_VARRAY_UINT32 | VMS_ARRAY_OF_POINTER | VMS_POINTER, \
+ .flags = VMS_VARRAY | VMS_ARRAY_OF_POINTER | VMS_POINTER, \
.offset = vmstate_offset_pointer(_state, _field, _type *), \
}
@@ -727,7 +709,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.version_id = (_version), \
.vmsd = &(_vmsd), \
.size = sizeof(_type), \
- .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \
+ .flags = VMS_STRUCT | VMS_VARRAY, \
.offset = vmstate_offset_varray(_state, _field, _type), \
}
@@ -750,7 +732,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.size = sizeof(_type), \
.vmsd = &(_vmsd), \
- .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
+ .flags = VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \
.offset = vmstate_offset_pointer(_state, _field, _type), \
}
@@ -760,7 +742,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.size = sizeof(_type), \
.vmsd = &(_vmsd), \
- .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
+ .flags = VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \
.offset = vmstate_offset_pointer(_state, _field, _type), \
}
@@ -770,7 +752,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.num_indirect = vmstate_field_offset(_state, _field_num), \
.size = sizeof(_type), \
.vmsd = &(_vmsd), \
- .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \
+ .flags = VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \
.offset = vmstate_offset_pointer(_state, _field, _type), \
}
@@ -780,7 +762,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.version_id = (_version), \
.vmsd = &(_vmsd), \
.size = sizeof(_type), \
- .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \
+ .flags = VMS_STRUCT | VMS_VARRAY, \
.offset = vmstate_offset_varray(_state, _field, _type), \
}
@@ -790,7 +772,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.vmsd = &(_vmsd), \
.num_indirect = vmstate_field_offset(_state, _field_num), \
.size = sizeof(_type), \
- .flags = VMS_STRUCT|VMS_VARRAY_INT32|VMS_ALLOC|VMS_POINTER, \
+ .flags = VMS_STRUCT | VMS_VARRAY | VMS_ALLOC | VMS_POINTER, \
.offset = vmstate_offset_pointer(_state, _field, _type), \
}
@@ -915,7 +897,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
.version_id = (_version), \
.size = (_size), \
.info = &vmstate_info_unused_buffer, \
- .flags = VMS_VARRAY_UINT32 | VMS_BUFFER, \
+ .flags = VMS_VARRAY | VMS_BUFFER, \
}
/* _field_size should be a int32_t field in the _state struct giving the
diff --git a/migration/savevm.c b/migration/savevm.c
index e1b707dda63..3e5cce6520d 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -884,11 +884,9 @@ static void vmstate_check(const VMStateDescription *vmsd)
}
/*
* VMS_ARRAY_OF_POINTER must be used only together with one
- * of VMS_(V)ARRAY* flags.
+ * of VMS_(V)ARRAY flags.
*/
- assert(field->flags & (VMS_ARRAY | VMS_VARRAY_INT32 |
- VMS_VARRAY_UINT16 | VMS_VARRAY_UINT8 |
- VMS_VARRAY_UINT32));
+ assert(field->flags & (VMS_ARRAY | VMS_VARRAY));
}
if (field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) {
diff --git a/migration/vmstate.c b/migration/vmstate.c
index 372aed258f1..bc5285bcea2 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -101,8 +101,7 @@ static uint64_t vmstate_n_elems(void *opaque, const VMStateField *field)
if (field->flags & VMS_ARRAY) {
n_elems = field->num;
- } else if (field->flags & (VMS_VARRAY_INT32 | VMS_VARRAY_UINT32
- | VMS_VARRAY_UINT16 | VMS_VARRAY_UINT8)) {
+ } else if (field->flags & VMS_VARRAY) {
n_elems = vmstate_read_from_offset(&field->num_indirect, opaque);
}
diff --git a/rust/bindings/migration-sys/lib.rs b/rust/bindings/migration-sys/lib.rs
index baa2730ca9d..c8397dc8974 100644
--- a/rust/bindings/migration-sys/lib.rs
+++ b/rust/bindings/migration-sys/lib.rs
@@ -57,12 +57,7 @@ pub trait VMStateFlagsExt {
}
impl VMStateFlagsExt for VMStateFlags {
- const VMS_VARRAY_FLAGS: VMStateFlags = VMStateFlags(
- VMStateFlags::VMS_VARRAY_INT32.0
- | VMStateFlags::VMS_VARRAY_UINT8.0
- | VMStateFlags::VMS_VARRAY_UINT16.0
- | VMStateFlags::VMS_VARRAY_UINT32.0,
- );
+ const VMS_VARRAY_FLAGS: VMStateFlags = VMStateFlags(VMStateFlags::VMS_VARRAY.0);
}
// Add a couple builder-style methods to VMStateField, allowing
diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs
index e60c0860cc5..4ec54097148 100644
--- a/rust/migration/src/vmstate.rs
+++ b/rust/migration/src/vmstate.rs
@@ -287,9 +287,9 @@ unsafe impl $crate::vmstate::VMState for $type {
impl_vmstate_scalar!(vmstate_info_int16, i16);
impl_vmstate_scalar!(vmstate_info_int32, i32);
impl_vmstate_scalar!(vmstate_info_int64, i64);
-impl_vmstate_scalar!(vmstate_info_uint8, u8, VMS_VARRAY_UINT8);
-impl_vmstate_scalar!(vmstate_info_uint16, u16, VMS_VARRAY_UINT16);
-impl_vmstate_scalar!(vmstate_info_uint32, u32, VMS_VARRAY_UINT32);
+impl_vmstate_scalar!(vmstate_info_uint8, u8, VMS_VARRAY);
+impl_vmstate_scalar!(vmstate_info_uint16, u16, VMS_VARRAY);
+impl_vmstate_scalar!(vmstate_info_uint32, u32, VMS_VARRAY);
impl_vmstate_scalar!(vmstate_info_uint64, u64);
impl_vmstate_scalar!(vmstate_info_timer, util::timer::Timer);
diff --git a/rust/tests/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_tests.rs
index c002ffb2bc4..5f6dd8ae7f1 100644
--- a/rust/tests/tests/vmstate_tests.rs
+++ b/rust/tests/tests/vmstate_tests.rs
@@ -113,7 +113,7 @@ fn test_vmstate_varray_uint16_unsafe() {
assert_eq!(foo_fields[2].version_id, 0);
assert_eq!(foo_fields[2].size, 1);
assert_eq!(foo_fields[2].num, 0);
- assert_eq!(foo_fields[2].flags, VMStateFlags::VMS_VARRAY_UINT16);
+ assert_eq!(foo_fields[2].flags, VMStateFlags::VMS_VARRAY);
assert!(foo_fields[2].vmsd.is_null());
assert!(foo_fields[2].field_exists.is_none());
}
@@ -222,7 +222,7 @@ fn test_vmstate_struct_varray_uint8() {
assert_eq!(foo_fields[2].num, 0);
assert_eq!(
foo_fields[2].flags.0,
- VMStateFlags::VMS_STRUCT.0 | VMStateFlags::VMS_VARRAY_UINT8.0
+ VMStateFlags::VMS_STRUCT.0 | VMStateFlags::VMS_VARRAY.0
);
assert_eq!(foo_fields[2].vmsd, VMSTATE_FOOA.as_ref());
assert!(foo_fields[2].field_exists.is_none());
--
2.53.0
next prev parent reply other threads:[~2026-08-18 18:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 18:24 [PATCH v2 0/8] migration: Remove extra type-checking from vmstate macros Fabiano Rosas
2026-08-18 18:24 ` [PATCH v2 1/8] migration: Remove unused " Fabiano Rosas
2026-08-18 18:24 ` [PATCH v2 2/8] migration: Introduce VMStateStructMember Fabiano Rosas
2026-08-18 19:12 ` Peter Xu
2026-08-18 18:24 ` Fabiano Rosas [this message]
2026-08-18 18:24 ` [PATCH v2 4/8] migration: Remove duplicate vmstate macros Fabiano Rosas
2026-08-18 18:24 ` [PATCH v2 5/8] migration: Add VMS_NO_STATE flag Fabiano Rosas
2026-08-18 18:24 ` [PATCH v2 6/8] migration: Check more vmstate flags Fabiano Rosas
2026-08-18 18:24 ` [PATCH v2 7/8] migration: Harden vmstate_handle_alloc Fabiano Rosas
2026-08-18 18:24 ` [PATCH v2 8/8] migration: Harden vmstate_size Fabiano Rosas
2026-08-18 19:12 ` [PATCH v2 0/8] migration: Remove extra type-checking from vmstate macros 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=20260818182441.404790-4-farosas@suse.de \
--to=farosas@suse.de \
--cc=dtalexundeer@yandex-team.ru \
--cc=manos.pitsidianakis@linaro.org \
--cc=mst@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
/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.