2 * QEMU migration/snapshot declarations
4 * Copyright (c) 2009-2011 Red Hat, Inc.
6 * Original author: Juan Quintela <quintela@redhat.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 #ifndef QEMU_VMSTATE_H
28 #define QEMU_VMSTATE_H
30 typedef struct VMStateInfo VMStateInfo
;
31 typedef struct VMStateField VMStateField
;
33 /* VMStateInfo allows customized migration of objects that don't fit in
34 * any category in VMStateFlags. Additional information is always passed
35 * into get and put in terms of field and vmdesc parameters. However
36 * these two parameters should only be used in cases when customized
37 * handling is needed, such as QTAILQ. For primitive data types such as
38 * integer, field and vmdesc parameters should be ignored inside get/put.
42 int (*get
)(QEMUFile
*f
, void *pv
, size_t size
, const VMStateField
*field
);
43 int (*put
)(QEMUFile
*f
, void *pv
, size_t size
, const VMStateField
*field
,
51 /* The struct member at opaque + VMStateField.offset is a pointer
52 * to the actual field (e.g. struct a { uint8_t *b;
53 * }). Dereference the pointer before using it as basis for
54 * further pointer arithmetic (see e.g. VMS_ARRAY). Does not
55 * affect the meaning of VMStateField.num_offset or
56 * VMStateField.size_offset; see VMS_VARRAY* and VMS_VBUFFER for
60 /* The field is an array of fixed size. VMStateField.num contains
61 * the number of entries in the array. The size of each entry is
62 * given by VMStateField.size and / or opaque +
63 * VMStateField.size_offset; see VMS_VBUFFER and
64 * VMS_MULTIPLY. Each array entry will be processed individually
65 * (VMStateField.info.get()/put() if VMS_STRUCT is not set,
66 * recursion into VMStateField.vmsd if VMS_STRUCT is set). May not
67 * be combined with VMS_VARRAY*. */
70 /* The field is itself a struct, containing one or more
71 * fields. Recurse into VMStateField.vmsd. Most useful in
72 * combination with VMS_ARRAY / VMS_VARRAY*, recursing into each
76 /* The field is an array of variable size. The int32_t at opaque +
77 * VMStateField.num_offset contains the number of entries in the
78 * array. See the VMS_ARRAY description regarding array handling
79 * in general. May not be combined with VMS_ARRAY or any other
81 VMS_VARRAY_INT32
= 0x010,
86 /* The field is a (fixed-size or variable-size) array of pointers
87 * (e.g. struct a { uint8_t *b[]; }). Dereference each array entry
88 * before using it. Note: Does not imply any one of VMS_ARRAY /
89 * VMS_VARRAY*; these need to be set explicitly. */
90 VMS_ARRAY_OF_POINTER
= 0x040,
92 /* The field is an array of variable size. The uint16_t at opaque
93 * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
94 * contains the number of entries in the array. See the VMS_ARRAY
95 * description regarding array handling in general. May not be
96 * combined with VMS_ARRAY or any other VMS_VARRAY*. */
97 VMS_VARRAY_UINT16
= 0x080,
99 /* The size of the individual entries (a single array entry if
100 * VMS_ARRAY or any of VMS_VARRAY* are set, or the field itself if
101 * neither is set) is variable (i.e. not known at compile-time),
102 * but the same for all entries. Use the int32_t at opaque +
103 * VMStateField.size_offset (subject to VMS_MULTIPLY) to determine
104 * the size of each (and every) entry. */
107 /* Multiply the entry size given by the int32_t at opaque +
108 * VMStateField.size_offset (see VMS_VBUFFER description) with
109 * VMStateField.size to determine the number of bytes to be
110 * allocated. Only valid in combination with VMS_VBUFFER. */
111 VMS_MULTIPLY
= 0x200,
113 /* The field is an array of variable size. The uint8_t at opaque +
114 * VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
115 * contains the number of entries in the array. See the VMS_ARRAY
116 * description regarding array handling in general. May not be
117 * combined with VMS_ARRAY or any other VMS_VARRAY*. */
118 VMS_VARRAY_UINT8
= 0x400,
120 /* The field is an array of variable size. The uint32_t at opaque
121 * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
122 * contains the number of entries in the array. See the VMS_ARRAY
123 * description regarding array handling in general. May not be
124 * combined with VMS_ARRAY or any other VMS_VARRAY*. */
125 VMS_VARRAY_UINT32
= 0x800,
127 /* Fail loading the serialised VM state if this field is missing
129 VMS_MUST_EXIST
= 0x1000,
131 /* When loading serialised VM state, allocate memory for the
132 * (entire) field. Only valid in combination with
133 * VMS_POINTER. Note: Not all combinations with other flags are
134 * currently supported, e.g. VMS_ALLOC|VMS_ARRAY_OF_POINTER won't
135 * cause the individual entries to be allocated. */
138 /* Multiply the number of entries given by the integer at opaque +
139 * VMStateField.num_offset (see VMS_VARRAY*) with VMStateField.num
140 * to determine the number of entries in the array. Only valid in
141 * combination with one of VMS_VARRAY*. */
142 VMS_MULTIPLY_ELEMENTS
= 0x4000,
144 /* A structure field that is like VMS_STRUCT, but uses
145 * VMStateField.struct_version_id to tell which version of the
146 * structure we are referencing to use. */
147 VMS_VSTRUCT
= 0x8000,
152 MIG_PRI_IOMMU
, /* Must happen before PCI devices */
153 MIG_PRI_PCI_BUS
, /* Must happen before IOMMU */
154 MIG_PRI_GICV3_ITS
, /* Must happen before PCI devices */
155 MIG_PRI_GICV3
, /* Must happen before the ITS */
159 struct VMStateField
{
161 const char *err_hint
;
168 const VMStateInfo
*info
;
169 enum VMStateFlags flags
;
170 const VMStateDescription
*vmsd
;
172 int struct_version_id
;
173 bool (*field_exists
)(void *opaque
, int version_id
);
176 struct VMStateDescription
{
180 int minimum_version_id
;
181 int minimum_version_id_old
;
182 MigrationPriority priority
;
183 LoadStateHandler
*load_state_old
;
184 int (*pre_load
)(void *opaque
);
185 int (*post_load
)(void *opaque
, int version_id
);
186 int (*pre_save
)(void *opaque
);
187 int (*post_save
)(void *opaque
);
188 bool (*needed
)(void *opaque
);
189 const VMStateField
*fields
;
190 const VMStateDescription
**subsections
;
193 extern const VMStateDescription vmstate_dummy
;
195 extern const VMStateInfo vmstate_info_bool
;
197 extern const VMStateInfo vmstate_info_int8
;
198 extern const VMStateInfo vmstate_info_int16
;
199 extern const VMStateInfo vmstate_info_int32
;
200 extern const VMStateInfo vmstate_info_int64
;
202 extern const VMStateInfo vmstate_info_uint8_equal
;
203 extern const VMStateInfo vmstate_info_uint16_equal
;
204 extern const VMStateInfo vmstate_info_int32_equal
;
205 extern const VMStateInfo vmstate_info_uint32_equal
;
206 extern const VMStateInfo vmstate_info_uint64_equal
;
207 extern const VMStateInfo vmstate_info_int32_le
;
209 extern const VMStateInfo vmstate_info_uint8
;
210 extern const VMStateInfo vmstate_info_uint16
;
211 extern const VMStateInfo vmstate_info_uint32
;
212 extern const VMStateInfo vmstate_info_uint64
;
214 /** Put this in the stream when migrating a null pointer.*/
215 #define VMS_NULLPTR_MARKER (0x30U) /* '0' */
216 extern const VMStateInfo vmstate_info_nullptr
;
218 extern const VMStateInfo vmstate_info_float64
;
219 extern const VMStateInfo vmstate_info_cpudouble
;
221 extern const VMStateInfo vmstate_info_timer
;
222 extern const VMStateInfo vmstate_info_buffer
;
223 extern const VMStateInfo vmstate_info_unused_buffer
;
224 extern const VMStateInfo vmstate_info_tmp
;
225 extern const VMStateInfo vmstate_info_bitmap
;
226 extern const VMStateInfo vmstate_info_qtailq
;
228 #define type_check_2darray(t1,t2,n,m) ((t1(*)[n][m])0 - (t2*)0)
230 * Check that type t2 is an array of type t1 of size n,
231 * e.g. if t1 is 'foo' and n is 32 then t2 must be 'foo[32]'
233 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
234 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
236 * type of element 0 of the specified (array) field of the type.
237 * Note that if the field is a pointer then this will return the
238 * pointed-to type rather than complaining.
240 #define typeof_elt_of_field(type, field) typeof(((type *)0)->field[0])
241 /* Check that field f in struct type t2 is an array of t1, of any size */
242 #define type_check_varray(t1, t2, f) \
243 (type_check(t1, typeof_elt_of_field(t2, f)) \
244 + QEMU_BUILD_BUG_ON_ZERO(!QEMU_IS_ARRAY(((t2 *)0)->f)))
246 #define vmstate_offset_value(_state, _field, _type) \
247 (offsetof(_state, _field) + \
248 type_check(_type, typeof_field(_state, _field)))
250 #define vmstate_offset_pointer(_state, _field, _type) \
251 (offsetof(_state, _field) + \
252 type_check_pointer(_type, typeof_field(_state, _field)))
254 #define vmstate_offset_array(_state, _field, _type, _num) \
255 (offsetof(_state, _field) + \
256 type_check_array(_type, typeof_field(_state, _field), _num))
258 #define vmstate_offset_2darray(_state, _field, _type, _n1, _n2) \
259 (offsetof(_state, _field) + \
260 type_check_2darray(_type, typeof_field(_state, _field), _n1, _n2))
262 #define vmstate_offset_sub_array(_state, _field, _type, _start) \
263 vmstate_offset_value(_state, _field[_start], _type)
265 #define vmstate_offset_buffer(_state, _field) \
266 vmstate_offset_array(_state, _field, uint8_t, \
267 sizeof(typeof_field(_state, _field)))
269 #define vmstate_offset_varray(_state, _field, _type) \
270 (offsetof(_state, _field) + \
271 type_check_varray(_type, _state, _field))
273 /* In the macros below, if there is a _version, that means the macro's
274 * field will be processed only if the version being received is >=
275 * the _version specified. In general, if you add a new field, you
276 * would increment the structure's version and put that version
277 * number into the new field so it would only be processed with the
280 * In particular, for VMSTATE_STRUCT() and friends the _version does
281 * *NOT* pick the version of the sub-structure. It works just as
282 * specified above. The version of the top-level structure received
283 * is passed down to all sub-structures. This means that the
284 * sub-structures must have version that are compatible with all the
285 * structures that use them.
287 * If you want to specify the version of the sub-structure, use
288 * VMSTATE_VSTRUCT(), which allows the specific sub-structure version
289 * to be directly specified.
292 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
293 .name = (stringify(_field)), \
294 .version_id = (_version), \
295 .field_exists = (_test), \
296 .size = sizeof(_type), \
298 .flags = VMS_SINGLE, \
299 .offset = vmstate_offset_value(_state, _field, _type), \
302 #define VMSTATE_SINGLE_FULL(_field, _state, _test, _version, _info, \
303 _type, _err_hint) { \
304 .name = (stringify(_field)), \
305 .err_hint = (_err_hint), \
306 .version_id = (_version), \
307 .field_exists = (_test), \
308 .size = sizeof(_type), \
310 .flags = VMS_SINGLE, \
311 .offset = vmstate_offset_value(_state, _field, _type), \
314 /* Validate state using a boolean predicate. */
315 #define VMSTATE_VALIDATE(_name, _test) { \
317 .field_exists = (_test), \
318 .flags = VMS_ARRAY | VMS_MUST_EXIST, \
319 .num = 0, /* 0 elements: no data, only run _test */ \
322 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
323 .name = (stringify(_field)), \
324 .version_id = (_version), \
326 .size = sizeof(_type), \
327 .flags = VMS_SINGLE|VMS_POINTER, \
328 .offset = vmstate_offset_value(_state, _field, _type), \
331 #define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) { \
332 .name = (stringify(_field)), \
334 .field_exists = (_test), \
335 .size = sizeof(_type), \
336 .flags = VMS_SINGLE|VMS_POINTER, \
337 .offset = vmstate_offset_value(_state, _field, _type), \
340 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
341 .name = (stringify(_field)), \
342 .version_id = (_version), \
345 .size = sizeof(_type), \
346 .flags = VMS_ARRAY, \
347 .offset = vmstate_offset_array(_state, _field, _type, _num), \
350 #define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _version, _info, _type) { \
351 .name = (stringify(_field)), \
352 .version_id = (_version), \
353 .num = (_n1) * (_n2), \
355 .size = sizeof(_type), \
356 .flags = VMS_ARRAY, \
357 .offset = vmstate_offset_2darray(_state, _field, _type, _n1, _n2), \
360 #define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info, _type) { \
361 .name = (stringify(_field)), \
362 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
363 .num = (_multiply), \
365 .size = sizeof(_type), \
366 .flags = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS, \
367 .offset = vmstate_offset_varray(_state, _field, _type), \
370 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
371 .name = (stringify(_field)), \
372 .field_exists = (_test), \
375 .size = sizeof(_type), \
376 .flags = VMS_ARRAY, \
377 .offset = vmstate_offset_array(_state, _field, _type, _num),\
380 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
381 .name = (stringify(_field)), \
382 .version_id = (_version), \
385 .size = sizeof(_type), \
386 .flags = VMS_ARRAY, \
387 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
390 #define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\
391 .name = (stringify(_field)), \
392 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
394 .size = sizeof(_type), \
395 .flags = VMS_VARRAY_INT32, \
396 .offset = vmstate_offset_varray(_state, _field, _type), \
399 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
400 .name = (stringify(_field)), \
401 .version_id = (_version), \
402 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
404 .size = sizeof(_type), \
405 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
406 .offset = vmstate_offset_pointer(_state, _field, _type), \
409 #define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\
410 .name = (stringify(_field)), \
411 .version_id = (_version), \
412 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
414 .size = sizeof(_type), \
415 .flags = VMS_VARRAY_UINT32|VMS_POINTER, \
416 .offset = vmstate_offset_pointer(_state, _field, _type), \
419 #define VMSTATE_VARRAY_UINT32_ALLOC(_field, _state, _field_num, _version, _info, _type) {\
420 .name = (stringify(_field)), \
421 .version_id = (_version), \
422 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
424 .size = sizeof(_type), \
425 .flags = VMS_VARRAY_UINT32|VMS_POINTER|VMS_ALLOC, \
426 .offset = vmstate_offset_pointer(_state, _field, _type), \
429 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
430 .name = (stringify(_field)), \
431 .version_id = (_version), \
432 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
434 .size = sizeof(_type), \
435 .flags = VMS_VARRAY_UINT16, \
436 .offset = vmstate_offset_varray(_state, _field, _type), \
439 #define VMSTATE_VSTRUCT_TEST(_field, _state, _test, _version, _vmsd, _type, _struct_version) { \
440 .name = (stringify(_field)), \
441 .version_id = (_version), \
442 .struct_version_id = (_struct_version), \
443 .field_exists = (_test), \
445 .size = sizeof(_type), \
446 .flags = VMS_VSTRUCT, \
447 .offset = vmstate_offset_value(_state, _field, _type), \
450 #define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \
451 .name = (stringify(_field)), \
452 .version_id = (_version), \
453 .field_exists = (_test), \
455 .size = sizeof(_type), \
456 .flags = VMS_STRUCT, \
457 .offset = vmstate_offset_value(_state, _field, _type), \
460 #define VMSTATE_STRUCT_POINTER_V(_field, _state, _version, _vmsd, _type) { \
461 .name = (stringify(_field)), \
462 .version_id = (_version), \
464 .size = sizeof(_type *), \
465 .flags = VMS_STRUCT|VMS_POINTER, \
466 .offset = vmstate_offset_pointer(_state, _field, _type), \
469 #define VMSTATE_STRUCT_POINTER_TEST_V(_field, _state, _test, _version, _vmsd, _type) { \
470 .name = (stringify(_field)), \
471 .version_id = (_version), \
472 .field_exists = (_test), \
474 .size = sizeof(_type *), \
475 .flags = VMS_STRUCT|VMS_POINTER, \
476 .offset = vmstate_offset_pointer(_state, _field, _type), \
479 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
480 .name = (stringify(_field)), \
481 .version_id = (_version), \
484 .size = sizeof(_type), \
485 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
486 .offset = vmstate_offset_array(_state, _field, _type, _num), \
489 #define VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n, _v, _vmsd, _type) { \
490 .name = (stringify(_f)), \
491 .version_id = (_v), \
494 .size = sizeof(_type *), \
495 .flags = VMS_ARRAY|VMS_STRUCT|VMS_ARRAY_OF_POINTER, \
496 .offset = vmstate_offset_array(_s, _f, _type*, _n), \
499 #define VMSTATE_STRUCT_SUB_ARRAY(_field, _state, _start, _num, _version, _vmsd, _type) { \
500 .name = (stringify(_field)), \
501 .version_id = (_version), \
504 .size = sizeof(_type), \
505 .flags = VMS_STRUCT|VMS_ARRAY, \
506 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
509 #define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \
510 .name = (stringify(_field)), \
512 .field_exists = (_test), \
513 .version_id = (_version), \
515 .size = sizeof(_type), \
516 .flags = VMS_STRUCT|VMS_ARRAY, \
517 .offset = vmstate_offset_array(_state, _field, _type, _num),\
520 #define VMSTATE_STRUCT_2DARRAY_TEST(_field, _state, _n1, _n2, _test, \
521 _version, _vmsd, _type) { \
522 .name = (stringify(_field)), \
523 .num = (_n1) * (_n2), \
524 .field_exists = (_test), \
525 .version_id = (_version), \
527 .size = sizeof(_type), \
528 .flags = VMS_STRUCT | VMS_ARRAY, \
529 .offset = vmstate_offset_2darray(_state, _field, _type, \
533 #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \
534 .name = (stringify(_field)), \
535 .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
536 .version_id = (_version), \
538 .size = sizeof(_type), \
539 .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \
540 .offset = vmstate_offset_varray(_state, _field, _type), \
543 /* a variable length array (i.e. _type *_field) but we know the
546 #define VMSTATE_STRUCT_VARRAY_POINTER_KNOWN(_field, _state, _num, _version, _vmsd, _type) { \
547 .name = (stringify(_field)), \
549 .version_id = (_version), \
551 .size = sizeof(_type), \
552 .flags = VMS_STRUCT|VMS_ARRAY|VMS_POINTER, \
553 .offset = offsetof(_state, _field), \
556 #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \
557 .name = (stringify(_field)), \
559 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
560 .size = sizeof(_type), \
562 .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
563 .offset = vmstate_offset_pointer(_state, _field, _type), \
566 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \
567 .name = (stringify(_field)), \
569 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
570 .size = sizeof(_type), \
572 .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
573 .offset = vmstate_offset_pointer(_state, _field, _type), \
576 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
577 .name = (stringify(_field)), \
579 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
580 .size = sizeof(_type), \
582 .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \
583 .offset = vmstate_offset_pointer(_state, _field, _type), \
586 #define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \
587 .name = (stringify(_field)), \
588 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
589 .version_id = (_version), \
591 .size = sizeof(_type), \
592 .flags = VMS_STRUCT|VMS_VARRAY_INT32, \
593 .offset = vmstate_offset_varray(_state, _field, _type), \
596 #define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \
597 .name = (stringify(_field)), \
598 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \
599 .version_id = (_version), \
601 .size = sizeof(_type), \
602 .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \
603 .offset = vmstate_offset_varray(_state, _field, _type), \
606 #define VMSTATE_STRUCT_VARRAY_ALLOC(_field, _state, _field_num, _version, _vmsd, _type) {\
607 .name = (stringify(_field)), \
608 .version_id = (_version), \
610 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
611 .size = sizeof(_type), \
612 .flags = VMS_STRUCT|VMS_VARRAY_INT32|VMS_ALLOC|VMS_POINTER, \
613 .offset = vmstate_offset_pointer(_state, _field, _type), \
616 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
617 .name = (stringify(_field)), \
618 .version_id = (_version), \
619 .field_exists = (_test), \
620 .size = (_size - _start), \
621 .info = &vmstate_info_buffer, \
622 .flags = VMS_BUFFER, \
623 .offset = vmstate_offset_buffer(_state, _field) + _start, \
626 #define VMSTATE_VBUFFER_MULTIPLY(_field, _state, _version, _test, \
627 _field_size, _multiply) { \
628 .name = (stringify(_field)), \
629 .version_id = (_version), \
630 .field_exists = (_test), \
631 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
632 .size = (_multiply), \
633 .info = &vmstate_info_buffer, \
634 .flags = VMS_VBUFFER|VMS_POINTER|VMS_MULTIPLY, \
635 .offset = offsetof(_state, _field), \
638 #define VMSTATE_VBUFFER(_field, _state, _version, _test, _field_size) { \
639 .name = (stringify(_field)), \
640 .version_id = (_version), \
641 .field_exists = (_test), \
642 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
643 .info = &vmstate_info_buffer, \
644 .flags = VMS_VBUFFER|VMS_POINTER, \
645 .offset = offsetof(_state, _field), \
648 #define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _field_size) { \
649 .name = (stringify(_field)), \
650 .version_id = (_version), \
651 .field_exists = (_test), \
652 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
653 .info = &vmstate_info_buffer, \
654 .flags = VMS_VBUFFER|VMS_POINTER, \
655 .offset = offsetof(_state, _field), \
658 #define VMSTATE_VBUFFER_ALLOC_UINT32(_field, _state, _version, \
659 _test, _field_size) { \
660 .name = (stringify(_field)), \
661 .version_id = (_version), \
662 .field_exists = (_test), \
663 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
664 .info = &vmstate_info_buffer, \
665 .flags = VMS_VBUFFER|VMS_POINTER|VMS_ALLOC, \
666 .offset = offsetof(_state, _field), \
669 #define VMSTATE_BUFFER_UNSAFE_INFO_TEST(_field, _state, _test, _version, _info, _size) { \
670 .name = (stringify(_field)), \
671 .version_id = (_version), \
672 .field_exists = (_test), \
675 .flags = VMS_BUFFER, \
676 .offset = offsetof(_state, _field), \
679 #define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _version, _size) { \
680 .name = (stringify(_field)), \
681 .version_id = (_version), \
683 .info = &vmstate_info_buffer, \
684 .flags = VMS_BUFFER|VMS_POINTER, \
685 .offset = offsetof(_state, _field), \
688 /* Allocate a temporary of type 'tmp_type', set tmp->parent to _state
689 * and execute the vmsd on the temporary. Note that we're working with
690 * the whole of _state here, not a field within it.
691 * We compile time check that:
692 * That _tmp_type contains a 'parent' member that's a pointer to the
694 * That the pointer is right at the start of _tmp_type.
696 #define VMSTATE_WITH_TMP(_state, _tmp_type, _vmsd) { \
698 .size = sizeof(_tmp_type) + \
699 QEMU_BUILD_BUG_ON_ZERO(offsetof(_tmp_type, parent) != 0) + \
700 type_check_pointer(_state, \
701 typeof_field(_tmp_type, parent)), \
703 .info = &vmstate_info_tmp, \
706 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
708 .field_exists = (_test), \
709 .version_id = (_version), \
711 .info = &vmstate_info_unused_buffer, \
712 .flags = VMS_BUFFER, \
715 /* Discard size * field_num bytes, where field_num is a uint32 member */
716 #define VMSTATE_UNUSED_VARRAY_UINT32(_state, _test, _version, _field_num, _size) {\
718 .field_exists = (_test), \
719 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
720 .version_id = (_version), \
722 .info = &vmstate_info_unused_buffer, \
723 .flags = VMS_VARRAY_UINT32 | VMS_BUFFER, \
726 /* _field_size should be a int32_t field in the _state struct giving the
727 * size of the bitmap _field in bits.
729 #define VMSTATE_BITMAP(_field, _state, _version, _field_size) { \
730 .name = (stringify(_field)), \
731 .version_id = (_version), \
732 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
733 .info = &vmstate_info_bitmap, \
734 .flags = VMS_VBUFFER|VMS_POINTER, \
735 .offset = offsetof(_state, _field), \
738 /* For migrating a QTAILQ.
739 * Target QTAILQ needs be properly initialized.
740 * _type: type of QTAILQ element
741 * _next: name of QTAILQ entry field in QTAILQ element
742 * _vmsd: VMSD for QTAILQ element
743 * size: size of QTAILQ element
744 * start: offset of QTAILQ entry in QTAILQ element
746 #define VMSTATE_QTAILQ_V(_field, _state, _version, _vmsd, _type, _next) \
748 .name = (stringify(_field)), \
749 .version_id = (_version), \
751 .size = sizeof(_type), \
752 .info = &vmstate_info_qtailq, \
753 .offset = offsetof(_state, _field), \
754 .start = offsetof(_type, _next), \
758 _f_n : num of elements field_name
760 _s : struct state name
764 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
765 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
767 #define VMSTATE_VSTRUCT(_field, _state, _vmsd, _type, _struct_version)\
768 VMSTATE_VSTRUCT_TEST(_field, _state, NULL, 0, _vmsd, _type, _struct_version)
770 #define VMSTATE_VSTRUCT_V(_field, _state, _version, _vmsd, _type, _struct_version) \
771 VMSTATE_VSTRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type, \
774 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \
775 VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
777 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \
778 VMSTATE_STRUCT_POINTER_V(_field, _state, 0, _vmsd, _type)
780 #define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) \
781 VMSTATE_STRUCT_POINTER_TEST_V(_field, _state, _test, 0, _vmsd, _type)
783 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \
784 VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \
787 #define VMSTATE_STRUCT_2DARRAY(_field, _state, _n1, _n2, _version, \
789 VMSTATE_STRUCT_2DARRAY_TEST(_field, _state, _n1, _n2, NULL, \
790 _version, _vmsd, _type)
792 #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) \
793 VMSTATE_BUFFER_UNSAFE_INFO_TEST(_field, _state, NULL, _version, _info, \
796 #define VMSTATE_BOOL_V(_f, _s, _v) \
797 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool)
799 #define VMSTATE_INT8_V(_f, _s, _v) \
800 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
801 #define VMSTATE_INT16_V(_f, _s, _v) \
802 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
803 #define VMSTATE_INT32_V(_f, _s, _v) \
804 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
805 #define VMSTATE_INT64_V(_f, _s, _v) \
806 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
808 #define VMSTATE_UINT8_V(_f, _s, _v) \
809 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
810 #define VMSTATE_UINT16_V(_f, _s, _v) \
811 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
812 #define VMSTATE_UINT32_V(_f, _s, _v) \
813 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
814 #define VMSTATE_UINT64_V(_f, _s, _v) \
815 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
819 #define VMSTATE_U8_V(_f, _s, _v) \
820 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, __u8)
821 #define VMSTATE_U16_V(_f, _s, _v) \
822 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, __u16)
823 #define VMSTATE_U32_V(_f, _s, _v) \
824 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, __u32)
825 #define VMSTATE_U64_V(_f, _s, _v) \
826 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, __u64)
830 #define VMSTATE_BOOL(_f, _s) \
831 VMSTATE_BOOL_V(_f, _s, 0)
833 #define VMSTATE_INT8(_f, _s) \
834 VMSTATE_INT8_V(_f, _s, 0)
835 #define VMSTATE_INT16(_f, _s) \
836 VMSTATE_INT16_V(_f, _s, 0)
837 #define VMSTATE_INT32(_f, _s) \
838 VMSTATE_INT32_V(_f, _s, 0)
839 #define VMSTATE_INT64(_f, _s) \
840 VMSTATE_INT64_V(_f, _s, 0)
842 #define VMSTATE_UINT8(_f, _s) \
843 VMSTATE_UINT8_V(_f, _s, 0)
844 #define VMSTATE_UINT16(_f, _s) \
845 VMSTATE_UINT16_V(_f, _s, 0)
846 #define VMSTATE_UINT32(_f, _s) \
847 VMSTATE_UINT32_V(_f, _s, 0)
848 #define VMSTATE_UINT64(_f, _s) \
849 VMSTATE_UINT64_V(_f, _s, 0)
853 #define VMSTATE_U8(_f, _s) \
854 VMSTATE_U8_V(_f, _s, 0)
855 #define VMSTATE_U16(_f, _s) \
856 VMSTATE_U16_V(_f, _s, 0)
857 #define VMSTATE_U32(_f, _s) \
858 VMSTATE_U32_V(_f, _s, 0)
859 #define VMSTATE_U64(_f, _s) \
860 VMSTATE_U64_V(_f, _s, 0)
864 #define VMSTATE_UINT8_EQUAL(_f, _s, _err_hint) \
865 VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \
866 vmstate_info_uint8_equal, uint8_t, _err_hint)
868 #define VMSTATE_UINT16_EQUAL(_f, _s, _err_hint) \
869 VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \
870 vmstate_info_uint16_equal, uint16_t, _err_hint)
872 #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v, _err_hint) \
873 VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \
874 vmstate_info_uint16_equal, uint16_t, _err_hint)
876 #define VMSTATE_INT32_EQUAL(_f, _s, _err_hint) \
877 VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \
878 vmstate_info_int32_equal, int32_t, _err_hint)
880 #define VMSTATE_UINT32_EQUAL_V(_f, _s, _v, _err_hint) \
881 VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \
882 vmstate_info_uint32_equal, uint32_t, _err_hint)
884 #define VMSTATE_UINT32_EQUAL(_f, _s, _err_hint) \
885 VMSTATE_UINT32_EQUAL_V(_f, _s, 0, _err_hint)
887 #define VMSTATE_UINT64_EQUAL_V(_f, _s, _v, _err_hint) \
888 VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \
889 vmstate_info_uint64_equal, uint64_t, _err_hint)
891 #define VMSTATE_UINT64_EQUAL(_f, _s, _err_hint) \
892 VMSTATE_UINT64_EQUAL_V(_f, _s, 0, _err_hint)
894 #define VMSTATE_INT32_POSITIVE_LE(_f, _s) \
895 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
897 #define VMSTATE_BOOL_TEST(_f, _s, _t) \
898 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_bool, bool)
900 #define VMSTATE_INT8_TEST(_f, _s, _t) \
901 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int8, int8_t)
903 #define VMSTATE_INT16_TEST(_f, _s, _t) \
904 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int16, int16_t)
906 #define VMSTATE_INT32_TEST(_f, _s, _t) \
907 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int32, int32_t)
909 #define VMSTATE_INT64_TEST(_f, _s, _t) \
910 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int64, int64_t)
912 #define VMSTATE_UINT8_TEST(_f, _s, _t) \
913 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
915 #define VMSTATE_UINT16_TEST(_f, _s, _t) \
916 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
918 #define VMSTATE_UINT32_TEST(_f, _s, _t) \
919 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
921 #define VMSTATE_UINT64_TEST(_f, _s, _t) \
922 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint64, uint64_t)
925 #define VMSTATE_FLOAT64_V(_f, _s, _v) \
926 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_float64, float64)
928 #define VMSTATE_FLOAT64(_f, _s) \
929 VMSTATE_FLOAT64_V(_f, _s, 0)
931 #define VMSTATE_TIMER_PTR_TEST(_f, _s, _test) \
932 VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
934 #define VMSTATE_TIMER_PTR_V(_f, _s, _v) \
935 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
937 #define VMSTATE_TIMER_PTR(_f, _s) \
938 VMSTATE_TIMER_PTR_V(_f, _s, 0)
940 #define VMSTATE_TIMER_PTR_ARRAY(_f, _s, _n) \
941 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
943 #define VMSTATE_TIMER_TEST(_f, _s, _test) \
944 VMSTATE_SINGLE_TEST(_f, _s, _test, 0, vmstate_info_timer, QEMUTimer)
946 #define VMSTATE_TIMER_V(_f, _s, _v) \
947 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_timer, QEMUTimer)
949 #define VMSTATE_TIMER(_f, _s) \
950 VMSTATE_TIMER_V(_f, _s, 0)
952 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
953 VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer)
955 #define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \
956 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool)
958 #define VMSTATE_BOOL_ARRAY(_f, _s, _n) \
959 VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0)
961 #define VMSTATE_BOOL_SUB_ARRAY(_f, _s, _start, _num) \
962 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_bool, bool)
964 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
965 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
967 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v) \
968 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)
970 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
971 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
973 #define VMSTATE_UINT16_SUB_ARRAY(_f, _s, _start, _num) \
974 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint16, uint16_t)
976 #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2) \
977 VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, 0)
979 #define VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, _v) \
980 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint8, uint8_t)
982 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
983 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
985 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
986 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
988 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num) \
989 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)
991 #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2) \
992 VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0)
994 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
995 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
997 #define VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v) \
998 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint32, uint32_t)
1000 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
1001 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
1003 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
1004 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
1006 #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2) \
1007 VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0)
1009 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
1010 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
1012 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
1013 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
1015 #define VMSTATE_UINT64_SUB_ARRAY(_f, _s, _start, _num) \
1016 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint64, uint64_t)
1018 #define VMSTATE_UINT64_2DARRAY(_f, _s, _n1, _n2) \
1019 VMSTATE_UINT64_2DARRAY_V(_f, _s, _n1, _n2, 0)
1021 #define VMSTATE_UINT64_2DARRAY_V(_f, _s, _n1, _n2, _v) \
1022 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint64, uint64_t)
1024 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
1025 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
1027 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
1028 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
1030 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
1031 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
1033 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
1034 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
1036 #define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \
1037 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t)
1039 #define VMSTATE_INT64_ARRAY(_f, _s, _n) \
1040 VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)
1042 #define VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, _v) \
1043 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_float64, float64)
1045 #define VMSTATE_FLOAT64_ARRAY(_f, _s, _n) \
1046 VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, 0)
1048 #define VMSTATE_CPUDOUBLE_ARRAY_V(_f, _s, _n, _v) \
1049 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_cpudouble, CPU_DoubleU)
1051 #define VMSTATE_CPUDOUBLE_ARRAY(_f, _s, _n) \
1052 VMSTATE_CPUDOUBLE_ARRAY_V(_f, _s, _n, 0)
1054 #define VMSTATE_BUFFER_V(_f, _s, _v) \
1055 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
1057 #define VMSTATE_BUFFER(_f, _s) \
1058 VMSTATE_BUFFER_V(_f, _s, 0)
1060 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
1061 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
1063 #define VMSTATE_BUFFER_START_MIDDLE_V(_f, _s, _start, _v) \
1064 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, _start, sizeof(typeof_field(_s, _f)))
1066 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
1067 VMSTATE_BUFFER_START_MIDDLE_V(_f, _s, _start, 0)
1069 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \
1070 VMSTATE_VBUFFER(_f, _s, 0, NULL, _size)
1072 #define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) \
1073 VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, _size)
1075 #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
1076 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
1078 #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
1079 VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
1082 * These VMSTATE_UNUSED*() macros can be used to fill in the holes
1083 * when some of the vmstate fields are obsolete to be compatible with
1084 * migrations between new/old binaries.
1086 * CAUTION: when using any of the VMSTATE_UNUSED*() macros please be
1087 * sure that the size passed in is the size that was actually *sent*
1088 * rather than the size of the *structure*. One example is the
1089 * boolean type - the size of the structure can vary depending on the
1090 * definition of boolean, however the size we actually sent is always
1091 * 1 byte (please refer to implementation of VMSTATE_BOOL_V and
1092 * vmstate_info_bool). So here we should always pass in size==1
1093 * rather than size==sizeof(bool).
1095 #define VMSTATE_UNUSED_V(_v, _size) \
1096 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
1098 #define VMSTATE_UNUSED(_size) \
1099 VMSTATE_UNUSED_V(0, _size)
1101 #define VMSTATE_UNUSED_TEST(_test, _size) \
1102 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
1104 #define VMSTATE_END_OF_LIST() \
1107 int vmstate_load_state(QEMUFile
*f
, const VMStateDescription
*vmsd
,
1108 void *opaque
, int version_id
);
1109 int vmstate_save_state(QEMUFile
*f
, const VMStateDescription
*vmsd
,
1110 void *opaque
, QJSON
*vmdesc
);
1111 int vmstate_save_state_v(QEMUFile
*f
, const VMStateDescription
*vmsd
,
1112 void *opaque
, QJSON
*vmdesc
, int version_id
);
1114 bool vmstate_save_needed(const VMStateDescription
*vmsd
, void *opaque
);
1116 /* Returns: 0 on success, -1 on failure */
1117 int vmstate_register_with_alias_id(DeviceState
*dev
, int instance_id
,
1118 const VMStateDescription
*vmsd
,
1119 void *base
, int alias_id
,
1120 int required_for_version
,
1123 /* Returns: 0 on success, -1 on failure */
1124 static inline int vmstate_register(DeviceState
*dev
, int instance_id
,
1125 const VMStateDescription
*vmsd
,
1128 return vmstate_register_with_alias_id(dev
, instance_id
, vmsd
,
1129 opaque
, -1, 0, NULL
);
1132 void vmstate_unregister(DeviceState
*dev
, const VMStateDescription
*vmsd
,
1135 struct MemoryRegion
;
1136 void vmstate_register_ram(struct MemoryRegion
*memory
, DeviceState
*dev
);
1137 void vmstate_unregister_ram(struct MemoryRegion
*memory
, DeviceState
*dev
);
1138 void vmstate_register_ram_global(struct MemoryRegion
*memory
);
1140 bool vmstate_check_only_migratable(const VMStateDescription
*vmsd
);