* Re: [PATCH] migration: Remove VMS_MULTIPLY_ELEMENTS and VMSTATE_VARRAY_MULTIPLY()
2026-05-07 7:02 [PATCH] migration: Remove VMS_MULTIPLY_ELEMENTS and VMSTATE_VARRAY_MULTIPLY() Philippe Mathieu-Daudé
@ 2026-05-07 7:12 ` Manos Pitsidianakis
2026-05-07 13:36 ` Fabiano Rosas
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Manos Pitsidianakis @ 2026-05-07 7:12 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Pierrick Bouvier, qemu-rust, Fabiano Rosas, Peter Xu
On Thu, May 7, 2026 at 10:02 AM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Commit c1eb3ac3468 ("target/sparc: Replace
> VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY") removed the
> last use of the VMSTATE_VARRAY_MULTIPLY() macro. We can now
> remove it as unnecessary, along with the VMS_MULTIPLY_ELEMENTS
> flag and the associated tests.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/migration/vmstate.h | 22 ++----------
> migration/vmstate.c | 4 ---
> rust/bindings/migration-sys/lib.rs | 8 -----
> rust/migration/src/vmstate.rs | 3 +-
> rust/tests/tests/vmstate_tests.rs | 55 ------------------------------
> 5 files changed, 4 insertions(+), 88 deletions(-)
>
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index 28e3640e60c..0a8a2e85a63 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -105,7 +105,7 @@ enum VMStateFlags {
> VMS_ARRAY_OF_POINTER = 0x040,
>
> /* The field is an array of variable size. The uint16_t at opaque
> - * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
> + * + VMStateField.num_offset
> * 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*. */
> @@ -126,14 +126,14 @@ enum VMStateFlags {
> VMS_MULTIPLY = 0x200,
>
> /* The field is an array of variable size. The uint8_t at opaque +
> - * VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
> + * VMStateField.num_offset
> * 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_offset (subject to VMS_MULTIPLY_ELEMENTS)
> + * + VMStateField.num_offset
> * 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*. */
> @@ -150,12 +150,6 @@ enum VMStateFlags {
> * cause the individual entries to be allocated. */
> VMS_ALLOC = 0x2000,
>
> - /* Multiply the number of entries given by the integer at opaque +
> - * VMStateField.num_offset (see VMS_VARRAY*) with VMStateField.num
> - * to determine the number of entries in the array. Only valid in
> - * combination with one of VMS_VARRAY*. */
> - VMS_MULTIPLY_ELEMENTS = 0x4000,
> -
> /* A structure field that is like VMS_STRUCT, but uses
> * VMStateField.struct_version_id to tell which version of the
> * structure we are referencing to use. */
> @@ -446,16 +440,6 @@ extern const VMStateInfo vmstate_info_qlist;
> .offset = vmstate_offset_2darray(_state, _field, _type, _n1, _n2), \
> }
>
> -#define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info, _type) { \
> - .name = (stringify(_field)), \
> - .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
> - .num = (_multiply), \
> - .info = &(_info), \
> - .size = sizeof(_type), \
> - .flags = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS, \
> - .offset = vmstate_offset_varray(_state, _field, _type), \
> -}
> -
> #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
> .name = (stringify(_field)), \
> .version_id = (_version), \
> diff --git a/migration/vmstate.c b/migration/vmstate.c
> index 2f13b48a37f..6fa7523f04d 100644
> --- a/migration/vmstate.c
> +++ b/migration/vmstate.c
> @@ -100,10 +100,6 @@ static int vmstate_n_elems(void *opaque, const VMStateField *field)
> n_elems = *(uint8_t *)(opaque + field->num_offset);
> }
>
> - if (field->flags & VMS_MULTIPLY_ELEMENTS) {
> - n_elems *= field->num;
> - }
> -
> trace_vmstate_n_elems(field->name, n_elems);
> return n_elems;
> }
> diff --git a/rust/bindings/migration-sys/lib.rs b/rust/bindings/migration-sys/lib.rs
> index 7ee30a3f7d5..9581481e421 100644
> --- a/rust/bindings/migration-sys/lib.rs
> +++ b/rust/bindings/migration-sys/lib.rs
> @@ -114,12 +114,4 @@ pub const fn with_varray_flag(mut self, flag: VMStateFlags) -> Self {
> assert!((self.flags.0 & VMStateFlags::VMS_ARRAY.0) != 0);
> self.with_varray_flag_unchecked(flag)
> }
> -
> - #[must_use]
> - pub const fn with_varray_multiply(mut self, num: u32) -> Self {
> - assert!(num <= 0x7FFF_FFFFu32);
> - self.flags = VMStateFlags(self.flags.0 | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0);
> - self.num = num as i32;
> - self
> - }
> }
> diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs
> index f34a36f6809..63d78b4f275 100644
> --- a/rust/migration/src/vmstate.rs
> +++ b/rust/migration/src/vmstate.rs
> @@ -159,8 +159,7 @@ macro_rules! vmstate_of {
> )$(.with_varray_flag($crate::call_func_with_field!(
> $crate::vmstate::vmstate_varray_flag,
> $struct_name,
> - $($num).+))
> - $(.with_varray_multiply($factor))?)?
> + $($num).+)))?
> }
> };
> }
> diff --git a/rust/tests/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_tests.rs
> index 87176a80990..c2c12cfab52 100644
> --- a/rust/tests/tests/vmstate_tests.rs
> +++ b/rust/tests/tests/vmstate_tests.rs
> @@ -118,34 +118,6 @@ fn test_vmstate_varray_uint16_unsafe() {
> assert!(foo_fields[2].field_exists.is_none());
> }
>
> -#[test]
> -fn test_vmstate_varray_multiply() {
> - let foo_fields: &[VMStateField] =
> - unsafe { slice::from_raw_parts(VMSTATE_FOOA.as_ref().fields, 5) };
> -
> - // 4th VMStateField ("arr_mul") in VMSTATE_FOOA (corresponding to
> - // VMSTATE_VARRAY_MULTIPLY)
> - assert_eq!(
> - unsafe { CStr::from_ptr(foo_fields[3].name) }.to_bytes_with_nul(),
> - b"arr_mul\0"
> - );
> - assert_eq!(foo_fields[3].offset, 6);
> - assert_eq!(foo_fields[3].num_offset, 12);
> - assert_eq!(foo_fields[3].info, unsafe { &vmstate_info_int8 });
> - assert_eq!(foo_fields[3].version_id, 0);
> - assert_eq!(foo_fields[3].size, 1);
> - assert_eq!(foo_fields[3].num, 16);
> - assert_eq!(
> - foo_fields[3].flags.0,
> - VMStateFlags::VMS_VARRAY_UINT32.0 | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0
> - );
> - assert!(foo_fields[3].vmsd.is_null());
> - assert!(foo_fields[3].field_exists.is_none());
> -
> - // The last VMStateField in VMSTATE_FOOA.
> - assert_eq!(foo_fields[4].flags, VMStateFlags::VMS_END);
> -}
> -
> // =========================== Test VMSTATE_FOOB ===========================
> // Test the use cases of the vmstate macro, corresponding to the following C
> // macro variants:
> @@ -256,33 +228,6 @@ fn test_vmstate_struct_varray_uint8() {
> assert!(foo_fields[2].field_exists.is_none());
> }
>
> -#[test]
> -fn test_vmstate_struct_varray_uint32_multiply() {
> - let foo_fields: &[VMStateField] =
> - unsafe { slice::from_raw_parts(VMSTATE_FOOB.as_ref().fields, 7) };
> -
> - // 4th VMStateField ("arr_a_mul") in VMSTATE_FOOB (corresponding to
> - // (no C version) MULTIPLY variant of VMSTATE_STRUCT_VARRAY_UINT32)
> - assert_eq!(
> - unsafe { CStr::from_ptr(foo_fields[3].name) }.to_bytes_with_nul(),
> - b"arr_a_mul\0"
> - );
> - assert_eq!(foo_fields[3].offset, 64);
> - assert_eq!(foo_fields[3].num_offset, 124);
> - assert!(foo_fields[3].info.is_null()); // VMSTATE_STRUCT_VARRAY_UINT8 doesn't set info field.
> - assert_eq!(foo_fields[3].version_id, 2);
> - assert_eq!(foo_fields[3].size, 20);
> - assert_eq!(foo_fields[3].num, 32);
> - assert_eq!(
> - foo_fields[3].flags.0,
> - VMStateFlags::VMS_STRUCT.0
> - | VMStateFlags::VMS_VARRAY_UINT32.0
> - | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0
> - );
> - assert_eq!(foo_fields[3].vmsd, VMSTATE_FOOA.as_ref());
> - assert!(foo_fields[3].field_exists.is_none());
> -}
> -
> #[test]
> fn test_vmstate_macro_array() {
> let foo_fields: &[VMStateField] =
> --
> 2.53.0
>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Acked-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] migration: Remove VMS_MULTIPLY_ELEMENTS and VMSTATE_VARRAY_MULTIPLY()
2026-05-07 7:02 [PATCH] migration: Remove VMS_MULTIPLY_ELEMENTS and VMSTATE_VARRAY_MULTIPLY() Philippe Mathieu-Daudé
2026-05-07 7:12 ` Manos Pitsidianakis
@ 2026-05-07 13:36 ` Fabiano Rosas
2026-05-07 13:36 ` Fabiano Rosas
2026-05-11 18:51 ` Peter Xu
3 siblings, 0 replies; 5+ messages in thread
From: Fabiano Rosas @ 2026-05-07 13:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Pierrick Bouvier, qemu-rust, Manos Pitsidianakis, Peter Xu,
Philippe Mathieu-Daudé
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Commit c1eb3ac3468 ("target/sparc: Replace
> VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY") removed the
> last use of the VMSTATE_VARRAY_MULTIPLY() macro. We can now
> remove it as unnecessary, along with the VMS_MULTIPLY_ELEMENTS
> flag and the associated tests.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/migration/vmstate.h | 22 ++----------
> migration/vmstate.c | 4 ---
> rust/bindings/migration-sys/lib.rs | 8 -----
> rust/migration/src/vmstate.rs | 3 +-
> rust/tests/tests/vmstate_tests.rs | 55 ------------------------------
> 5 files changed, 4 insertions(+), 88 deletions(-)
>
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index 28e3640e60c..0a8a2e85a63 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -105,7 +105,7 @@ enum VMStateFlags {
> VMS_ARRAY_OF_POINTER = 0x040,
>
> /* The field is an array of variable size. The uint16_t at opaque
> - * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
> + * + VMStateField.num_offset
> * 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*. */
> @@ -126,14 +126,14 @@ enum VMStateFlags {
> VMS_MULTIPLY = 0x200,
>
> /* The field is an array of variable size. The uint8_t at opaque +
> - * VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
> + * VMStateField.num_offset
> * 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_offset (subject to VMS_MULTIPLY_ELEMENTS)
> + * + VMStateField.num_offset
> * 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*. */
> @@ -150,12 +150,6 @@ enum VMStateFlags {
> * cause the individual entries to be allocated. */
> VMS_ALLOC = 0x2000,
>
> - /* Multiply the number of entries given by the integer at opaque +
> - * VMStateField.num_offset (see VMS_VARRAY*) with VMStateField.num
> - * to determine the number of entries in the array. Only valid in
> - * combination with one of VMS_VARRAY*. */
> - VMS_MULTIPLY_ELEMENTS = 0x4000,
> -
> /* A structure field that is like VMS_STRUCT, but uses
> * VMStateField.struct_version_id to tell which version of the
> * structure we are referencing to use. */
> @@ -446,16 +440,6 @@ extern const VMStateInfo vmstate_info_qlist;
> .offset = vmstate_offset_2darray(_state, _field, _type, _n1, _n2), \
> }
>
> -#define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info, _type) { \
> - .name = (stringify(_field)), \
> - .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
> - .num = (_multiply), \
> - .info = &(_info), \
> - .size = sizeof(_type), \
> - .flags = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS, \
> - .offset = vmstate_offset_varray(_state, _field, _type), \
> -}
> -
> #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
> .name = (stringify(_field)), \
> .version_id = (_version), \
> diff --git a/migration/vmstate.c b/migration/vmstate.c
> index 2f13b48a37f..6fa7523f04d 100644
> --- a/migration/vmstate.c
> +++ b/migration/vmstate.c
> @@ -100,10 +100,6 @@ static int vmstate_n_elems(void *opaque, const VMStateField *field)
> n_elems = *(uint8_t *)(opaque + field->num_offset);
> }
>
> - if (field->flags & VMS_MULTIPLY_ELEMENTS) {
> - n_elems *= field->num;
> - }
> -
> trace_vmstate_n_elems(field->name, n_elems);
> return n_elems;
> }
> diff --git a/rust/bindings/migration-sys/lib.rs b/rust/bindings/migration-sys/lib.rs
> index 7ee30a3f7d5..9581481e421 100644
> --- a/rust/bindings/migration-sys/lib.rs
> +++ b/rust/bindings/migration-sys/lib.rs
> @@ -114,12 +114,4 @@ pub const fn with_varray_flag(mut self, flag: VMStateFlags) -> Self {
> assert!((self.flags.0 & VMStateFlags::VMS_ARRAY.0) != 0);
> self.with_varray_flag_unchecked(flag)
> }
> -
> - #[must_use]
> - pub const fn with_varray_multiply(mut self, num: u32) -> Self {
> - assert!(num <= 0x7FFF_FFFFu32);
> - self.flags = VMStateFlags(self.flags.0 | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0);
> - self.num = num as i32;
> - self
> - }
> }
> diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs
> index f34a36f6809..63d78b4f275 100644
> --- a/rust/migration/src/vmstate.rs
> +++ b/rust/migration/src/vmstate.rs
> @@ -159,8 +159,7 @@ macro_rules! vmstate_of {
> )$(.with_varray_flag($crate::call_func_with_field!(
> $crate::vmstate::vmstate_varray_flag,
> $struct_name,
> - $($num).+))
> - $(.with_varray_multiply($factor))?)?
> + $($num).+)))?
> }
> };
> }
> diff --git a/rust/tests/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_tests.rs
> index 87176a80990..c2c12cfab52 100644
> --- a/rust/tests/tests/vmstate_tests.rs
> +++ b/rust/tests/tests/vmstate_tests.rs
> @@ -118,34 +118,6 @@ fn test_vmstate_varray_uint16_unsafe() {
> assert!(foo_fields[2].field_exists.is_none());
> }
>
> -#[test]
> -fn test_vmstate_varray_multiply() {
> - let foo_fields: &[VMStateField] =
> - unsafe { slice::from_raw_parts(VMSTATE_FOOA.as_ref().fields, 5) };
> -
> - // 4th VMStateField ("arr_mul") in VMSTATE_FOOA (corresponding to
> - // VMSTATE_VARRAY_MULTIPLY)
> - assert_eq!(
> - unsafe { CStr::from_ptr(foo_fields[3].name) }.to_bytes_with_nul(),
> - b"arr_mul\0"
> - );
> - assert_eq!(foo_fields[3].offset, 6);
> - assert_eq!(foo_fields[3].num_offset, 12);
> - assert_eq!(foo_fields[3].info, unsafe { &vmstate_info_int8 });
> - assert_eq!(foo_fields[3].version_id, 0);
> - assert_eq!(foo_fields[3].size, 1);
> - assert_eq!(foo_fields[3].num, 16);
> - assert_eq!(
> - foo_fields[3].flags.0,
> - VMStateFlags::VMS_VARRAY_UINT32.0 | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0
> - );
> - assert!(foo_fields[3].vmsd.is_null());
> - assert!(foo_fields[3].field_exists.is_none());
> -
> - // The last VMStateField in VMSTATE_FOOA.
> - assert_eq!(foo_fields[4].flags, VMStateFlags::VMS_END);
> -}
> -
> // =========================== Test VMSTATE_FOOB ===========================
> // Test the use cases of the vmstate macro, corresponding to the following C
> // macro variants:
> @@ -256,33 +228,6 @@ fn test_vmstate_struct_varray_uint8() {
> assert!(foo_fields[2].field_exists.is_none());
> }
>
> -#[test]
> -fn test_vmstate_struct_varray_uint32_multiply() {
> - let foo_fields: &[VMStateField] =
> - unsafe { slice::from_raw_parts(VMSTATE_FOOB.as_ref().fields, 7) };
> -
> - // 4th VMStateField ("arr_a_mul") in VMSTATE_FOOB (corresponding to
> - // (no C version) MULTIPLY variant of VMSTATE_STRUCT_VARRAY_UINT32)
> - assert_eq!(
> - unsafe { CStr::from_ptr(foo_fields[3].name) }.to_bytes_with_nul(),
> - b"arr_a_mul\0"
> - );
> - assert_eq!(foo_fields[3].offset, 64);
> - assert_eq!(foo_fields[3].num_offset, 124);
> - assert!(foo_fields[3].info.is_null()); // VMSTATE_STRUCT_VARRAY_UINT8 doesn't set info field.
> - assert_eq!(foo_fields[3].version_id, 2);
> - assert_eq!(foo_fields[3].size, 20);
> - assert_eq!(foo_fields[3].num, 32);
> - assert_eq!(
> - foo_fields[3].flags.0,
> - VMStateFlags::VMS_STRUCT.0
> - | VMStateFlags::VMS_VARRAY_UINT32.0
> - | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0
> - );
> - assert_eq!(foo_fields[3].vmsd, VMSTATE_FOOA.as_ref());
> - assert!(foo_fields[3].field_exists.is_none());
> -}
> -
> #[test]
> fn test_vmstate_macro_array() {
> let foo_fields: &[VMStateField] =
Reviewed-by: Fabiano Rosas <farosas@suse.de>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] migration: Remove VMS_MULTIPLY_ELEMENTS and VMSTATE_VARRAY_MULTIPLY()
2026-05-07 7:02 [PATCH] migration: Remove VMS_MULTIPLY_ELEMENTS and VMSTATE_VARRAY_MULTIPLY() Philippe Mathieu-Daudé
2026-05-07 7:12 ` Manos Pitsidianakis
2026-05-07 13:36 ` Fabiano Rosas
@ 2026-05-07 13:36 ` Fabiano Rosas
2026-05-11 18:51 ` Peter Xu
3 siblings, 0 replies; 5+ messages in thread
From: Fabiano Rosas @ 2026-05-07 13:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Pierrick Bouvier, qemu-rust, Manos Pitsidianakis, Peter Xu,
Philippe Mathieu-Daudé
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Commit c1eb3ac3468 ("target/sparc: Replace
> VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY") removed the
> last use of the VMSTATE_VARRAY_MULTIPLY() macro. We can now
> remove it as unnecessary, along with the VMS_MULTIPLY_ELEMENTS
> flag and the associated tests.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/migration/vmstate.h | 22 ++----------
> migration/vmstate.c | 4 ---
> rust/bindings/migration-sys/lib.rs | 8 -----
> rust/migration/src/vmstate.rs | 3 +-
> rust/tests/tests/vmstate_tests.rs | 55 ------------------------------
> 5 files changed, 4 insertions(+), 88 deletions(-)
>
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index 28e3640e60c..0a8a2e85a63 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -105,7 +105,7 @@ enum VMStateFlags {
> VMS_ARRAY_OF_POINTER = 0x040,
>
> /* The field is an array of variable size. The uint16_t at opaque
> - * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
> + * + VMStateField.num_offset
> * 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*. */
> @@ -126,14 +126,14 @@ enum VMStateFlags {
> VMS_MULTIPLY = 0x200,
>
> /* The field is an array of variable size. The uint8_t at opaque +
> - * VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
> + * VMStateField.num_offset
> * 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_offset (subject to VMS_MULTIPLY_ELEMENTS)
> + * + VMStateField.num_offset
> * 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*. */
> @@ -150,12 +150,6 @@ enum VMStateFlags {
> * cause the individual entries to be allocated. */
> VMS_ALLOC = 0x2000,
>
> - /* Multiply the number of entries given by the integer at opaque +
> - * VMStateField.num_offset (see VMS_VARRAY*) with VMStateField.num
> - * to determine the number of entries in the array. Only valid in
> - * combination with one of VMS_VARRAY*. */
> - VMS_MULTIPLY_ELEMENTS = 0x4000,
> -
> /* A structure field that is like VMS_STRUCT, but uses
> * VMStateField.struct_version_id to tell which version of the
> * structure we are referencing to use. */
> @@ -446,16 +440,6 @@ extern const VMStateInfo vmstate_info_qlist;
> .offset = vmstate_offset_2darray(_state, _field, _type, _n1, _n2), \
> }
>
> -#define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info, _type) { \
> - .name = (stringify(_field)), \
> - .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
> - .num = (_multiply), \
> - .info = &(_info), \
> - .size = sizeof(_type), \
> - .flags = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS, \
> - .offset = vmstate_offset_varray(_state, _field, _type), \
> -}
> -
> #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
> .name = (stringify(_field)), \
> .version_id = (_version), \
> diff --git a/migration/vmstate.c b/migration/vmstate.c
> index 2f13b48a37f..6fa7523f04d 100644
> --- a/migration/vmstate.c
> +++ b/migration/vmstate.c
> @@ -100,10 +100,6 @@ static int vmstate_n_elems(void *opaque, const VMStateField *field)
> n_elems = *(uint8_t *)(opaque + field->num_offset);
> }
>
> - if (field->flags & VMS_MULTIPLY_ELEMENTS) {
> - n_elems *= field->num;
> - }
> -
> trace_vmstate_n_elems(field->name, n_elems);
> return n_elems;
> }
> diff --git a/rust/bindings/migration-sys/lib.rs b/rust/bindings/migration-sys/lib.rs
> index 7ee30a3f7d5..9581481e421 100644
> --- a/rust/bindings/migration-sys/lib.rs
> +++ b/rust/bindings/migration-sys/lib.rs
> @@ -114,12 +114,4 @@ pub const fn with_varray_flag(mut self, flag: VMStateFlags) -> Self {
> assert!((self.flags.0 & VMStateFlags::VMS_ARRAY.0) != 0);
> self.with_varray_flag_unchecked(flag)
> }
> -
> - #[must_use]
> - pub const fn with_varray_multiply(mut self, num: u32) -> Self {
> - assert!(num <= 0x7FFF_FFFFu32);
> - self.flags = VMStateFlags(self.flags.0 | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0);
> - self.num = num as i32;
> - self
> - }
> }
> diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs
> index f34a36f6809..63d78b4f275 100644
> --- a/rust/migration/src/vmstate.rs
> +++ b/rust/migration/src/vmstate.rs
> @@ -159,8 +159,7 @@ macro_rules! vmstate_of {
> )$(.with_varray_flag($crate::call_func_with_field!(
> $crate::vmstate::vmstate_varray_flag,
> $struct_name,
> - $($num).+))
> - $(.with_varray_multiply($factor))?)?
> + $($num).+)))?
> }
> };
> }
> diff --git a/rust/tests/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_tests.rs
> index 87176a80990..c2c12cfab52 100644
> --- a/rust/tests/tests/vmstate_tests.rs
> +++ b/rust/tests/tests/vmstate_tests.rs
> @@ -118,34 +118,6 @@ fn test_vmstate_varray_uint16_unsafe() {
> assert!(foo_fields[2].field_exists.is_none());
> }
>
> -#[test]
> -fn test_vmstate_varray_multiply() {
> - let foo_fields: &[VMStateField] =
> - unsafe { slice::from_raw_parts(VMSTATE_FOOA.as_ref().fields, 5) };
> -
> - // 4th VMStateField ("arr_mul") in VMSTATE_FOOA (corresponding to
> - // VMSTATE_VARRAY_MULTIPLY)
> - assert_eq!(
> - unsafe { CStr::from_ptr(foo_fields[3].name) }.to_bytes_with_nul(),
> - b"arr_mul\0"
> - );
> - assert_eq!(foo_fields[3].offset, 6);
> - assert_eq!(foo_fields[3].num_offset, 12);
> - assert_eq!(foo_fields[3].info, unsafe { &vmstate_info_int8 });
> - assert_eq!(foo_fields[3].version_id, 0);
> - assert_eq!(foo_fields[3].size, 1);
> - assert_eq!(foo_fields[3].num, 16);
> - assert_eq!(
> - foo_fields[3].flags.0,
> - VMStateFlags::VMS_VARRAY_UINT32.0 | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0
> - );
> - assert!(foo_fields[3].vmsd.is_null());
> - assert!(foo_fields[3].field_exists.is_none());
> -
> - // The last VMStateField in VMSTATE_FOOA.
> - assert_eq!(foo_fields[4].flags, VMStateFlags::VMS_END);
> -}
> -
> // =========================== Test VMSTATE_FOOB ===========================
> // Test the use cases of the vmstate macro, corresponding to the following C
> // macro variants:
> @@ -256,33 +228,6 @@ fn test_vmstate_struct_varray_uint8() {
> assert!(foo_fields[2].field_exists.is_none());
> }
>
> -#[test]
> -fn test_vmstate_struct_varray_uint32_multiply() {
> - let foo_fields: &[VMStateField] =
> - unsafe { slice::from_raw_parts(VMSTATE_FOOB.as_ref().fields, 7) };
> -
> - // 4th VMStateField ("arr_a_mul") in VMSTATE_FOOB (corresponding to
> - // (no C version) MULTIPLY variant of VMSTATE_STRUCT_VARRAY_UINT32)
> - assert_eq!(
> - unsafe { CStr::from_ptr(foo_fields[3].name) }.to_bytes_with_nul(),
> - b"arr_a_mul\0"
> - );
> - assert_eq!(foo_fields[3].offset, 64);
> - assert_eq!(foo_fields[3].num_offset, 124);
> - assert!(foo_fields[3].info.is_null()); // VMSTATE_STRUCT_VARRAY_UINT8 doesn't set info field.
> - assert_eq!(foo_fields[3].version_id, 2);
> - assert_eq!(foo_fields[3].size, 20);
> - assert_eq!(foo_fields[3].num, 32);
> - assert_eq!(
> - foo_fields[3].flags.0,
> - VMStateFlags::VMS_STRUCT.0
> - | VMStateFlags::VMS_VARRAY_UINT32.0
> - | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0
> - );
> - assert_eq!(foo_fields[3].vmsd, VMSTATE_FOOA.as_ref());
> - assert!(foo_fields[3].field_exists.is_none());
> -}
> -
> #[test]
> fn test_vmstate_macro_array() {
> let foo_fields: &[VMStateField] =
Reviewed-by: Fabiano Rosas <farosas@suse.de>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] migration: Remove VMS_MULTIPLY_ELEMENTS and VMSTATE_VARRAY_MULTIPLY()
2026-05-07 7:02 [PATCH] migration: Remove VMS_MULTIPLY_ELEMENTS and VMSTATE_VARRAY_MULTIPLY() Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2026-05-07 13:36 ` Fabiano Rosas
@ 2026-05-11 18:51 ` Peter Xu
3 siblings, 0 replies; 5+ messages in thread
From: Peter Xu @ 2026-05-11 18:51 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Pierrick Bouvier, qemu-rust, Manos Pitsidianakis,
Fabiano Rosas
On Thu, May 07, 2026 at 09:02:28AM +0200, Philippe Mathieu-Daudé wrote:
> Commit c1eb3ac3468 ("target/sparc: Replace
> VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY") removed the
> last use of the VMSTATE_VARRAY_MULTIPLY() macro. We can now
> remove it as unnecessary, along with the VMS_MULTIPLY_ELEMENTS
> flag and the associated tests.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
queued, thanks.
--
Peter Xu
^ permalink raw reply [flat|nested] 5+ messages in thread