vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY
[qemu.git] / include / migration / vmstate.h
blob59fc75e4187b775397b34b3e91fee8cfdf8c409b
1 /*
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
24 * THE SOFTWARE.
27 #ifndef QEMU_VMSTATE_H
28 #define QEMU_VMSTATE_H
30 #include "migration/qjson.h"
32 typedef struct VMStateInfo VMStateInfo;
33 typedef struct VMStateDescription VMStateDescription;
34 typedef struct VMStateField VMStateField;
36 /* VMStateInfo allows customized migration of objects that don't fit in
37 * any category in VMStateFlags. Additional information is always passed
38 * into get and put in terms of field and vmdesc parameters. However
39 * these two parameters should only be used in cases when customized
40 * handling is needed, such as QTAILQ. For primitive data types such as
41 * integer, field and vmdesc parameters should be ignored inside get/put.
43 struct VMStateInfo {
44 const char *name;
45 int (*get)(QEMUFile *f, void *pv, size_t size, VMStateField *field);
46 int (*put)(QEMUFile *f, void *pv, size_t size, VMStateField *field,
47 QJSON *vmdesc);
50 enum VMStateFlags {
51 /* Ignored */
52 VMS_SINGLE = 0x001,
54 /* The struct member at opaque + VMStateField.offset is a pointer
55 * to the actual field (e.g. struct a { uint8_t *b;
56 * }). Dereference the pointer before using it as basis for
57 * further pointer arithmetic (see e.g. VMS_ARRAY). Does not
58 * affect the meaning of VMStateField.num_offset or
59 * VMStateField.size_offset; see VMS_VARRAY* and VMS_VBUFFER for
60 * those. */
61 VMS_POINTER = 0x002,
63 /* The field is an array of fixed size. VMStateField.num contains
64 * the number of entries in the array. The size of each entry is
65 * given by VMStateField.size and / or opaque +
66 * VMStateField.size_offset; see VMS_VBUFFER and
67 * VMS_MULTIPLY. Each array entry will be processed individually
68 * (VMStateField.info.get()/put() if VMS_STRUCT is not set,
69 * recursion into VMStateField.vmsd if VMS_STRUCT is set). May not
70 * be combined with VMS_VARRAY*. */
71 VMS_ARRAY = 0x004,
73 /* The field is itself a struct, containing one or more
74 * fields. Recurse into VMStateField.vmsd. Most useful in
75 * combination with VMS_ARRAY / VMS_VARRAY*, recursing into each
76 * array entry. */
77 VMS_STRUCT = 0x008,
79 /* The field is an array of variable size. The int32_t at opaque +
80 * VMStateField.num_offset contains the number of entries in the
81 * array. See the VMS_ARRAY description regarding array handling
82 * in general. May not be combined with VMS_ARRAY or any other
83 * VMS_VARRAY*. */
84 VMS_VARRAY_INT32 = 0x010,
86 /* Ignored */
87 VMS_BUFFER = 0x020,
89 /* The field is a (fixed-size or variable-size) array of pointers
90 * (e.g. struct a { uint8_t *b[]; }). Dereference each array entry
91 * before using it. Note: Does not imply any one of VMS_ARRAY /
92 * VMS_VARRAY*; these need to be set explicitly. */
93 VMS_ARRAY_OF_POINTER = 0x040,
95 /* The field is an array of variable size. The uint16_t at opaque
96 * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
97 * contains the number of entries in the array. See the VMS_ARRAY
98 * description regarding array handling in general. May not be
99 * combined with VMS_ARRAY or any other VMS_VARRAY*. */
100 VMS_VARRAY_UINT16 = 0x080,
102 /* The size of the individual entries (a single array entry if
103 * VMS_ARRAY or any of VMS_VARRAY* are set, or the field itself if
104 * neither is set) is variable (i.e. not known at compile-time),
105 * but the same for all entries. Use the int32_t at opaque +
106 * VMStateField.size_offset (subject to VMS_MULTIPLY) to determine
107 * the size of each (and every) entry. */
108 VMS_VBUFFER = 0x100,
110 /* Multiply the entry size given by the int32_t at opaque +
111 * VMStateField.size_offset (see VMS_VBUFFER description) with
112 * VMStateField.size to determine the number of bytes to be
113 * allocated. Only valid in combination with VMS_VBUFFER. */
114 VMS_MULTIPLY = 0x200,
116 /* The field is an array of variable size. The uint8_t at opaque +
117 * VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
118 * contains the number of entries in the array. See the VMS_ARRAY
119 * description regarding array handling in general. May not be
120 * combined with VMS_ARRAY or any other VMS_VARRAY*. */
121 VMS_VARRAY_UINT8 = 0x400,
123 /* The field is an array of variable size. The uint32_t at opaque
124 * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
125 * contains the number of entries in the array. See the VMS_ARRAY
126 * description regarding array handling in general. May not be
127 * combined with VMS_ARRAY or any other VMS_VARRAY*. */
128 VMS_VARRAY_UINT32 = 0x800,
130 /* Fail loading the serialised VM state if this field is missing
131 * from the input. */
132 VMS_MUST_EXIST = 0x1000,
134 /* When loading serialised VM state, allocate memory for the
135 * (entire) field. Only valid in combination with
136 * VMS_POINTER. Note: Not all combinations with other flags are
137 * currently supported, e.g. VMS_ALLOC|VMS_ARRAY_OF_POINTER won't
138 * cause the individual entries to be allocated. */
139 VMS_ALLOC = 0x2000,
141 /* Multiply the number of entries given by the integer at opaque +
142 * VMStateField.num_offset (see VMS_VARRAY*) with VMStateField.num
143 * to determine the number of entries in the array. Only valid in
144 * combination with one of VMS_VARRAY*. */
145 VMS_MULTIPLY_ELEMENTS = 0x4000,
148 typedef enum {
149 MIG_PRI_DEFAULT = 0,
150 MIG_PRI_IOMMU, /* Must happen before PCI devices */
151 MIG_PRI_PCI_BUS, /* Must happen before IOMMU */
152 MIG_PRI_GICV3_ITS, /* Must happen before PCI devices */
153 MIG_PRI_GICV3, /* Must happen before the ITS */
154 MIG_PRI_MAX,
155 } MigrationPriority;
157 struct VMStateField {
158 const char *name;
159 const char *err_hint;
160 size_t offset;
161 size_t size;
162 size_t start;
163 int num;
164 size_t num_offset;
165 size_t size_offset;
166 const VMStateInfo *info;
167 enum VMStateFlags flags;
168 const VMStateDescription *vmsd;
169 int version_id;
170 bool (*field_exists)(void *opaque, int version_id);
173 struct VMStateDescription {
174 const char *name;
175 int unmigratable;
176 int version_id;
177 int minimum_version_id;
178 int minimum_version_id_old;
179 MigrationPriority priority;
180 LoadStateHandler *load_state_old;
181 int (*pre_load)(void *opaque);
182 int (*post_load)(void *opaque, int version_id);
183 int (*pre_save)(void *opaque);
184 bool (*needed)(void *opaque);
185 VMStateField *fields;
186 const VMStateDescription **subsections;
189 extern const VMStateDescription vmstate_dummy;
191 extern const VMStateInfo vmstate_info_bool;
193 extern const VMStateInfo vmstate_info_int8;
194 extern const VMStateInfo vmstate_info_int16;
195 extern const VMStateInfo vmstate_info_int32;
196 extern const VMStateInfo vmstate_info_int64;
198 extern const VMStateInfo vmstate_info_uint8_equal;
199 extern const VMStateInfo vmstate_info_uint16_equal;
200 extern const VMStateInfo vmstate_info_int32_equal;
201 extern const VMStateInfo vmstate_info_uint32_equal;
202 extern const VMStateInfo vmstate_info_uint64_equal;
203 extern const VMStateInfo vmstate_info_int32_le;
205 extern const VMStateInfo vmstate_info_uint8;
206 extern const VMStateInfo vmstate_info_uint16;
207 extern const VMStateInfo vmstate_info_uint32;
208 extern const VMStateInfo vmstate_info_uint64;
210 /** Put this in the stream when migrating a null pointer.*/
211 #define VMS_NULLPTR_MARKER (0x30U) /* '0' */
212 extern const VMStateInfo vmstate_info_nullptr;
214 extern const VMStateInfo vmstate_info_float64;
215 extern const VMStateInfo vmstate_info_cpudouble;
217 extern const VMStateInfo vmstate_info_timer;
218 extern const VMStateInfo vmstate_info_buffer;
219 extern const VMStateInfo vmstate_info_unused_buffer;
220 extern const VMStateInfo vmstate_info_tmp;
221 extern const VMStateInfo vmstate_info_bitmap;
222 extern const VMStateInfo vmstate_info_qtailq;
224 #define type_check_2darray(t1,t2,n,m) ((t1(*)[n][m])0 - (t2*)0)
225 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
226 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
228 #define vmstate_offset_value(_state, _field, _type) \
229 (offsetof(_state, _field) + \
230 type_check(_type, typeof_field(_state, _field)))
232 #define vmstate_offset_pointer(_state, _field, _type) \
233 (offsetof(_state, _field) + \
234 type_check_pointer(_type, typeof_field(_state, _field)))
236 #define vmstate_offset_array(_state, _field, _type, _num) \
237 (offsetof(_state, _field) + \
238 type_check_array(_type, typeof_field(_state, _field), _num))
240 #define vmstate_offset_2darray(_state, _field, _type, _n1, _n2) \
241 (offsetof(_state, _field) + \
242 type_check_2darray(_type, typeof_field(_state, _field), _n1, _n2))
244 #define vmstate_offset_sub_array(_state, _field, _type, _start) \
245 vmstate_offset_value(_state, _field[_start], _type)
247 #define vmstate_offset_buffer(_state, _field) \
248 vmstate_offset_array(_state, _field, uint8_t, \
249 sizeof(typeof_field(_state, _field)))
251 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
252 .name = (stringify(_field)), \
253 .version_id = (_version), \
254 .field_exists = (_test), \
255 .size = sizeof(_type), \
256 .info = &(_info), \
257 .flags = VMS_SINGLE, \
258 .offset = vmstate_offset_value(_state, _field, _type), \
261 #define VMSTATE_SINGLE_FULL(_field, _state, _test, _version, _info, \
262 _type, _err_hint) { \
263 .name = (stringify(_field)), \
264 .err_hint = (_err_hint), \
265 .version_id = (_version), \
266 .field_exists = (_test), \
267 .size = sizeof(_type), \
268 .info = &(_info), \
269 .flags = VMS_SINGLE, \
270 .offset = vmstate_offset_value(_state, _field, _type), \
273 /* Validate state using a boolean predicate. */
274 #define VMSTATE_VALIDATE(_name, _test) { \
275 .name = (_name), \
276 .field_exists = (_test), \
277 .flags = VMS_ARRAY | VMS_MUST_EXIST, \
278 .num = 0, /* 0 elements: no data, only run _test */ \
281 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
282 .name = (stringify(_field)), \
283 .version_id = (_version), \
284 .info = &(_info), \
285 .size = sizeof(_type), \
286 .flags = VMS_SINGLE|VMS_POINTER, \
287 .offset = vmstate_offset_value(_state, _field, _type), \
290 #define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) { \
291 .name = (stringify(_field)), \
292 .info = &(_info), \
293 .field_exists = (_test), \
294 .size = sizeof(_type), \
295 .flags = VMS_SINGLE|VMS_POINTER, \
296 .offset = vmstate_offset_value(_state, _field, _type), \
299 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
300 .name = (stringify(_field)), \
301 .version_id = (_version), \
302 .num = (_num), \
303 .info = &(_info), \
304 .size = sizeof(_type), \
305 .flags = VMS_ARRAY, \
306 .offset = vmstate_offset_array(_state, _field, _type, _num), \
309 #define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _version, _info, _type) { \
310 .name = (stringify(_field)), \
311 .version_id = (_version), \
312 .num = (_n1) * (_n2), \
313 .info = &(_info), \
314 .size = sizeof(_type), \
315 .flags = VMS_ARRAY, \
316 .offset = vmstate_offset_2darray(_state, _field, _type, _n1, _n2), \
319 #define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info, _type) { \
320 .name = (stringify(_field)), \
321 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
322 .num = (_multiply), \
323 .info = &(_info), \
324 .size = sizeof(_type), \
325 .flags = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS, \
326 .offset = offsetof(_state, _field), \
329 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
330 .name = (stringify(_field)), \
331 .field_exists = (_test), \
332 .num = (_num), \
333 .info = &(_info), \
334 .size = sizeof(_type), \
335 .flags = VMS_ARRAY, \
336 .offset = vmstate_offset_array(_state, _field, _type, _num),\
339 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
340 .name = (stringify(_field)), \
341 .version_id = (_version), \
342 .num = (_num), \
343 .info = &(_info), \
344 .size = sizeof(_type), \
345 .flags = VMS_ARRAY, \
346 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
349 #define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\
350 .name = (stringify(_field)), \
351 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
352 .info = &(_info), \
353 .size = sizeof(_type), \
354 .flags = VMS_VARRAY_INT32, \
355 .offset = offsetof(_state, _field), \
358 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
359 .name = (stringify(_field)), \
360 .version_id = (_version), \
361 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
362 .info = &(_info), \
363 .size = sizeof(_type), \
364 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
365 .offset = vmstate_offset_pointer(_state, _field, _type), \
368 #define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\
369 .name = (stringify(_field)), \
370 .version_id = (_version), \
371 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
372 .info = &(_info), \
373 .size = sizeof(_type), \
374 .flags = VMS_VARRAY_UINT32|VMS_POINTER, \
375 .offset = vmstate_offset_pointer(_state, _field, _type), \
378 #define VMSTATE_VARRAY_UINT32_ALLOC(_field, _state, _field_num, _version, _info, _type) {\
379 .name = (stringify(_field)), \
380 .version_id = (_version), \
381 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
382 .info = &(_info), \
383 .size = sizeof(_type), \
384 .flags = VMS_VARRAY_UINT32|VMS_POINTER|VMS_ALLOC, \
385 .offset = vmstate_offset_pointer(_state, _field, _type), \
388 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
389 .name = (stringify(_field)), \
390 .version_id = (_version), \
391 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
392 .info = &(_info), \
393 .size = sizeof(_type), \
394 .flags = VMS_VARRAY_UINT16, \
395 .offset = offsetof(_state, _field), \
398 #define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \
399 .name = (stringify(_field)), \
400 .version_id = (_version), \
401 .field_exists = (_test), \
402 .vmsd = &(_vmsd), \
403 .size = sizeof(_type), \
404 .flags = VMS_STRUCT, \
405 .offset = vmstate_offset_value(_state, _field, _type), \
408 #define VMSTATE_STRUCT_POINTER_V(_field, _state, _version, _vmsd, _type) { \
409 .name = (stringify(_field)), \
410 .version_id = (_version), \
411 .vmsd = &(_vmsd), \
412 .size = sizeof(_type *), \
413 .flags = VMS_STRUCT|VMS_POINTER, \
414 .offset = vmstate_offset_pointer(_state, _field, _type), \
417 #define VMSTATE_STRUCT_POINTER_TEST_V(_field, _state, _test, _version, _vmsd, _type) { \
418 .name = (stringify(_field)), \
419 .version_id = (_version), \
420 .field_exists = (_test), \
421 .vmsd = &(_vmsd), \
422 .size = sizeof(_type *), \
423 .flags = VMS_STRUCT|VMS_POINTER, \
424 .offset = vmstate_offset_pointer(_state, _field, _type), \
427 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
428 .name = (stringify(_field)), \
429 .version_id = (_version), \
430 .num = (_num), \
431 .info = &(_info), \
432 .size = sizeof(_type), \
433 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
434 .offset = vmstate_offset_array(_state, _field, _type, _num), \
437 #define VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n, _v, _vmsd, _type) { \
438 .name = (stringify(_f)), \
439 .version_id = (_v), \
440 .num = (_n), \
441 .vmsd = &(_vmsd), \
442 .size = sizeof(_type *), \
443 .flags = VMS_ARRAY|VMS_STRUCT|VMS_ARRAY_OF_POINTER, \
444 .offset = vmstate_offset_array(_s, _f, _type*, _n), \
447 #define VMSTATE_STRUCT_SUB_ARRAY(_field, _state, _start, _num, _version, _vmsd, _type) { \
448 .name = (stringify(_field)), \
449 .version_id = (_version), \
450 .num = (_num), \
451 .vmsd = &(_vmsd), \
452 .size = sizeof(_type), \
453 .flags = VMS_STRUCT|VMS_ARRAY, \
454 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
457 #define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \
458 .name = (stringify(_field)), \
459 .num = (_num), \
460 .field_exists = (_test), \
461 .version_id = (_version), \
462 .vmsd = &(_vmsd), \
463 .size = sizeof(_type), \
464 .flags = VMS_STRUCT|VMS_ARRAY, \
465 .offset = vmstate_offset_array(_state, _field, _type, _num),\
468 #define VMSTATE_STRUCT_2DARRAY_TEST(_field, _state, _n1, _n2, _test, \
469 _version, _vmsd, _type) { \
470 .name = (stringify(_field)), \
471 .num = (_n1) * (_n2), \
472 .field_exists = (_test), \
473 .version_id = (_version), \
474 .vmsd = &(_vmsd), \
475 .size = sizeof(_type), \
476 .flags = VMS_STRUCT | VMS_ARRAY, \
477 .offset = vmstate_offset_2darray(_state, _field, _type, \
478 _n1, _n2), \
481 #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \
482 .name = (stringify(_field)), \
483 .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
484 .version_id = (_version), \
485 .vmsd = &(_vmsd), \
486 .size = sizeof(_type), \
487 .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \
488 .offset = offsetof(_state, _field), \
491 /* a variable length array (i.e. _type *_field) but we know the
492 * length
494 #define VMSTATE_STRUCT_VARRAY_POINTER_KNOWN(_field, _state, _num, _version, _vmsd, _type) { \
495 .name = (stringify(_field)), \
496 .num = (_num), \
497 .version_id = (_version), \
498 .vmsd = &(_vmsd), \
499 .size = sizeof(_type), \
500 .flags = VMS_STRUCT|VMS_ARRAY|VMS_POINTER, \
501 .offset = offsetof(_state, _field), \
504 #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \
505 .name = (stringify(_field)), \
506 .version_id = 0, \
507 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
508 .size = sizeof(_type), \
509 .vmsd = &(_vmsd), \
510 .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
511 .offset = vmstate_offset_pointer(_state, _field, _type), \
514 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \
515 .name = (stringify(_field)), \
516 .version_id = 0, \
517 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
518 .size = sizeof(_type), \
519 .vmsd = &(_vmsd), \
520 .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
521 .offset = vmstate_offset_pointer(_state, _field, _type), \
524 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
525 .name = (stringify(_field)), \
526 .version_id = 0, \
527 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
528 .size = sizeof(_type), \
529 .vmsd = &(_vmsd), \
530 .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \
531 .offset = vmstate_offset_pointer(_state, _field, _type), \
534 #define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \
535 .name = (stringify(_field)), \
536 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
537 .version_id = (_version), \
538 .vmsd = &(_vmsd), \
539 .size = sizeof(_type), \
540 .flags = VMS_STRUCT|VMS_VARRAY_INT32, \
541 .offset = offsetof(_state, _field), \
544 #define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \
545 .name = (stringify(_field)), \
546 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \
547 .version_id = (_version), \
548 .vmsd = &(_vmsd), \
549 .size = sizeof(_type), \
550 .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \
551 .offset = offsetof(_state, _field), \
554 #define VMSTATE_STRUCT_VARRAY_ALLOC(_field, _state, _field_num, _version, _vmsd, _type) {\
555 .name = (stringify(_field)), \
556 .version_id = (_version), \
557 .vmsd = &(_vmsd), \
558 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
559 .size = sizeof(_type), \
560 .flags = VMS_STRUCT|VMS_VARRAY_INT32|VMS_ALLOC|VMS_POINTER, \
561 .offset = vmstate_offset_pointer(_state, _field, _type), \
564 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
565 .name = (stringify(_field)), \
566 .version_id = (_version), \
567 .field_exists = (_test), \
568 .size = (_size - _start), \
569 .info = &vmstate_info_buffer, \
570 .flags = VMS_BUFFER, \
571 .offset = vmstate_offset_buffer(_state, _field) + _start, \
574 #define VMSTATE_VBUFFER_MULTIPLY(_field, _state, _version, _test, \
575 _field_size, _multiply) { \
576 .name = (stringify(_field)), \
577 .version_id = (_version), \
578 .field_exists = (_test), \
579 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
580 .size = (_multiply), \
581 .info = &vmstate_info_buffer, \
582 .flags = VMS_VBUFFER|VMS_POINTER|VMS_MULTIPLY, \
583 .offset = offsetof(_state, _field), \
586 #define VMSTATE_VBUFFER(_field, _state, _version, _test, _field_size) { \
587 .name = (stringify(_field)), \
588 .version_id = (_version), \
589 .field_exists = (_test), \
590 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
591 .info = &vmstate_info_buffer, \
592 .flags = VMS_VBUFFER|VMS_POINTER, \
593 .offset = offsetof(_state, _field), \
596 #define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _field_size) { \
597 .name = (stringify(_field)), \
598 .version_id = (_version), \
599 .field_exists = (_test), \
600 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
601 .info = &vmstate_info_buffer, \
602 .flags = VMS_VBUFFER|VMS_POINTER, \
603 .offset = offsetof(_state, _field), \
606 #define VMSTATE_VBUFFER_ALLOC_UINT32(_field, _state, _version, \
607 _test, _field_size) { \
608 .name = (stringify(_field)), \
609 .version_id = (_version), \
610 .field_exists = (_test), \
611 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
612 .info = &vmstate_info_buffer, \
613 .flags = VMS_VBUFFER|VMS_POINTER|VMS_ALLOC, \
614 .offset = offsetof(_state, _field), \
617 #define VMSTATE_BUFFER_UNSAFE_INFO_TEST(_field, _state, _test, _version, _info, _size) { \
618 .name = (stringify(_field)), \
619 .version_id = (_version), \
620 .field_exists = (_test), \
621 .size = (_size), \
622 .info = &(_info), \
623 .flags = VMS_BUFFER, \
624 .offset = offsetof(_state, _field), \
627 #define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _version, _size) { \
628 .name = (stringify(_field)), \
629 .version_id = (_version), \
630 .size = (_size), \
631 .info = &vmstate_info_buffer, \
632 .flags = VMS_BUFFER|VMS_POINTER, \
633 .offset = offsetof(_state, _field), \
636 /* Allocate a temporary of type 'tmp_type', set tmp->parent to _state
637 * and execute the vmsd on the temporary. Note that we're working with
638 * the whole of _state here, not a field within it.
639 * We compile time check that:
640 * That _tmp_type contains a 'parent' member that's a pointer to the
641 * '_state' type
642 * That the pointer is right at the start of _tmp_type.
644 #define VMSTATE_WITH_TMP(_state, _tmp_type, _vmsd) { \
645 .name = "tmp", \
646 .size = sizeof(_tmp_type) + \
647 QEMU_BUILD_BUG_ON_ZERO(offsetof(_tmp_type, parent) != 0) + \
648 type_check_pointer(_state, \
649 typeof_field(_tmp_type, parent)), \
650 .vmsd = &(_vmsd), \
651 .info = &vmstate_info_tmp, \
654 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
655 .name = "unused", \
656 .field_exists = (_test), \
657 .version_id = (_version), \
658 .size = (_size), \
659 .info = &vmstate_info_unused_buffer, \
660 .flags = VMS_BUFFER, \
663 /* Discard size * field_num bytes, where field_num is a uint32 member */
664 #define VMSTATE_UNUSED_VARRAY_UINT32(_state, _test, _version, _field_num, _size) {\
665 .name = "unused", \
666 .field_exists = (_test), \
667 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
668 .version_id = (_version), \
669 .size = (_size), \
670 .info = &vmstate_info_unused_buffer, \
671 .flags = VMS_VARRAY_UINT32 | VMS_BUFFER, \
674 /* _field_size should be a int32_t field in the _state struct giving the
675 * size of the bitmap _field in bits.
677 #define VMSTATE_BITMAP(_field, _state, _version, _field_size) { \
678 .name = (stringify(_field)), \
679 .version_id = (_version), \
680 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
681 .info = &vmstate_info_bitmap, \
682 .flags = VMS_VBUFFER|VMS_POINTER, \
683 .offset = offsetof(_state, _field), \
686 /* For migrating a QTAILQ.
687 * Target QTAILQ needs be properly initialized.
688 * _type: type of QTAILQ element
689 * _next: name of QTAILQ entry field in QTAILQ element
690 * _vmsd: VMSD for QTAILQ element
691 * size: size of QTAILQ element
692 * start: offset of QTAILQ entry in QTAILQ element
694 #define VMSTATE_QTAILQ_V(_field, _state, _version, _vmsd, _type, _next) \
696 .name = (stringify(_field)), \
697 .version_id = (_version), \
698 .vmsd = &(_vmsd), \
699 .size = sizeof(_type), \
700 .info = &vmstate_info_qtailq, \
701 .offset = offsetof(_state, _field), \
702 .start = offsetof(_type, _next), \
705 /* _f : field name
706 _f_n : num of elements field_name
707 _n : num of elements
708 _s : struct state name
709 _v : version
712 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
713 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
715 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \
716 VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
718 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \
719 VMSTATE_STRUCT_POINTER_V(_field, _state, 0, _vmsd, _type)
721 #define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) \
722 VMSTATE_STRUCT_POINTER_TEST_V(_field, _state, _test, 0, _vmsd, _type)
724 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \
725 VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \
726 _vmsd, _type)
728 #define VMSTATE_STRUCT_2DARRAY(_field, _state, _n1, _n2, _version, \
729 _vmsd, _type) \
730 VMSTATE_STRUCT_2DARRAY_TEST(_field, _state, _n1, _n2, NULL, \
731 _version, _vmsd, _type)
733 #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) \
734 VMSTATE_BUFFER_UNSAFE_INFO_TEST(_field, _state, NULL, _version, _info, \
735 _size)
737 #define VMSTATE_BOOL_V(_f, _s, _v) \
738 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool)
740 #define VMSTATE_INT8_V(_f, _s, _v) \
741 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
742 #define VMSTATE_INT16_V(_f, _s, _v) \
743 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
744 #define VMSTATE_INT32_V(_f, _s, _v) \
745 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
746 #define VMSTATE_INT64_V(_f, _s, _v) \
747 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
749 #define VMSTATE_UINT8_V(_f, _s, _v) \
750 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
751 #define VMSTATE_UINT16_V(_f, _s, _v) \
752 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
753 #define VMSTATE_UINT32_V(_f, _s, _v) \
754 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
755 #define VMSTATE_UINT64_V(_f, _s, _v) \
756 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
758 #define VMSTATE_BOOL(_f, _s) \
759 VMSTATE_BOOL_V(_f, _s, 0)
761 #define VMSTATE_INT8(_f, _s) \
762 VMSTATE_INT8_V(_f, _s, 0)
763 #define VMSTATE_INT16(_f, _s) \
764 VMSTATE_INT16_V(_f, _s, 0)
765 #define VMSTATE_INT32(_f, _s) \
766 VMSTATE_INT32_V(_f, _s, 0)
767 #define VMSTATE_INT64(_f, _s) \
768 VMSTATE_INT64_V(_f, _s, 0)
770 #define VMSTATE_UINT8(_f, _s) \
771 VMSTATE_UINT8_V(_f, _s, 0)
772 #define VMSTATE_UINT16(_f, _s) \
773 VMSTATE_UINT16_V(_f, _s, 0)
774 #define VMSTATE_UINT32(_f, _s) \
775 VMSTATE_UINT32_V(_f, _s, 0)
776 #define VMSTATE_UINT64(_f, _s) \
777 VMSTATE_UINT64_V(_f, _s, 0)
779 #define VMSTATE_UINT8_EQUAL(_f, _s, _err_hint) \
780 VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \
781 vmstate_info_uint8_equal, uint8_t, _err_hint)
783 #define VMSTATE_UINT16_EQUAL(_f, _s, _err_hint) \
784 VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \
785 vmstate_info_uint16_equal, uint16_t, _err_hint)
787 #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v, _err_hint) \
788 VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \
789 vmstate_info_uint16_equal, uint16_t, _err_hint)
791 #define VMSTATE_INT32_EQUAL(_f, _s, _err_hint) \
792 VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \
793 vmstate_info_int32_equal, int32_t, _err_hint)
795 #define VMSTATE_UINT32_EQUAL_V(_f, _s, _v, _err_hint) \
796 VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \
797 vmstate_info_uint32_equal, uint32_t, _err_hint)
799 #define VMSTATE_UINT32_EQUAL(_f, _s, _err_hint) \
800 VMSTATE_UINT32_EQUAL_V(_f, _s, 0, _err_hint)
802 #define VMSTATE_UINT64_EQUAL_V(_f, _s, _v, _err_hint) \
803 VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \
804 vmstate_info_uint64_equal, uint64_t, _err_hint)
806 #define VMSTATE_UINT64_EQUAL(_f, _s, _err_hint) \
807 VMSTATE_UINT64_EQUAL_V(_f, _s, 0, _err_hint)
809 #define VMSTATE_INT32_POSITIVE_LE(_f, _s) \
810 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
812 #define VMSTATE_INT8_TEST(_f, _s, _t) \
813 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int8, int8_t)
815 #define VMSTATE_INT16_TEST(_f, _s, _t) \
816 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int16, int16_t)
818 #define VMSTATE_INT32_TEST(_f, _s, _t) \
819 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int32, int32_t)
821 #define VMSTATE_INT64_TEST(_f, _s, _t) \
822 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int64, int64_t)
824 #define VMSTATE_UINT8_TEST(_f, _s, _t) \
825 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
827 #define VMSTATE_UINT16_TEST(_f, _s, _t) \
828 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
830 #define VMSTATE_UINT32_TEST(_f, _s, _t) \
831 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
833 #define VMSTATE_UINT64_TEST(_f, _s, _t) \
834 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint64, uint64_t)
837 #define VMSTATE_FLOAT64_V(_f, _s, _v) \
838 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_float64, float64)
840 #define VMSTATE_FLOAT64(_f, _s) \
841 VMSTATE_FLOAT64_V(_f, _s, 0)
843 #define VMSTATE_TIMER_PTR_TEST(_f, _s, _test) \
844 VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
846 #define VMSTATE_TIMER_PTR_V(_f, _s, _v) \
847 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
849 #define VMSTATE_TIMER_PTR(_f, _s) \
850 VMSTATE_TIMER_PTR_V(_f, _s, 0)
852 #define VMSTATE_TIMER_PTR_ARRAY(_f, _s, _n) \
853 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
855 #define VMSTATE_TIMER_TEST(_f, _s, _test) \
856 VMSTATE_SINGLE_TEST(_f, _s, _test, 0, vmstate_info_timer, QEMUTimer)
858 #define VMSTATE_TIMER_V(_f, _s, _v) \
859 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_timer, QEMUTimer)
861 #define VMSTATE_TIMER(_f, _s) \
862 VMSTATE_TIMER_V(_f, _s, 0)
864 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
865 VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer)
867 #define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \
868 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool)
870 #define VMSTATE_BOOL_ARRAY(_f, _s, _n) \
871 VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0)
873 #define VMSTATE_BOOL_SUB_ARRAY(_f, _s, _start, _num) \
874 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_bool, bool)
876 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
877 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
879 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v) \
880 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)
882 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
883 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
885 #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2) \
886 VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, 0)
888 #define VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, _v) \
889 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint8, uint8_t)
891 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
892 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
894 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
895 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
897 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num) \
898 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)
900 #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2) \
901 VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0)
903 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
904 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
906 #define VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v) \
907 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint32, uint32_t)
909 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
910 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
912 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
913 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
915 #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2) \
916 VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0)
918 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
919 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
921 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
922 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
924 #define VMSTATE_UINT64_SUB_ARRAY(_f, _s, _start, _num) \
925 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint64, uint64_t)
927 #define VMSTATE_UINT64_2DARRAY(_f, _s, _n1, _n2) \
928 VMSTATE_UINT64_2DARRAY_V(_f, _s, _n1, _n2, 0)
930 #define VMSTATE_UINT64_2DARRAY_V(_f, _s, _n1, _n2, _v) \
931 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint64, uint64_t)
933 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
934 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
936 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
937 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
939 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
940 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
942 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
943 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
945 #define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \
946 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t)
948 #define VMSTATE_INT64_ARRAY(_f, _s, _n) \
949 VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)
951 #define VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, _v) \
952 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_float64, float64)
954 #define VMSTATE_FLOAT64_ARRAY(_f, _s, _n) \
955 VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, 0)
957 #define VMSTATE_CPUDOUBLE_ARRAY_V(_f, _s, _n, _v) \
958 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_cpudouble, CPU_DoubleU)
960 #define VMSTATE_CPUDOUBLE_ARRAY(_f, _s, _n) \
961 VMSTATE_CPUDOUBLE_ARRAY_V(_f, _s, _n, 0)
963 #define VMSTATE_BUFFER_V(_f, _s, _v) \
964 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
966 #define VMSTATE_BUFFER(_f, _s) \
967 VMSTATE_BUFFER_V(_f, _s, 0)
969 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
970 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
972 #define VMSTATE_BUFFER_START_MIDDLE_V(_f, _s, _start, _v) \
973 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, _start, sizeof(typeof_field(_s, _f)))
975 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
976 VMSTATE_BUFFER_START_MIDDLE_V(_f, _s, _start, 0)
978 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \
979 VMSTATE_VBUFFER(_f, _s, 0, NULL, _size)
981 #define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) \
982 VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, _size)
984 #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
985 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
987 #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
988 VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
990 #define VMSTATE_UNUSED_V(_v, _size) \
991 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
993 #define VMSTATE_UNUSED(_size) \
994 VMSTATE_UNUSED_V(0, _size)
996 #define VMSTATE_UNUSED_TEST(_test, _size) \
997 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
999 #define VMSTATE_END_OF_LIST() \
1002 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
1003 void *opaque, int version_id);
1004 int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
1005 void *opaque, QJSON *vmdesc);
1007 bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque);
1009 /* Returns: 0 on success, -1 on failure */
1010 int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
1011 const VMStateDescription *vmsd,
1012 void *base, int alias_id,
1013 int required_for_version,
1014 Error **errp);
1016 /* Returns: 0 on success, -1 on failure */
1017 static inline int vmstate_register(DeviceState *dev, int instance_id,
1018 const VMStateDescription *vmsd,
1019 void *opaque)
1021 return vmstate_register_with_alias_id(dev, instance_id, vmsd,
1022 opaque, -1, 0, NULL);
1025 void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
1026 void *opaque);
1028 struct MemoryRegion;
1029 void vmstate_register_ram(struct MemoryRegion *memory, DeviceState *dev);
1030 void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev);
1031 void vmstate_register_ram_global(struct MemoryRegion *memory);
1033 bool vmstate_check_only_migratable(const VMStateDescription *vmsd);
1035 #endif