migration: Remove VMS_MULTIPLY_ELEMENTS and VMSTATE_VARRAY_MULTIPLY()
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> Reviewed-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Acked-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Link: https://lore.kernel.org/r/20260507070228.48877-1-philmd@linaro.org Signed-off-by: Peter Xu <peterx@redhat.com>
Philippe Mathieu-Daudé committed
May 7, 2026 at 09:02 UTC
1c592bf19b8bf6805ab61f6d1f8a8ec73484f537
5 files changed
+4
-88
include/migration/vmstate.h
+3
-19
@@ -105,7 +105,7 @@ enum VMStateFlags {
105
VMS_ARRAY_OF_POINTER = 0x040,
106
107
/* The field is an array of variable size. The uint16_t at opaque
108
- * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
108
+ * + VMStateField.num_offset
109
* contains the number of entries in the array. See the VMS_ARRAY
110
* description regarding array handling in general. May not be
111
* combined with VMS_ARRAY or any other VMS_VARRAY*. */
@@ -126,14 +126,14 @@ enum VMStateFlags {
126
VMS_MULTIPLY = 0x200,
127
128
/* The field is an array of variable size. The uint8_t at opaque +
129
- * VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
129
+ * VMStateField.num_offset
130
* contains the number of entries in the array. See the VMS_ARRAY
131
* description regarding array handling in general. May not be
132
* combined with VMS_ARRAY or any other VMS_VARRAY*. */
133
VMS_VARRAY_UINT8 = 0x400,
134
135
/* The field is an array of variable size. The uint32_t at opaque
136
- * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
136
+ * + VMStateField.num_offset
137
* contains the number of entries in the array. See the VMS_ARRAY
138
* description regarding array handling in general. May not be
139
* combined with VMS_ARRAY or any other VMS_VARRAY*. */
@@ -150,12 +150,6 @@ enum VMStateFlags {
150
* cause the individual entries to be allocated. */
151
VMS_ALLOC = 0x2000,
152
153
- /* Multiply the number of entries given by the integer at opaque +
154
- * VMStateField.num_offset (see VMS_VARRAY*) with VMStateField.num
155
- * to determine the number of entries in the array. Only valid in
156
- * combination with one of VMS_VARRAY*. */
157
- VMS_MULTIPLY_ELEMENTS = 0x4000,
158
-
153
/* A structure field that is like VMS_STRUCT, but uses
154
* VMStateField.struct_version_id to tell which version of the
155
* structure we are referencing to use. */
@@ -446,16 +440,6 @@ extern const VMStateInfo vmstate_info_qlist;
440
.offset = vmstate_offset_2darray(_state, _field, _type, _n1, _n2), \
441
}
442
449
-#define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info, _type) { \
450
- .name = (stringify(_field)), \
451
- .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
452
- .num = (_multiply), \
453
- .info = &(_info), \
454
- .size = sizeof(_type), \
455
- .flags = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS, \
456
- .offset = vmstate_offset_varray(_state, _field, _type), \
457
-}
458
-
443
#define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
444
.name = (stringify(_field)), \
445
.version_id = (_version), \
migration/vmstate.c
-4
@@ -100,10 +100,6 @@ static int vmstate_n_elems(void *opaque, const VMStateField *field)
100
n_elems = *(uint8_t *)(opaque + field->num_offset);
101
}
102
103
- if (field->flags & VMS_MULTIPLY_ELEMENTS) {
104
- n_elems *= field->num;
105
- }
106
-
103
trace_vmstate_n_elems(field->name, n_elems);
104
return n_elems;
105
}
rust/bindings/migration-sys/lib.rs
-8
@@ -114,12 +114,4 @@ impl VMStateField {
114
assert!((self.flags.0 & VMStateFlags::VMS_ARRAY.0) != 0);
115
self.with_varray_flag_unchecked(flag)
116
}
117
-
118
- #[must_use]
119
- pub const fn with_varray_multiply(mut self, num: u32) -> Self {
120
- assert!(num <= 0x7FFF_FFFFu32);
121
- self.flags = VMStateFlags(self.flags.0 | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0);
122
- self.num = num as i32;
123
- self
124
- }
117
}
rust/migration/src/vmstate.rs
+1
-2
@@ -159,8 +159,7 @@ macro_rules! vmstate_of {
159
)$(.with_varray_flag($crate::call_func_with_field!(
160
$crate::vmstate::vmstate_varray_flag,
161
$struct_name,
162
- $($num).+))
163
- $(.with_varray_multiply($factor))?)?
162
+ $($num).+)))?
163
}
164
};
165
}
rust/tests/tests/vmstate_tests.rs
-55
@@ -118,34 +118,6 @@ fn test_vmstate_varray_uint16_unsafe() {
118
assert!(foo_fields[2].field_exists.is_none());
119
}
120
121
-#[test]
122
-fn test_vmstate_varray_multiply() {
123
- let foo_fields: &[VMStateField] =
124
- unsafe { slice::from_raw_parts(VMSTATE_FOOA.as_ref().fields, 5) };
125
-
126
- // 4th VMStateField ("arr_mul") in VMSTATE_FOOA (corresponding to
127
- // VMSTATE_VARRAY_MULTIPLY)
128
- assert_eq!(
129
- unsafe { CStr::from_ptr(foo_fields[3].name) }.to_bytes_with_nul(),
130
- b"arr_mul\0"
131
- );
132
- assert_eq!(foo_fields[3].offset, 6);
133
- assert_eq!(foo_fields[3].num_offset, 12);
134
- assert_eq!(foo_fields[3].info, unsafe { &vmstate_info_int8 });
135
- assert_eq!(foo_fields[3].version_id, 0);
136
- assert_eq!(foo_fields[3].size, 1);
137
- assert_eq!(foo_fields[3].num, 16);
138
- assert_eq!(
139
- foo_fields[3].flags.0,
140
- VMStateFlags::VMS_VARRAY_UINT32.0 | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0
141
- );
142
- assert!(foo_fields[3].vmsd.is_null());
143
- assert!(foo_fields[3].field_exists.is_none());
144
-
145
- // The last VMStateField in VMSTATE_FOOA.
146
- assert_eq!(foo_fields[4].flags, VMStateFlags::VMS_END);
147
-}
148
-
121
// =========================== Test VMSTATE_FOOB ===========================
122
// Test the use cases of the vmstate macro, corresponding to the following C
123
// macro variants:
@@ -256,33 +228,6 @@ fn test_vmstate_struct_varray_uint8() {
228
assert!(foo_fields[2].field_exists.is_none());
229
}
230
259
-#[test]
260
-fn test_vmstate_struct_varray_uint32_multiply() {
261
- let foo_fields: &[VMStateField] =
262
- unsafe { slice::from_raw_parts(VMSTATE_FOOB.as_ref().fields, 7) };
263
-
264
- // 4th VMStateField ("arr_a_mul") in VMSTATE_FOOB (corresponding to
265
- // (no C version) MULTIPLY variant of VMSTATE_STRUCT_VARRAY_UINT32)
266
- assert_eq!(
267
- unsafe { CStr::from_ptr(foo_fields[3].name) }.to_bytes_with_nul(),
268
- b"arr_a_mul\0"
269
- );
270
- assert_eq!(foo_fields[3].offset, 64);
271
- assert_eq!(foo_fields[3].num_offset, 124);
272
- assert!(foo_fields[3].info.is_null()); // VMSTATE_STRUCT_VARRAY_UINT8 doesn't set info field.
273
- assert_eq!(foo_fields[3].version_id, 2);
274
- assert_eq!(foo_fields[3].size, 20);
275
- assert_eq!(foo_fields[3].num, 32);
276
- assert_eq!(
277
- foo_fields[3].flags.0,
278
- VMStateFlags::VMS_STRUCT.0
279
- | VMStateFlags::VMS_VARRAY_UINT32.0
280
- | VMStateFlags::VMS_MULTIPLY_ELEMENTS.0
281
- );
282
- assert_eq!(foo_fields[3].vmsd, VMSTATE_FOOA.as_ref());
283
- assert!(foo_fields[3].field_exists.is_none());
284
-}
285
-
231
#[test]
232
fn test_vmstate_macro_array() {
233
let foo_fields: &[VMStateField] =