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
26 #ifndef QEMU_VMSTATE_H
27 #define QEMU_VMSTATE_H 1
29 #ifndef CONFIG_USER_ONLY
30 #include <migration/qemu-file.h>
33 typedef void SaveStateHandler(QEMUFile
*f
, void *opaque
);
34 typedef int LoadStateHandler(QEMUFile
*f
, void *opaque
, int version_id
);
36 typedef struct SaveVMHandlers
{
37 /* This runs inside the iothread lock. */
38 void (*set_params
)(const MigrationParams
*params
, void * opaque
);
39 SaveStateHandler
*save_state
;
41 void (*cancel
)(void *opaque
);
42 int (*save_live_complete
)(QEMUFile
*f
, void *opaque
);
44 /* This runs both outside and inside the iothread lock. */
45 bool (*is_active
)(void *opaque
);
47 /* This runs outside the iothread lock in the migration case, and
48 * within the lock in the savevm case. The callback had better only
49 * use data that is local to the migration thread or protected
52 int (*save_live_iterate
)(QEMUFile
*f
, void *opaque
);
54 /* This runs outside the iothread lock! */
55 int (*save_live_setup
)(QEMUFile
*f
, void *opaque
);
56 uint64_t (*save_live_pending
)(QEMUFile
*f
, void *opaque
, uint64_t max_size
);
58 LoadStateHandler
*load_state
;
61 int register_savevm(DeviceState
*dev
,
65 SaveStateHandler
*save_state
,
66 LoadStateHandler
*load_state
,
69 int register_savevm_live(DeviceState
*dev
,
76 void unregister_savevm(DeviceState
*dev
, const char *idstr
, void *opaque
);
77 void register_device_unmigratable(DeviceState
*dev
, const char *idstr
,
81 typedef struct VMStateInfo VMStateInfo
;
82 typedef struct VMStateDescription VMStateDescription
;
86 int (*get
)(QEMUFile
*f
, void *pv
, size_t size
);
87 void (*put
)(QEMUFile
*f
, void *pv
, size_t size
);
95 VMS_VARRAY_INT32
= 0x010, /* Array with size in int32_t field*/
96 VMS_BUFFER
= 0x020, /* static sized buffer */
97 VMS_ARRAY_OF_POINTER
= 0x040,
98 VMS_VARRAY_UINT16
= 0x080, /* Array with size in uint16_t field */
99 VMS_VBUFFER
= 0x100, /* Buffer with size in int32_t field */
100 VMS_MULTIPLY
= 0x200, /* multiply "size" field by field_size */
101 VMS_VARRAY_UINT8
= 0x400, /* Array with size in uint8_t field*/
102 VMS_VARRAY_UINT32
= 0x800, /* Array with size in uint32_t field*/
113 const VMStateInfo
*info
;
114 enum VMStateFlags flags
;
115 const VMStateDescription
*vmsd
;
117 bool (*field_exists
)(void *opaque
, int version_id
);
120 typedef struct VMStateSubsection
{
121 const VMStateDescription
*vmsd
;
122 bool (*needed
)(void *opaque
);
125 struct VMStateDescription
{
129 int minimum_version_id
;
130 int minimum_version_id_old
;
131 LoadStateHandler
*load_state_old
;
132 int (*pre_load
)(void *opaque
);
133 int (*post_load
)(void *opaque
, int version_id
);
134 void (*pre_save
)(void *opaque
);
135 VMStateField
*fields
;
136 const VMStateSubsection
*subsections
;
139 #ifdef CONFIG_USER_ONLY
140 extern const VMStateDescription vmstate_dummy
;
143 extern const VMStateInfo vmstate_info_bool
;
145 extern const VMStateInfo vmstate_info_int8
;
146 extern const VMStateInfo vmstate_info_int16
;
147 extern const VMStateInfo vmstate_info_int32
;
148 extern const VMStateInfo vmstate_info_int64
;
150 extern const VMStateInfo vmstate_info_uint8_equal
;
151 extern const VMStateInfo vmstate_info_uint16_equal
;
152 extern const VMStateInfo vmstate_info_int32_equal
;
153 extern const VMStateInfo vmstate_info_uint32_equal
;
154 extern const VMStateInfo vmstate_info_uint64_equal
;
155 extern const VMStateInfo vmstate_info_int32_le
;
157 extern const VMStateInfo vmstate_info_uint8
;
158 extern const VMStateInfo vmstate_info_uint16
;
159 extern const VMStateInfo vmstate_info_uint32
;
160 extern const VMStateInfo vmstate_info_uint64
;
162 extern const VMStateInfo vmstate_info_float64
;
164 extern const VMStateInfo vmstate_info_timer
;
165 extern const VMStateInfo vmstate_info_buffer
;
166 extern const VMStateInfo vmstate_info_unused_buffer
;
167 extern const VMStateInfo vmstate_info_bitmap
;
169 #define type_check_2darray(t1,t2,n,m) ((t1(*)[n][m])0 - (t2*)0)
170 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
171 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
173 #define vmstate_offset_value(_state, _field, _type) \
174 (offsetof(_state, _field) + \
175 type_check(_type, typeof_field(_state, _field)))
177 #define vmstate_offset_pointer(_state, _field, _type) \
178 (offsetof(_state, _field) + \
179 type_check_pointer(_type, typeof_field(_state, _field)))
181 #define vmstate_offset_array(_state, _field, _type, _num) \
182 (offsetof(_state, _field) + \
183 type_check_array(_type, typeof_field(_state, _field), _num))
185 #define vmstate_offset_2darray(_state, _field, _type, _n1, _n2) \
186 (offsetof(_state, _field) + \
187 type_check_2darray(_type, typeof_field(_state, _field), _n1, _n2))
189 #define vmstate_offset_sub_array(_state, _field, _type, _start) \
190 (offsetof(_state, _field[_start]))
192 #define vmstate_offset_buffer(_state, _field) \
193 vmstate_offset_array(_state, _field, uint8_t, \
194 sizeof(typeof_field(_state, _field)))
196 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
197 .name = (stringify(_field)), \
198 .version_id = (_version), \
199 .field_exists = (_test), \
200 .size = sizeof(_type), \
202 .flags = VMS_SINGLE, \
203 .offset = vmstate_offset_value(_state, _field, _type), \
206 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
207 .name = (stringify(_field)), \
208 .version_id = (_version), \
210 .size = sizeof(_type), \
211 .flags = VMS_SINGLE|VMS_POINTER, \
212 .offset = vmstate_offset_value(_state, _field, _type), \
215 #define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) { \
216 .name = (stringify(_field)), \
218 .field_exists = (_test), \
219 .size = sizeof(_type), \
220 .flags = VMS_SINGLE|VMS_POINTER, \
221 .offset = vmstate_offset_value(_state, _field, _type), \
224 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
225 .name = (stringify(_field)), \
226 .version_id = (_version), \
229 .size = sizeof(_type), \
230 .flags = VMS_ARRAY, \
231 .offset = vmstate_offset_array(_state, _field, _type, _num), \
234 #define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _version, _info, _type) { \
235 .name = (stringify(_field)), \
236 .version_id = (_version), \
237 .num = (_n1) * (_n2), \
239 .size = sizeof(_type), \
240 .flags = VMS_ARRAY, \
241 .offset = vmstate_offset_2darray(_state, _field, _type, _n1, _n2), \
244 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
245 .name = (stringify(_field)), \
246 .field_exists = (_test), \
249 .size = sizeof(_type), \
250 .flags = VMS_ARRAY, \
251 .offset = vmstate_offset_array(_state, _field, _type, _num),\
254 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
255 .name = (stringify(_field)), \
256 .version_id = (_version), \
259 .size = sizeof(_type), \
260 .flags = VMS_ARRAY, \
261 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
264 #define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\
265 .name = (stringify(_field)), \
266 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
268 .size = sizeof(_type), \
269 .flags = VMS_VARRAY_INT32, \
270 .offset = offsetof(_state, _field), \
273 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
274 .name = (stringify(_field)), \
275 .version_id = (_version), \
276 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
278 .size = sizeof(_type), \
279 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
280 .offset = vmstate_offset_pointer(_state, _field, _type), \
283 #define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\
284 .name = (stringify(_field)), \
285 .version_id = (_version), \
286 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
288 .size = sizeof(_type), \
289 .flags = VMS_VARRAY_UINT32|VMS_POINTER, \
290 .offset = vmstate_offset_pointer(_state, _field, _type), \
293 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
294 .name = (stringify(_field)), \
295 .version_id = (_version), \
296 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
298 .size = sizeof(_type), \
299 .flags = VMS_VARRAY_UINT16, \
300 .offset = offsetof(_state, _field), \
303 #define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \
304 .name = (stringify(_field)), \
305 .version_id = (_version), \
306 .field_exists = (_test), \
308 .size = sizeof(_type), \
309 .flags = VMS_STRUCT, \
310 .offset = vmstate_offset_value(_state, _field, _type), \
313 #define VMSTATE_STRUCT_POINTER_V(_field, _state, _version, _vmsd, _type) { \
314 .name = (stringify(_field)), \
315 .version_id = (_version), \
317 .size = sizeof(_type *), \
318 .flags = VMS_STRUCT|VMS_POINTER, \
319 .offset = vmstate_offset_pointer(_state, _field, _type), \
322 #define VMSTATE_STRUCT_POINTER_TEST_V(_field, _state, _test, _version, _vmsd, _type) { \
323 .name = (stringify(_field)), \
324 .version_id = (_version), \
325 .field_exists = (_test), \
327 .size = sizeof(_type *), \
328 .flags = VMS_STRUCT|VMS_POINTER, \
329 .offset = vmstate_offset_pointer(_state, _field, _type), \
332 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
333 .name = (stringify(_field)), \
334 .version_id = (_version), \
337 .size = sizeof(_type), \
338 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
339 .offset = vmstate_offset_array(_state, _field, _type, _num), \
342 #define VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n, _v, _vmsd, _type) { \
343 .name = (stringify(_f)), \
344 .version_id = (_v), \
347 .size = sizeof(_type *), \
348 .flags = VMS_ARRAY|VMS_STRUCT|VMS_ARRAY_OF_POINTER, \
349 .offset = vmstate_offset_array(_s, _f, _type*, _n), \
352 #define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \
353 .name = (stringify(_field)), \
355 .field_exists = (_test), \
356 .version_id = (_version), \
358 .size = sizeof(_type), \
359 .flags = VMS_STRUCT|VMS_ARRAY, \
360 .offset = vmstate_offset_array(_state, _field, _type, _num),\
363 #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \
364 .name = (stringify(_field)), \
365 .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
366 .version_id = (_version), \
368 .size = sizeof(_type), \
369 .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \
370 .offset = offsetof(_state, _field), \
373 #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \
374 .name = (stringify(_field)), \
376 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
377 .size = sizeof(_type), \
379 .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
380 .offset = vmstate_offset_pointer(_state, _field, _type), \
383 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \
384 .name = (stringify(_field)), \
386 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
387 .size = sizeof(_type), \
389 .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
390 .offset = vmstate_offset_pointer(_state, _field, _type), \
393 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
394 .name = (stringify(_field)), \
396 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
397 .size = sizeof(_type), \
399 .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \
400 .offset = vmstate_offset_pointer(_state, _field, _type), \
403 #define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \
404 .name = (stringify(_field)), \
405 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
406 .version_id = (_version), \
408 .size = sizeof(_type), \
409 .flags = VMS_STRUCT|VMS_VARRAY_INT32, \
410 .offset = offsetof(_state, _field), \
413 #define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \
414 .name = (stringify(_field)), \
415 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \
416 .version_id = (_version), \
418 .size = sizeof(_type), \
419 .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \
420 .offset = offsetof(_state, _field), \
423 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
424 .name = (stringify(_field)), \
425 .version_id = (_version), \
426 .field_exists = (_test), \
427 .size = (_size - _start), \
428 .info = &vmstate_info_buffer, \
429 .flags = VMS_BUFFER, \
430 .offset = vmstate_offset_buffer(_state, _field) + _start, \
433 #define VMSTATE_VBUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \
434 .name = (stringify(_field)), \
435 .version_id = (_version), \
436 .field_exists = (_test), \
437 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
438 .size = (_multiply), \
439 .info = &vmstate_info_buffer, \
440 .flags = VMS_VBUFFER|VMS_POINTER|VMS_MULTIPLY, \
441 .offset = offsetof(_state, _field), \
445 #define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
446 .name = (stringify(_field)), \
447 .version_id = (_version), \
448 .field_exists = (_test), \
449 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
450 .info = &vmstate_info_buffer, \
451 .flags = VMS_VBUFFER|VMS_POINTER, \
452 .offset = offsetof(_state, _field), \
456 #define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _start, _field_size) { \
457 .name = (stringify(_field)), \
458 .version_id = (_version), \
459 .field_exists = (_test), \
460 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
461 .info = &vmstate_info_buffer, \
462 .flags = VMS_VBUFFER|VMS_POINTER, \
463 .offset = offsetof(_state, _field), \
467 #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
468 .name = (stringify(_field)), \
469 .version_id = (_version), \
472 .flags = VMS_BUFFER, \
473 .offset = offsetof(_state, _field), \
476 #define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _version, _size) { \
477 .name = (stringify(_field)), \
478 .version_id = (_version), \
480 .info = &vmstate_info_buffer, \
481 .flags = VMS_BUFFER|VMS_POINTER, \
482 .offset = offsetof(_state, _field), \
485 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
487 .field_exists = (_test), \
488 .version_id = (_version), \
490 .info = &vmstate_info_unused_buffer, \
491 .flags = VMS_BUFFER, \
494 /* _field_size should be a int32_t field in the _state struct giving the
495 * size of the bitmap _field in bits.
497 #define VMSTATE_BITMAP(_field, _state, _version, _field_size) { \
498 .name = (stringify(_field)), \
499 .version_id = (_version), \
500 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
501 .info = &vmstate_info_bitmap, \
502 .flags = VMS_VBUFFER|VMS_POINTER, \
503 .offset = offsetof(_state, _field), \
507 _f_n : num of elements field_name
509 _s : struct state name
513 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
514 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
516 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \
517 VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
519 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \
520 VMSTATE_STRUCT_POINTER_V(_field, _state, 0, _vmsd, _type)
522 #define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) \
523 VMSTATE_STRUCT_POINTER_TEST_V(_field, _state, _test, 0, _vmsd, _type)
525 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \
526 VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \
529 #define VMSTATE_BOOL_V(_f, _s, _v) \
530 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool)
532 #define VMSTATE_INT8_V(_f, _s, _v) \
533 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
534 #define VMSTATE_INT16_V(_f, _s, _v) \
535 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
536 #define VMSTATE_INT32_V(_f, _s, _v) \
537 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
538 #define VMSTATE_INT64_V(_f, _s, _v) \
539 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
541 #define VMSTATE_UINT8_V(_f, _s, _v) \
542 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
543 #define VMSTATE_UINT16_V(_f, _s, _v) \
544 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
545 #define VMSTATE_UINT32_V(_f, _s, _v) \
546 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
547 #define VMSTATE_UINT64_V(_f, _s, _v) \
548 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
550 #define VMSTATE_BOOL(_f, _s) \
551 VMSTATE_BOOL_V(_f, _s, 0)
553 #define VMSTATE_INT8(_f, _s) \
554 VMSTATE_INT8_V(_f, _s, 0)
555 #define VMSTATE_INT16(_f, _s) \
556 VMSTATE_INT16_V(_f, _s, 0)
557 #define VMSTATE_INT32(_f, _s) \
558 VMSTATE_INT32_V(_f, _s, 0)
559 #define VMSTATE_INT64(_f, _s) \
560 VMSTATE_INT64_V(_f, _s, 0)
562 #define VMSTATE_UINT8(_f, _s) \
563 VMSTATE_UINT8_V(_f, _s, 0)
564 #define VMSTATE_UINT16(_f, _s) \
565 VMSTATE_UINT16_V(_f, _s, 0)
566 #define VMSTATE_UINT32(_f, _s) \
567 VMSTATE_UINT32_V(_f, _s, 0)
568 #define VMSTATE_UINT64(_f, _s) \
569 VMSTATE_UINT64_V(_f, _s, 0)
571 #define VMSTATE_UINT8_EQUAL(_f, _s) \
572 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
574 #define VMSTATE_UINT16_EQUAL(_f, _s) \
575 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
577 #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
578 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
580 #define VMSTATE_INT32_EQUAL(_f, _s) \
581 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
583 #define VMSTATE_UINT32_EQUAL_V(_f, _s, _v) \
584 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32_equal, uint32_t)
586 #define VMSTATE_UINT32_EQUAL(_f, _s) \
587 VMSTATE_UINT32_EQUAL_V(_f, _s, 0)
589 #define VMSTATE_UINT64_EQUAL_V(_f, _s, _v) \
590 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64_equal, uint64_t)
592 #define VMSTATE_UINT64_EQUAL(_f, _s) \
593 VMSTATE_UINT64_EQUAL_V(_f, _s, 0)
595 #define VMSTATE_INT32_LE(_f, _s) \
596 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
598 #define VMSTATE_UINT8_TEST(_f, _s, _t) \
599 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
601 #define VMSTATE_UINT16_TEST(_f, _s, _t) \
602 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
604 #define VMSTATE_UINT32_TEST(_f, _s, _t) \
605 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
608 #define VMSTATE_FLOAT64_V(_f, _s, _v) \
609 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_float64, float64)
611 #define VMSTATE_FLOAT64(_f, _s) \
612 VMSTATE_FLOAT64_V(_f, _s, 0)
614 #define VMSTATE_TIMER_TEST(_f, _s, _test) \
615 VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
617 #define VMSTATE_TIMER_V(_f, _s, _v) \
618 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
620 #define VMSTATE_TIMER(_f, _s) \
621 VMSTATE_TIMER_V(_f, _s, 0)
623 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
624 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
626 #define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \
627 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool)
629 #define VMSTATE_BOOL_ARRAY(_f, _s, _n) \
630 VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0)
632 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
633 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
635 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v) \
636 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)
638 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
639 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
641 #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2) \
642 VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, 0)
644 #define VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, _v) \
645 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint8, uint8_t)
647 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
648 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
650 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
651 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
653 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num) \
654 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)
656 #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2) \
657 VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0)
659 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
660 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
662 #define VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v) \
663 VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint32, uint32_t)
665 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
666 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
668 #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2) \
669 VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0)
671 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
672 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
674 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
675 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
677 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
678 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
680 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
681 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
683 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
684 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
686 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
687 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
689 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
690 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
692 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
693 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
695 #define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \
696 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t)
698 #define VMSTATE_INT64_ARRAY(_f, _s, _n) \
699 VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)
701 #define VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, _v) \
702 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_float64, float64)
704 #define VMSTATE_FLOAT64_ARRAY(_f, _s, _n) \
705 VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, 0)
707 #define VMSTATE_BUFFER_V(_f, _s, _v) \
708 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
710 #define VMSTATE_BUFFER(_f, _s) \
711 VMSTATE_BUFFER_V(_f, _s, 0)
713 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
714 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
716 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
717 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
719 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \
720 VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size)
722 #define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) \
723 VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size)
725 #define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \
726 VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size)
728 #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
729 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
731 #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
732 VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
734 #define VMSTATE_UNUSED_V(_v, _size) \
735 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
737 #define VMSTATE_UNUSED(_size) \
738 VMSTATE_UNUSED_V(0, _size)
740 #define VMSTATE_UNUSED_TEST(_test, _size) \
741 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
743 #define VMSTATE_END_OF_LIST() \
746 int vmstate_load_state(QEMUFile
*f
, const VMStateDescription
*vmsd
,
747 void *opaque
, int version_id
);
748 void vmstate_save_state(QEMUFile
*f
, const VMStateDescription
*vmsd
,
751 int vmstate_register_with_alias_id(DeviceState
*dev
, int instance_id
,
752 const VMStateDescription
*vmsd
,
753 void *base
, int alias_id
,
754 int required_for_version
);
756 static inline int vmstate_register(DeviceState
*dev
, int instance_id
,
757 const VMStateDescription
*vmsd
,
760 return vmstate_register_with_alias_id(dev
, instance_id
, vmsd
,
764 void vmstate_unregister(DeviceState
*dev
, const VMStateDescription
*vmsd
,
768 void vmstate_register_ram(struct MemoryRegion
*memory
, DeviceState
*dev
);
769 void vmstate_unregister_ram(struct MemoryRegion
*memory
, DeviceState
*dev
);
770 void vmstate_register_ram_global(struct MemoryRegion
*memory
);