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 #include <migration/qemu-file.h>
31 typedef void SaveStateHandler(QEMUFile
*f
, void *opaque
);
32 typedef int LoadStateHandler(QEMUFile
*f
, void *opaque
, int version_id
);
34 typedef struct SaveVMHandlers
{
35 /* This runs inside the iothread lock. */
36 void (*set_params
)(const MigrationParams
*params
, void * opaque
);
37 SaveStateHandler
*save_state
;
39 void (*cancel
)(void *opaque
);
40 int (*save_live_complete
)(QEMUFile
*f
, void *opaque
);
42 /* This runs both outside and inside the iothread lock. */
43 bool (*is_active
)(void *opaque
);
45 /* This runs outside the iothread lock in the migration case, and
46 * within the lock in the savevm case. The callback had better only
47 * use data that is local to the migration thread or protected
50 int (*save_live_iterate
)(QEMUFile
*f
, void *opaque
);
52 /* This runs outside the iothread lock! */
53 int (*save_live_setup
)(QEMUFile
*f
, void *opaque
);
54 uint64_t (*save_live_pending
)(QEMUFile
*f
, void *opaque
, uint64_t max_size
);
56 LoadStateHandler
*load_state
;
59 int register_savevm(DeviceState
*dev
,
63 SaveStateHandler
*save_state
,
64 LoadStateHandler
*load_state
,
67 int register_savevm_live(DeviceState
*dev
,
74 void unregister_savevm(DeviceState
*dev
, const char *idstr
, void *opaque
);
75 void register_device_unmigratable(DeviceState
*dev
, const char *idstr
,
79 typedef struct VMStateInfo VMStateInfo
;
80 typedef struct VMStateDescription VMStateDescription
;
84 int (*get
)(QEMUFile
*f
, void *pv
, size_t size
);
85 void (*put
)(QEMUFile
*f
, void *pv
, size_t size
);
93 VMS_VARRAY_INT32
= 0x010, /* Array with size in int32_t field*/
94 VMS_BUFFER
= 0x020, /* static sized buffer */
95 VMS_ARRAY_OF_POINTER
= 0x040,
96 VMS_VARRAY_UINT16
= 0x080, /* Array with size in uint16_t field */
97 VMS_VBUFFER
= 0x100, /* Buffer with size in int32_t field */
98 VMS_MULTIPLY
= 0x200, /* multiply "size" field by field_size */
99 VMS_VARRAY_UINT8
= 0x400, /* Array with size in uint8_t field*/
100 VMS_VARRAY_UINT32
= 0x800, /* Array with size in uint32_t field*/
111 const VMStateInfo
*info
;
112 enum VMStateFlags flags
;
113 const VMStateDescription
*vmsd
;
115 bool (*field_exists
)(void *opaque
, int version_id
);
118 typedef struct VMStateSubsection
{
119 const VMStateDescription
*vmsd
;
120 bool (*needed
)(void *opaque
);
123 struct VMStateDescription
{
127 int minimum_version_id
;
128 int minimum_version_id_old
;
129 LoadStateHandler
*load_state_old
;
130 int (*pre_load
)(void *opaque
);
131 int (*post_load
)(void *opaque
, int version_id
);
132 void (*pre_save
)(void *opaque
);
133 VMStateField
*fields
;
134 const VMStateSubsection
*subsections
;
137 #ifdef CONFIG_USER_ONLY
138 extern const VMStateDescription vmstate_dummy
;
141 extern const VMStateInfo vmstate_info_bool
;
143 extern const VMStateInfo vmstate_info_int8
;
144 extern const VMStateInfo vmstate_info_int16
;
145 extern const VMStateInfo vmstate_info_int32
;
146 extern const VMStateInfo vmstate_info_int64
;
148 extern const VMStateInfo vmstate_info_uint8_equal
;
149 extern const VMStateInfo vmstate_info_uint16_equal
;
150 extern const VMStateInfo vmstate_info_int32_equal
;
151 extern const VMStateInfo vmstate_info_uint32_equal
;
152 extern const VMStateInfo vmstate_info_uint64_equal
;
153 extern const VMStateInfo vmstate_info_int32_le
;
155 extern const VMStateInfo vmstate_info_uint8
;
156 extern const VMStateInfo vmstate_info_uint16
;
157 extern const VMStateInfo vmstate_info_uint32
;
158 extern const VMStateInfo vmstate_info_uint64
;
160 extern const VMStateInfo vmstate_info_timer
;
161 extern const VMStateInfo vmstate_info_buffer
;
162 extern const VMStateInfo vmstate_info_unused_buffer
;
163 extern const VMStateInfo vmstate_info_bitmap
;
165 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
166 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
168 #define vmstate_offset_value(_state, _field, _type) \
169 (offsetof(_state, _field) + \
170 type_check(_type, typeof_field(_state, _field)))
172 #define vmstate_offset_pointer(_state, _field, _type) \
173 (offsetof(_state, _field) + \
174 type_check_pointer(_type, typeof_field(_state, _field)))
176 #define vmstate_offset_array(_state, _field, _type, _num) \
177 (offsetof(_state, _field) + \
178 type_check_array(_type, typeof_field(_state, _field), _num))
180 #define vmstate_offset_sub_array(_state, _field, _type, _start) \
181 (offsetof(_state, _field[_start]))
183 #define vmstate_offset_buffer(_state, _field) \
184 vmstate_offset_array(_state, _field, uint8_t, \
185 sizeof(typeof_field(_state, _field)))
187 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
188 .name = (stringify(_field)), \
189 .version_id = (_version), \
190 .field_exists = (_test), \
191 .size = sizeof(_type), \
193 .flags = VMS_SINGLE, \
194 .offset = vmstate_offset_value(_state, _field, _type), \
197 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
198 .name = (stringify(_field)), \
199 .version_id = (_version), \
201 .size = sizeof(_type), \
202 .flags = VMS_SINGLE|VMS_POINTER, \
203 .offset = vmstate_offset_value(_state, _field, _type), \
206 #define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) { \
207 .name = (stringify(_field)), \
209 .field_exists = (_test), \
210 .size = sizeof(_type), \
211 .flags = VMS_SINGLE|VMS_POINTER, \
212 .offset = vmstate_offset_value(_state, _field, _type), \
215 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
216 .name = (stringify(_field)), \
217 .version_id = (_version), \
220 .size = sizeof(_type), \
221 .flags = VMS_ARRAY, \
222 .offset = vmstate_offset_array(_state, _field, _type, _num), \
225 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
226 .name = (stringify(_field)), \
227 .field_exists = (_test), \
230 .size = sizeof(_type), \
231 .flags = VMS_ARRAY, \
232 .offset = vmstate_offset_array(_state, _field, _type, _num),\
235 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
236 .name = (stringify(_field)), \
237 .version_id = (_version), \
240 .size = sizeof(_type), \
241 .flags = VMS_ARRAY, \
242 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
245 #define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\
246 .name = (stringify(_field)), \
247 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
249 .size = sizeof(_type), \
250 .flags = VMS_VARRAY_INT32, \
251 .offset = offsetof(_state, _field), \
254 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
255 .name = (stringify(_field)), \
256 .version_id = (_version), \
257 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
259 .size = sizeof(_type), \
260 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
261 .offset = vmstate_offset_pointer(_state, _field, _type), \
264 #define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\
265 .name = (stringify(_field)), \
266 .version_id = (_version), \
267 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
269 .size = sizeof(_type), \
270 .flags = VMS_VARRAY_UINT32|VMS_POINTER, \
271 .offset = vmstate_offset_pointer(_state, _field, _type), \
274 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
275 .name = (stringify(_field)), \
276 .version_id = (_version), \
277 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
279 .size = sizeof(_type), \
280 .flags = VMS_VARRAY_UINT16, \
281 .offset = offsetof(_state, _field), \
284 #define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \
285 .name = (stringify(_field)), \
286 .version_id = (_version), \
287 .field_exists = (_test), \
289 .size = sizeof(_type), \
290 .flags = VMS_STRUCT, \
291 .offset = vmstate_offset_value(_state, _field, _type), \
294 #define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \
295 .name = (stringify(_field)), \
296 .field_exists = (_test), \
298 .size = sizeof(_type), \
299 .flags = VMS_STRUCT|VMS_POINTER, \
300 .offset = vmstate_offset_value(_state, _field, _type), \
303 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
304 .name = (stringify(_field)), \
305 .version_id = (_version), \
308 .size = sizeof(_type), \
309 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
310 .offset = vmstate_offset_array(_state, _field, _type, _num), \
313 #define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \
314 .name = (stringify(_field)), \
316 .field_exists = (_test), \
317 .version_id = (_version), \
319 .size = sizeof(_type), \
320 .flags = VMS_STRUCT|VMS_ARRAY, \
321 .offset = vmstate_offset_array(_state, _field, _type, _num),\
324 #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \
325 .name = (stringify(_field)), \
326 .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
327 .version_id = (_version), \
329 .size = sizeof(_type), \
330 .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \
331 .offset = offsetof(_state, _field), \
334 #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \
335 .name = (stringify(_field)), \
337 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
338 .size = sizeof(_type), \
340 .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
341 .offset = vmstate_offset_pointer(_state, _field, _type), \
344 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
345 .name = (stringify(_field)), \
347 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
348 .size = sizeof(_type), \
350 .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \
351 .offset = vmstate_offset_pointer(_state, _field, _type), \
354 #define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \
355 .name = (stringify(_field)), \
356 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
357 .version_id = (_version), \
359 .size = sizeof(_type), \
360 .flags = VMS_STRUCT|VMS_VARRAY_INT32, \
361 .offset = offsetof(_state, _field), \
364 #define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \
365 .name = (stringify(_field)), \
366 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \
367 .version_id = (_version), \
369 .size = sizeof(_type), \
370 .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \
371 .offset = offsetof(_state, _field), \
374 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
375 .name = (stringify(_field)), \
376 .version_id = (_version), \
377 .field_exists = (_test), \
378 .size = (_size - _start), \
379 .info = &vmstate_info_buffer, \
380 .flags = VMS_BUFFER, \
381 .offset = vmstate_offset_buffer(_state, _field) + _start, \
384 #define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \
385 .name = (stringify(_field)), \
386 .version_id = (_version), \
387 .field_exists = (_test), \
388 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
389 .size = (_multiply), \
390 .info = &vmstate_info_buffer, \
391 .flags = VMS_VBUFFER|VMS_MULTIPLY, \
392 .offset = offsetof(_state, _field), \
396 #define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
397 .name = (stringify(_field)), \
398 .version_id = (_version), \
399 .field_exists = (_test), \
400 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
401 .info = &vmstate_info_buffer, \
402 .flags = VMS_VBUFFER|VMS_POINTER, \
403 .offset = offsetof(_state, _field), \
407 #define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _start, _field_size) { \
408 .name = (stringify(_field)), \
409 .version_id = (_version), \
410 .field_exists = (_test), \
411 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
412 .info = &vmstate_info_buffer, \
413 .flags = VMS_VBUFFER|VMS_POINTER, \
414 .offset = offsetof(_state, _field), \
418 #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
419 .name = (stringify(_field)), \
420 .version_id = (_version), \
423 .flags = VMS_BUFFER, \
424 .offset = offsetof(_state, _field), \
427 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
429 .field_exists = (_test), \
430 .version_id = (_version), \
432 .info = &vmstate_info_unused_buffer, \
433 .flags = VMS_BUFFER, \
436 /* _field_size should be a int32_t field in the _state struct giving the
437 * size of the bitmap _field in bits.
439 #define VMSTATE_BITMAP(_field, _state, _version, _field_size) { \
440 .name = (stringify(_field)), \
441 .version_id = (_version), \
442 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
443 .info = &vmstate_info_bitmap, \
444 .flags = VMS_VBUFFER|VMS_POINTER, \
445 .offset = offsetof(_state, _field), \
449 _f_n : num of elements field_name
451 _s : struct state name
455 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
456 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
458 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \
459 VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
461 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \
462 VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)
464 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \
465 VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \
468 #define VMSTATE_BOOL_V(_f, _s, _v) \
469 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool)
471 #define VMSTATE_INT8_V(_f, _s, _v) \
472 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
473 #define VMSTATE_INT16_V(_f, _s, _v) \
474 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
475 #define VMSTATE_INT32_V(_f, _s, _v) \
476 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
477 #define VMSTATE_INT64_V(_f, _s, _v) \
478 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
480 #define VMSTATE_UINT8_V(_f, _s, _v) \
481 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
482 #define VMSTATE_UINT16_V(_f, _s, _v) \
483 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
484 #define VMSTATE_UINT32_V(_f, _s, _v) \
485 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
486 #define VMSTATE_UINT64_V(_f, _s, _v) \
487 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
489 #define VMSTATE_BOOL(_f, _s) \
490 VMSTATE_BOOL_V(_f, _s, 0)
492 #define VMSTATE_INT8(_f, _s) \
493 VMSTATE_INT8_V(_f, _s, 0)
494 #define VMSTATE_INT16(_f, _s) \
495 VMSTATE_INT16_V(_f, _s, 0)
496 #define VMSTATE_INT32(_f, _s) \
497 VMSTATE_INT32_V(_f, _s, 0)
498 #define VMSTATE_INT64(_f, _s) \
499 VMSTATE_INT64_V(_f, _s, 0)
501 #define VMSTATE_UINT8(_f, _s) \
502 VMSTATE_UINT8_V(_f, _s, 0)
503 #define VMSTATE_UINT16(_f, _s) \
504 VMSTATE_UINT16_V(_f, _s, 0)
505 #define VMSTATE_UINT32(_f, _s) \
506 VMSTATE_UINT32_V(_f, _s, 0)
507 #define VMSTATE_UINT64(_f, _s) \
508 VMSTATE_UINT64_V(_f, _s, 0)
510 #define VMSTATE_UINT8_EQUAL(_f, _s) \
511 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
513 #define VMSTATE_UINT16_EQUAL(_f, _s) \
514 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
516 #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
517 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
519 #define VMSTATE_INT32_EQUAL(_f, _s) \
520 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
522 #define VMSTATE_UINT32_EQUAL(_f, _s) \
523 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint32_equal, uint32_t)
525 #define VMSTATE_UINT64_EQUAL_V(_f, _s, _v) \
526 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64_equal, uint64_t)
528 #define VMSTATE_UINT64_EQUAL(_f, _s) \
529 VMSTATE_UINT64_EQUAL_V(_f, _s, 0)
531 #define VMSTATE_INT32_LE(_f, _s) \
532 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
534 #define VMSTATE_UINT8_TEST(_f, _s, _t) \
535 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
537 #define VMSTATE_UINT16_TEST(_f, _s, _t) \
538 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
540 #define VMSTATE_UINT32_TEST(_f, _s, _t) \
541 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
543 #define VMSTATE_TIMER_TEST(_f, _s, _test) \
544 VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
546 #define VMSTATE_TIMER_V(_f, _s, _v) \
547 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
549 #define VMSTATE_TIMER(_f, _s) \
550 VMSTATE_TIMER_V(_f, _s, 0)
552 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
553 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
555 #define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \
556 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool)
558 #define VMSTATE_BOOL_ARRAY(_f, _s, _n) \
559 VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0)
561 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
562 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
564 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
565 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
567 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
568 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
570 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
571 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
573 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
574 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
576 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
577 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
579 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
580 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
582 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
583 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
585 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
586 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
588 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
589 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
591 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
592 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
594 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
595 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
597 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
598 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
600 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
601 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
603 #define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \
604 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t)
606 #define VMSTATE_INT64_ARRAY(_f, _s, _n) \
607 VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)
609 #define VMSTATE_BUFFER_V(_f, _s, _v) \
610 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
612 #define VMSTATE_BUFFER(_f, _s) \
613 VMSTATE_BUFFER_V(_f, _s, 0)
615 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
616 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
618 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
619 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
621 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \
622 VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size)
624 #define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) \
625 VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size)
627 #define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \
628 VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size)
630 #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
631 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
633 #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
634 VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
636 #define VMSTATE_UNUSED_V(_v, _size) \
637 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
639 #define VMSTATE_UNUSED(_size) \
640 VMSTATE_UNUSED_V(0, _size)
642 #define VMSTATE_UNUSED_TEST(_test, _size) \
643 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
645 #define VMSTATE_END_OF_LIST() \
648 int vmstate_load_state(QEMUFile
*f
, const VMStateDescription
*vmsd
,
649 void *opaque
, int version_id
);
650 void vmstate_save_state(QEMUFile
*f
, const VMStateDescription
*vmsd
,
653 int vmstate_register_with_alias_id(DeviceState
*dev
, int instance_id
,
654 const VMStateDescription
*vmsd
,
655 void *base
, int alias_id
,
656 int required_for_version
);
658 static inline int vmstate_register(DeviceState
*dev
, int instance_id
,
659 const VMStateDescription
*vmsd
,
662 return vmstate_register_with_alias_id(dev
, instance_id
, vmsd
,
666 void vmstate_unregister(DeviceState
*dev
, const VMStateDescription
*vmsd
,
670 void vmstate_register_ram(struct MemoryRegion
*memory
, DeviceState
*dev
);
671 void vmstate_unregister_ram(struct MemoryRegion
*memory
, DeviceState
*dev
);
672 void vmstate_register_ram_global(struct MemoryRegion
*memory
);