migration: Remove redundant flags
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. Acked-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
Fabiano Rosas committed
Aug 18, 2026 at 15:24 UTC
1f0b40dccfe54849d45a7126af0398645b2bd231
6 files changed
+37
-63
include/migration/vmstate.h
+28
-46
@@ -69,8 +69,9 @@ enum VMStateFlags {
69
* }). Dereference the pointer before using it as basis for
70
* further pointer arithmetic (see e.g. VMS_ARRAY). Does not
71
* affect the meaning of VMStateField.num_indirect or
72
- * VMStateField.size_indirect; see VMS_VARRAY* and VMS_VBUFFER for
73
- * those. */
72
+ * VMStateField.size_indirect; see VMS_VARRAY and VMS_VBUFFER for
73
+ * those.
74
+ */
75
VMS_POINTER = 0x002,
76
77
/* The field is an array of fixed size. VMStateField.num contains
@@ -80,12 +81,13 @@ enum VMStateFlags {
81
* VMS_MULTIPLY. Each array entry will be processed individually
82
* (VMStateField.info.get()/put() if VMS_STRUCT is not set,
83
* recursion into VMStateField.vmsd if VMS_STRUCT is set). May not
83
- * be combined with VMS_VARRAY*. */
84
+ * be combined with VMS_VARRAY.
85
+ */
86
VMS_ARRAY = 0x004,
87
88
/* The field is itself a struct, containing one or more
89
* fields. Recurse into VMStateField.vmsd. Most useful in
88
- * combination with VMS_ARRAY / VMS_VARRAY*, recursing into each
90
+ * combination with VMS_ARRAY / VMS_VARRAY, recursing into each
91
* array entry. */
92
VMS_STRUCT = 0x008,
93
@@ -93,9 +95,9 @@ enum VMStateFlags {
95
* The field is an array of variable size. The integer at opaque +
96
* VMStateField.num_indirect contains the number of entries in the
97
* array. See the VMS_ARRAY description regarding array handling
96
- * in general. May not be combined with VMS_ARRAY or any other
97
- * VMS_VARRAY*. */
98
- VMS_VARRAY_INT32 = 0x010,
98
+ * in general. May not be combined with VMS_ARRAY.
99
+ */
100
+ VMS_VARRAY = 0x010,
101
102
/* Ignored */
103
VMS_BUFFER = 0x020,
@@ -103,18 +105,12 @@ enum VMStateFlags {
105
/* The field is a (fixed-size or variable-size) array of pointers
106
* (e.g. struct a { uint8_t *b[]; }). Dereference each array entry
107
* before using it. Note: Does not imply any one of VMS_ARRAY /
106
- * VMS_VARRAY*; these need to be set explicitly. */
108
+ * VMS_VARRAY; these need to be set explicitly.
109
+ */
110
VMS_ARRAY_OF_POINTER = 0x040,
111
109
- /* The field is an array of variable size. The uint16_t at opaque
110
- * + VMStateField.num_indirect
111
- * contains the number of entries in the array. See the VMS_ARRAY
112
- * description regarding array handling in general. May not be
113
- * combined with VMS_ARRAY or any other VMS_VARRAY*. */
114
- VMS_VARRAY_UINT16 = 0x080,
115
-
112
/* The size of the individual entries (a single array entry if
117
- * VMS_ARRAY or any of VMS_VARRAY* are set, or the field itself if
113
+ * VMS_ARRAY or VMS_VARRAY are set, or the field itself if
114
* neither is set) is variable (i.e. not known at compile-time),
115
* but the same for all entries. Use the integer at opaque +
116
* VMStateField.size_indirect (subject to VMS_MULTIPLY) to determine
@@ -128,20 +124,6 @@ enum VMStateFlags {
124
* allocated. Only valid in combination with VMS_VBUFFER. */
125
VMS_MULTIPLY = 0x200,
126
131
- /* The field is an array of variable size. The uint8_t at opaque +
132
- * VMStateField.num_indirect
133
- * contains the number of entries in the array. See the VMS_ARRAY
134
- * description regarding array handling in general. May not be
135
- * combined with VMS_ARRAY or any other VMS_VARRAY*. */
136
- VMS_VARRAY_UINT8 = 0x400,
137
-
138
- /* The field is an array of variable size. The uint32_t at opaque
139
- * + VMStateField.num_indirect
140
- * contains the number of entries in the array. See the VMS_ARRAY
141
- * description regarding array handling in general. May not be
142
- * combined with VMS_ARRAY or any other VMS_VARRAY*. */
143
- VMS_VARRAY_UINT32 = 0x800,
144
-
127
/* Fail loading the serialised VM state if this field is missing
128
* from the input. */
129
VMS_MUST_EXIST = 0x1000,
@@ -530,7 +512,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
512
.num_indirect = vmstate_field_offset(_state, _field_num), \
513
.info = &(_info), \
514
.size = sizeof(_type), \
533
- .flags = VMS_VARRAY_INT32|VMS_POINTER, \
515
+ .flags = VMS_VARRAY | VMS_POINTER, \
516
.offset = vmstate_offset_pointer(_state, _field, _type), \
517
}
518
@@ -540,7 +522,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
522
.num_indirect = vmstate_field_offset(_state, _field_num), \
523
.info = &(_info), \
524
.size = sizeof(_type), \
543
- .flags = VMS_VARRAY_UINT32|VMS_POINTER, \
525
+ .flags = VMS_VARRAY | VMS_POINTER, \
526
.offset = vmstate_offset_pointer(_state, _field, _type), \
527
}
528
@@ -550,7 +532,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
532
.num_indirect = vmstate_field_offset(_state, _field_num), \
533
.info = &(_info), \
534
.size = sizeof(_type), \
553
- .flags = VMS_VARRAY_INT32 | VMS_POINTER | VMS_ALLOC, \
535
+ .flags = VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \
536
.offset = vmstate_offset_pointer(_state, _field, _type), \
537
}
538
@@ -560,7 +542,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
542
.num_indirect = vmstate_field_offset(_state, _field_num), \
543
.info = &(_info), \
544
.size = sizeof(_type), \
563
- .flags = VMS_VARRAY_UINT32|VMS_POINTER|VMS_ALLOC, \
545
+ .flags = VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \
546
.offset = vmstate_offset_pointer(_state, _field, _type), \
547
}
548
@@ -570,7 +552,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
552
.num_indirect = vmstate_field_offset(_state, _field_num), \
553
.info = &(_info), \
554
.size = sizeof(_type), \
573
- .flags = VMS_VARRAY_UINT16 | VMS_POINTER | VMS_ALLOC, \
555
+ .flags = VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \
556
.offset = vmstate_offset_pointer(_state, _field, _type), \
557
}
558
@@ -580,7 +562,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
562
.num_indirect = vmstate_field_offset(_state, _field_num), \
563
.info = &(_info), \
564
.size = sizeof(_type), \
583
- .flags = VMS_VARRAY_UINT16, \
565
+ .flags = VMS_VARRAY, \
566
.offset = vmstate_offset_varray(_state, _field, _type), \
567
}
568
@@ -659,7 +641,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
641
.num_indirect = vmstate_field_offset(_state, _field_num), \
642
.vmsd = &(_vmsd), \
643
.size = sizeof(_type), \
662
- .flags = VMS_POINTER | VMS_VARRAY_UINT8 | \
644
+ .flags = VMS_POINTER | VMS_VARRAY | \
645
VMS_ARRAY_OF_POINTER | VMS_STRUCT | \
646
VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \
647
.offset = vmstate_offset_pointer(_state, _field, _type *), \
@@ -672,7 +654,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
654
.num_indirect = vmstate_field_offset(_state, _field_num), \
655
.vmsd = &(_vmsd), \
656
.size = sizeof(_type), \
675
- .flags = VMS_POINTER | VMS_VARRAY_UINT32 | \
657
+ .flags = VMS_POINTER | VMS_VARRAY | \
658
VMS_ARRAY_OF_POINTER | VMS_STRUCT | \
659
VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \
660
.offset = vmstate_offset_pointer(_state, _field, _type *), \
@@ -683,7 +665,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
665
.version_id = (_version), \
666
.num_indirect = vmstate_field_offset(_state, _field_num), \
667
.info = &(_info), \
686
- .flags = VMS_VARRAY_UINT32 | VMS_ARRAY_OF_POINTER | VMS_POINTER, \
668
+ .flags = VMS_VARRAY | VMS_ARRAY_OF_POINTER | VMS_POINTER, \
669
.offset = vmstate_offset_pointer(_state, _field, _type *), \
670
}
671
@@ -727,7 +709,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
709
.version_id = (_version), \
710
.vmsd = &(_vmsd), \
711
.size = sizeof(_type), \
730
- .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \
712
+ .flags = VMS_STRUCT | VMS_VARRAY, \
713
.offset = vmstate_offset_varray(_state, _field, _type), \
714
}
715
@@ -750,7 +732,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
732
.num_indirect = vmstate_field_offset(_state, _field_num), \
733
.size = sizeof(_type), \
734
.vmsd = &(_vmsd), \
753
- .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
735
+ .flags = VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \
736
.offset = vmstate_offset_pointer(_state, _field, _type), \
737
}
738
@@ -760,7 +742,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
742
.num_indirect = vmstate_field_offset(_state, _field_num), \
743
.size = sizeof(_type), \
744
.vmsd = &(_vmsd), \
763
- .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
745
+ .flags = VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \
746
.offset = vmstate_offset_pointer(_state, _field, _type), \
747
}
748
@@ -770,7 +752,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
752
.num_indirect = vmstate_field_offset(_state, _field_num), \
753
.size = sizeof(_type), \
754
.vmsd = &(_vmsd), \
773
- .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \
755
+ .flags = VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \
756
.offset = vmstate_offset_pointer(_state, _field, _type), \
757
}
758
@@ -780,7 +762,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
762
.version_id = (_version), \
763
.vmsd = &(_vmsd), \
764
.size = sizeof(_type), \
783
- .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \
765
+ .flags = VMS_STRUCT | VMS_VARRAY, \
766
.offset = vmstate_offset_varray(_state, _field, _type), \
767
}
768
@@ -790,7 +772,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
772
.vmsd = &(_vmsd), \
773
.num_indirect = vmstate_field_offset(_state, _field_num), \
774
.size = sizeof(_type), \
793
- .flags = VMS_STRUCT|VMS_VARRAY_INT32|VMS_ALLOC|VMS_POINTER, \
775
+ .flags = VMS_STRUCT | VMS_VARRAY | VMS_ALLOC | VMS_POINTER, \
776
.offset = vmstate_offset_pointer(_state, _field, _type), \
777
}
778
@@ -915,7 +897,7 @@ extern const VMStateInfo vmstate_info_g_byte_array;
897
.version_id = (_version), \
898
.size = (_size), \
899
.info = &vmstate_info_unused_buffer, \
918
- .flags = VMS_VARRAY_UINT32 | VMS_BUFFER, \
900
+ .flags = VMS_VARRAY | VMS_BUFFER, \
901
}
902
903
/* _field_size should be a int32_t field in the _state struct giving the
migration/savevm.c
+2
-4
@@ -884,11 +884,9 @@ static void vmstate_check(const VMStateDescription *vmsd)
884
}
885
/*
886
* VMS_ARRAY_OF_POINTER must be used only together with one
887
- * of VMS_(V)ARRAY* flags.
887
+ * of VMS_(V)ARRAY flags.
888
*/
889
- assert(field->flags & (VMS_ARRAY | VMS_VARRAY_INT32 |
890
- VMS_VARRAY_UINT16 | VMS_VARRAY_UINT8 |
891
- VMS_VARRAY_UINT32));
889
+ assert(field->flags & (VMS_ARRAY | VMS_VARRAY));
890
}
891
892
if (field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) {
migration/vmstate.c
+1
-2
@@ -114,8 +114,7 @@ static uint64_t vmstate_n_elems(void *opaque, const VMStateField *field)
114
115
if (field->flags & VMS_ARRAY) {
116
n_elems = field->num;
117
- } else if (field->flags & (VMS_VARRAY_INT32 | VMS_VARRAY_UINT32
118
- | VMS_VARRAY_UINT16 | VMS_VARRAY_UINT8)) {
117
+ } else if (field->flags & VMS_VARRAY) {
118
n_elems = vmstate_read_from_offset(&field->num_indirect, opaque);
119
}
120
rust/bindings/migration-sys/lib.rs
+1
-6
@@ -57,12 +57,7 @@ pub trait VMStateFlagsExt {
57
}
58
59
impl VMStateFlagsExt for VMStateFlags {
60
- const VMS_VARRAY_FLAGS: VMStateFlags = VMStateFlags(
61
- VMStateFlags::VMS_VARRAY_INT32.0
62
- | VMStateFlags::VMS_VARRAY_UINT8.0
63
- | VMStateFlags::VMS_VARRAY_UINT16.0
64
- | VMStateFlags::VMS_VARRAY_UINT32.0,
65
- );
60
+ const VMS_VARRAY_FLAGS: VMStateFlags = VMStateFlags(VMStateFlags::VMS_VARRAY.0);
61
}
62
63
// Add a couple builder-style methods to VMStateField, allowing
rust/migration/src/vmstate.rs
+3
-3
@@ -250,9 +250,9 @@ impl_vmstate_scalar!(vmstate_info_int8, i8);
250
impl_vmstate_scalar!(vmstate_info_int16, i16);
251
impl_vmstate_scalar!(vmstate_info_int32, i32);
252
impl_vmstate_scalar!(vmstate_info_int64, i64);
253
-impl_vmstate_scalar!(vmstate_info_uint8, u8, VMS_VARRAY_UINT8);
254
-impl_vmstate_scalar!(vmstate_info_uint16, u16, VMS_VARRAY_UINT16);
255
-impl_vmstate_scalar!(vmstate_info_uint32, u32, VMS_VARRAY_UINT32);
253
+impl_vmstate_scalar!(vmstate_info_uint8, u8, VMS_VARRAY);
254
+impl_vmstate_scalar!(vmstate_info_uint16, u16, VMS_VARRAY);
255
+impl_vmstate_scalar!(vmstate_info_uint32, u32, VMS_VARRAY);
256
impl_vmstate_scalar!(vmstate_info_uint64, u64);
257
impl_vmstate_scalar!(vmstate_info_timer, util::timer::Timer);
258
rust/tests/tests/vmstate_tests.rs
+2
-2
@@ -113,7 +113,7 @@ fn test_vmstate_varray_uint16_unsafe() {
113
assert_eq!(foo_fields[2].version_id, 0);
114
assert_eq!(foo_fields[2].size, 1);
115
assert_eq!(foo_fields[2].num, 0);
116
- assert_eq!(foo_fields[2].flags, VMStateFlags::VMS_VARRAY_UINT16);
116
+ assert_eq!(foo_fields[2].flags, VMStateFlags::VMS_VARRAY);
117
assert!(foo_fields[2].vmsd.is_null());
118
assert!(foo_fields[2].field_exists.is_none());
119
}
@@ -222,7 +222,7 @@ fn test_vmstate_struct_varray_uint8() {
222
assert_eq!(foo_fields[2].num, 0);
223
assert_eq!(
224
foo_fields[2].flags.0,
225
- VMStateFlags::VMS_STRUCT.0 | VMStateFlags::VMS_VARRAY_UINT8.0
225
+ VMStateFlags::VMS_STRUCT.0 | VMStateFlags::VMS_VARRAY.0
226
);
227
assert_eq!(foo_fields[2].vmsd, VMSTATE_FOOA.as_ref());
228
assert!(foo_fields[2].field_exists.is_none());