serial: add pci variant
[qemu/opensuse.git] / vmstate.h
blobc9c320e62e099e906c941c0fe4c7ec35fead2805
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.
26 #ifndef QEMU_VMSTATE_H
27 #define QEMU_VMSTATE_H 1
29 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
30 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
32 typedef struct SaveVMHandlers {
33 void (*set_params)(const MigrationParams *params, void * opaque);
34 SaveStateHandler *save_state;
35 int (*save_live_setup)(QEMUFile *f, void *opaque);
36 int (*save_live_iterate)(QEMUFile *f, void *opaque);
37 int (*save_live_complete)(QEMUFile *f, void *opaque);
38 void (*cancel)(void *opaque);
39 LoadStateHandler *load_state;
40 bool (*is_active)(void *opaque);
41 } SaveVMHandlers;
43 int register_savevm(DeviceState *dev,
44 const char *idstr,
45 int instance_id,
46 int version_id,
47 SaveStateHandler *save_state,
48 LoadStateHandler *load_state,
49 void *opaque);
51 int register_savevm_live(DeviceState *dev,
52 const char *idstr,
53 int instance_id,
54 int version_id,
55 SaveVMHandlers *ops,
56 void *opaque);
58 void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque);
59 void register_device_unmigratable(DeviceState *dev, const char *idstr,
60 void *opaque);
63 typedef struct VMStateInfo VMStateInfo;
64 typedef struct VMStateDescription VMStateDescription;
66 struct VMStateInfo {
67 const char *name;
68 int (*get)(QEMUFile *f, void *pv, size_t size);
69 void (*put)(QEMUFile *f, void *pv, size_t size);
72 enum VMStateFlags {
73 VMS_SINGLE = 0x001,
74 VMS_POINTER = 0x002,
75 VMS_ARRAY = 0x004,
76 VMS_STRUCT = 0x008,
77 VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/
78 VMS_BUFFER = 0x020, /* static sized buffer */
79 VMS_ARRAY_OF_POINTER = 0x040,
80 VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */
81 VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */
82 VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */
83 VMS_VARRAY_UINT8 = 0x400, /* Array with size in uint8_t field*/
84 VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/
87 typedef struct {
88 const char *name;
89 size_t offset;
90 size_t size;
91 size_t start;
92 int num;
93 size_t num_offset;
94 size_t size_offset;
95 const VMStateInfo *info;
96 enum VMStateFlags flags;
97 const VMStateDescription *vmsd;
98 int version_id;
99 bool (*field_exists)(void *opaque, int version_id);
100 } VMStateField;
102 typedef struct VMStateSubsection {
103 const VMStateDescription *vmsd;
104 bool (*needed)(void *opaque);
105 } VMStateSubsection;
107 struct VMStateDescription {
108 const char *name;
109 int unmigratable;
110 int version_id;
111 int minimum_version_id;
112 int minimum_version_id_old;
113 LoadStateHandler *load_state_old;
114 int (*pre_load)(void *opaque);
115 int (*post_load)(void *opaque, int version_id);
116 void (*pre_save)(void *opaque);
117 VMStateField *fields;
118 const VMStateSubsection *subsections;
121 extern const VMStateInfo vmstate_info_bool;
123 extern const VMStateInfo vmstate_info_int8;
124 extern const VMStateInfo vmstate_info_int16;
125 extern const VMStateInfo vmstate_info_int32;
126 extern const VMStateInfo vmstate_info_int64;
128 extern const VMStateInfo vmstate_info_uint8_equal;
129 extern const VMStateInfo vmstate_info_uint16_equal;
130 extern const VMStateInfo vmstate_info_int32_equal;
131 extern const VMStateInfo vmstate_info_uint32_equal;
132 extern const VMStateInfo vmstate_info_int32_le;
134 extern const VMStateInfo vmstate_info_uint8;
135 extern const VMStateInfo vmstate_info_uint16;
136 extern const VMStateInfo vmstate_info_uint32;
137 extern const VMStateInfo vmstate_info_uint64;
139 extern const VMStateInfo vmstate_info_timer;
140 extern const VMStateInfo vmstate_info_buffer;
141 extern const VMStateInfo vmstate_info_unused_buffer;
143 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
144 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
146 #define vmstate_offset_value(_state, _field, _type) \
147 (offsetof(_state, _field) + \
148 type_check(_type, typeof_field(_state, _field)))
150 #define vmstate_offset_pointer(_state, _field, _type) \
151 (offsetof(_state, _field) + \
152 type_check_pointer(_type, typeof_field(_state, _field)))
154 #define vmstate_offset_array(_state, _field, _type, _num) \
155 (offsetof(_state, _field) + \
156 type_check_array(_type, typeof_field(_state, _field), _num))
158 #define vmstate_offset_sub_array(_state, _field, _type, _start) \
159 (offsetof(_state, _field[_start]))
161 #define vmstate_offset_buffer(_state, _field) \
162 vmstate_offset_array(_state, _field, uint8_t, \
163 sizeof(typeof_field(_state, _field)))
165 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
166 .name = (stringify(_field)), \
167 .version_id = (_version), \
168 .field_exists = (_test), \
169 .size = sizeof(_type), \
170 .info = &(_info), \
171 .flags = VMS_SINGLE, \
172 .offset = vmstate_offset_value(_state, _field, _type), \
175 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
176 .name = (stringify(_field)), \
177 .version_id = (_version), \
178 .info = &(_info), \
179 .size = sizeof(_type), \
180 .flags = VMS_SINGLE|VMS_POINTER, \
181 .offset = vmstate_offset_value(_state, _field, _type), \
184 #define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) { \
185 .name = (stringify(_field)), \
186 .info = &(_info), \
187 .field_exists = (_test), \
188 .size = sizeof(_type), \
189 .flags = VMS_SINGLE|VMS_POINTER, \
190 .offset = vmstate_offset_value(_state, _field, _type), \
193 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
194 .name = (stringify(_field)), \
195 .version_id = (_version), \
196 .num = (_num), \
197 .info = &(_info), \
198 .size = sizeof(_type), \
199 .flags = VMS_ARRAY, \
200 .offset = vmstate_offset_array(_state, _field, _type, _num), \
203 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
204 .name = (stringify(_field)), \
205 .field_exists = (_test), \
206 .num = (_num), \
207 .info = &(_info), \
208 .size = sizeof(_type), \
209 .flags = VMS_ARRAY, \
210 .offset = vmstate_offset_array(_state, _field, _type, _num),\
213 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
214 .name = (stringify(_field)), \
215 .version_id = (_version), \
216 .num = (_num), \
217 .info = &(_info), \
218 .size = sizeof(_type), \
219 .flags = VMS_ARRAY, \
220 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
223 #define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\
224 .name = (stringify(_field)), \
225 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
226 .info = &(_info), \
227 .size = sizeof(_type), \
228 .flags = VMS_VARRAY_INT32, \
229 .offset = offsetof(_state, _field), \
232 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
233 .name = (stringify(_field)), \
234 .version_id = (_version), \
235 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
236 .info = &(_info), \
237 .size = sizeof(_type), \
238 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
239 .offset = vmstate_offset_pointer(_state, _field, _type), \
242 #define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\
243 .name = (stringify(_field)), \
244 .version_id = (_version), \
245 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
246 .info = &(_info), \
247 .size = sizeof(_type), \
248 .flags = VMS_VARRAY_UINT32|VMS_POINTER, \
249 .offset = vmstate_offset_pointer(_state, _field, _type), \
252 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
253 .name = (stringify(_field)), \
254 .version_id = (_version), \
255 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
256 .info = &(_info), \
257 .size = sizeof(_type), \
258 .flags = VMS_VARRAY_UINT16, \
259 .offset = offsetof(_state, _field), \
262 #define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \
263 .name = (stringify(_field)), \
264 .version_id = (_version), \
265 .field_exists = (_test), \
266 .vmsd = &(_vmsd), \
267 .size = sizeof(_type), \
268 .flags = VMS_STRUCT, \
269 .offset = vmstate_offset_value(_state, _field, _type), \
272 #define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \
273 .name = (stringify(_field)), \
274 .field_exists = (_test), \
275 .vmsd = &(_vmsd), \
276 .size = sizeof(_type), \
277 .flags = VMS_STRUCT|VMS_POINTER, \
278 .offset = vmstate_offset_value(_state, _field, _type), \
281 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
282 .name = (stringify(_field)), \
283 .version_id = (_version), \
284 .num = (_num), \
285 .info = &(_info), \
286 .size = sizeof(_type), \
287 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
288 .offset = vmstate_offset_array(_state, _field, _type, _num), \
291 #define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \
292 .name = (stringify(_field)), \
293 .num = (_num), \
294 .field_exists = (_test), \
295 .version_id = (_version), \
296 .vmsd = &(_vmsd), \
297 .size = sizeof(_type), \
298 .flags = VMS_STRUCT|VMS_ARRAY, \
299 .offset = vmstate_offset_array(_state, _field, _type, _num),\
302 #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \
303 .name = (stringify(_field)), \
304 .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
305 .version_id = (_version), \
306 .vmsd = &(_vmsd), \
307 .size = sizeof(_type), \
308 .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \
309 .offset = offsetof(_state, _field), \
312 #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \
313 .name = (stringify(_field)), \
314 .version_id = 0, \
315 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
316 .size = sizeof(_type), \
317 .vmsd = &(_vmsd), \
318 .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
319 .offset = vmstate_offset_pointer(_state, _field, _type), \
322 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
323 .name = (stringify(_field)), \
324 .version_id = 0, \
325 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
326 .size = sizeof(_type), \
327 .vmsd = &(_vmsd), \
328 .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \
329 .offset = vmstate_offset_pointer(_state, _field, _type), \
332 #define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \
333 .name = (stringify(_field)), \
334 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
335 .version_id = (_version), \
336 .vmsd = &(_vmsd), \
337 .size = sizeof(_type), \
338 .flags = VMS_STRUCT|VMS_VARRAY_INT32, \
339 .offset = offsetof(_state, _field), \
342 #define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \
343 .name = (stringify(_field)), \
344 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \
345 .version_id = (_version), \
346 .vmsd = &(_vmsd), \
347 .size = sizeof(_type), \
348 .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \
349 .offset = offsetof(_state, _field), \
352 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
353 .name = (stringify(_field)), \
354 .version_id = (_version), \
355 .field_exists = (_test), \
356 .size = (_size - _start), \
357 .info = &vmstate_info_buffer, \
358 .flags = VMS_BUFFER, \
359 .offset = vmstate_offset_buffer(_state, _field) + _start, \
362 #define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \
363 .name = (stringify(_field)), \
364 .version_id = (_version), \
365 .field_exists = (_test), \
366 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
367 .size = (_multiply), \
368 .info = &vmstate_info_buffer, \
369 .flags = VMS_VBUFFER|VMS_MULTIPLY, \
370 .offset = offsetof(_state, _field), \
371 .start = (_start), \
374 #define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
375 .name = (stringify(_field)), \
376 .version_id = (_version), \
377 .field_exists = (_test), \
378 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
379 .info = &vmstate_info_buffer, \
380 .flags = VMS_VBUFFER|VMS_POINTER, \
381 .offset = offsetof(_state, _field), \
382 .start = (_start), \
385 #define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _start, _field_size) { \
386 .name = (stringify(_field)), \
387 .version_id = (_version), \
388 .field_exists = (_test), \
389 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
390 .info = &vmstate_info_buffer, \
391 .flags = VMS_VBUFFER|VMS_POINTER, \
392 .offset = offsetof(_state, _field), \
393 .start = (_start), \
396 #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
397 .name = (stringify(_field)), \
398 .version_id = (_version), \
399 .size = (_size), \
400 .info = &(_info), \
401 .flags = VMS_BUFFER, \
402 .offset = offsetof(_state, _field), \
405 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
406 .name = "unused", \
407 .field_exists = (_test), \
408 .version_id = (_version), \
409 .size = (_size), \
410 .info = &vmstate_info_unused_buffer, \
411 .flags = VMS_BUFFER, \
414 /* _f : field name
415 _f_n : num of elements field_name
416 _n : num of elements
417 _s : struct state name
418 _v : version
421 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
422 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
424 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \
425 VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
427 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \
428 VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)
430 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \
431 VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \
432 _vmsd, _type)
434 #define VMSTATE_BOOL_V(_f, _s, _v) \
435 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool)
437 #define VMSTATE_INT8_V(_f, _s, _v) \
438 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
439 #define VMSTATE_INT16_V(_f, _s, _v) \
440 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
441 #define VMSTATE_INT32_V(_f, _s, _v) \
442 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
443 #define VMSTATE_INT64_V(_f, _s, _v) \
444 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
446 #define VMSTATE_UINT8_V(_f, _s, _v) \
447 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
448 #define VMSTATE_UINT16_V(_f, _s, _v) \
449 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
450 #define VMSTATE_UINT32_V(_f, _s, _v) \
451 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
452 #define VMSTATE_UINT64_V(_f, _s, _v) \
453 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
455 #define VMSTATE_BOOL(_f, _s) \
456 VMSTATE_BOOL_V(_f, _s, 0)
458 #define VMSTATE_INT8(_f, _s) \
459 VMSTATE_INT8_V(_f, _s, 0)
460 #define VMSTATE_INT16(_f, _s) \
461 VMSTATE_INT16_V(_f, _s, 0)
462 #define VMSTATE_INT32(_f, _s) \
463 VMSTATE_INT32_V(_f, _s, 0)
464 #define VMSTATE_INT64(_f, _s) \
465 VMSTATE_INT64_V(_f, _s, 0)
467 #define VMSTATE_UINT8(_f, _s) \
468 VMSTATE_UINT8_V(_f, _s, 0)
469 #define VMSTATE_UINT16(_f, _s) \
470 VMSTATE_UINT16_V(_f, _s, 0)
471 #define VMSTATE_UINT32(_f, _s) \
472 VMSTATE_UINT32_V(_f, _s, 0)
473 #define VMSTATE_UINT64(_f, _s) \
474 VMSTATE_UINT64_V(_f, _s, 0)
476 #define VMSTATE_UINT8_EQUAL(_f, _s) \
477 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
479 #define VMSTATE_UINT16_EQUAL(_f, _s) \
480 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
482 #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
483 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
485 #define VMSTATE_INT32_EQUAL(_f, _s) \
486 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
488 #define VMSTATE_UINT32_EQUAL(_f, _s) \
489 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint32_equal, uint32_t)
491 #define VMSTATE_INT32_LE(_f, _s) \
492 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
494 #define VMSTATE_UINT8_TEST(_f, _s, _t) \
495 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
497 #define VMSTATE_UINT16_TEST(_f, _s, _t) \
498 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
500 #define VMSTATE_UINT32_TEST(_f, _s, _t) \
501 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
503 #define VMSTATE_TIMER_TEST(_f, _s, _test) \
504 VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
506 #define VMSTATE_TIMER_V(_f, _s, _v) \
507 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
509 #define VMSTATE_TIMER(_f, _s) \
510 VMSTATE_TIMER_V(_f, _s, 0)
512 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
513 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
515 #define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \
516 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool)
518 #define VMSTATE_BOOL_ARRAY(_f, _s, _n) \
519 VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0)
521 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
522 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
524 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
525 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
527 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
528 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
530 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
531 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
533 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
534 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
536 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
537 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
539 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
540 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
542 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
543 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
545 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
546 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
548 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
549 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
551 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
552 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
554 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
555 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
557 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
558 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
560 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
561 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
563 #define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \
564 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t)
566 #define VMSTATE_INT64_ARRAY(_f, _s, _n) \
567 VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)
569 #define VMSTATE_BUFFER_V(_f, _s, _v) \
570 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
572 #define VMSTATE_BUFFER(_f, _s) \
573 VMSTATE_BUFFER_V(_f, _s, 0)
575 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
576 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
578 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
579 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
581 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \
582 VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size)
584 #define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) \
585 VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size)
587 #define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \
588 VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size)
590 #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
591 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
593 #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
594 VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
596 #define VMSTATE_UNUSED_V(_v, _size) \
597 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
599 #define VMSTATE_UNUSED(_size) \
600 VMSTATE_UNUSED_V(0, _size)
602 #define VMSTATE_UNUSED_TEST(_test, _size) \
603 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
605 #define VMSTATE_END_OF_LIST() \
608 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
609 void *opaque, int version_id);
610 void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
611 void *opaque);
612 int vmstate_register(DeviceState *dev, int instance_id,
613 const VMStateDescription *vmsd, void *base);
614 int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
615 const VMStateDescription *vmsd,
616 void *base, int alias_id,
617 int required_for_version);
618 void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
619 void *opaque);
621 struct MemoryRegion;
622 void vmstate_register_ram(struct MemoryRegion *memory, DeviceState *dev);
623 void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev);
624 void vmstate_register_ram_global(struct MemoryRegion *memory);
626 #endif