1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef QEMU_VMSTATE_H
27#define QEMU_VMSTATE_H 1
28
29typedef void SaveStateHandler(QEMUFile *f, void *opaque);
30typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
31
32typedef 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 uint64_t (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t max_size);
39 void (*cancel)(void *opaque);
40 LoadStateHandler *load_state;
41 bool (*is_active)(void *opaque);
42} SaveVMHandlers;
43
44int register_savevm(DeviceState *dev,
45 const char *idstr,
46 int instance_id,
47 int version_id,
48 SaveStateHandler *save_state,
49 LoadStateHandler *load_state,
50 void *opaque);
51
52int register_savevm_live(DeviceState *dev,
53 const char *idstr,
54 int instance_id,
55 int version_id,
56 SaveVMHandlers *ops,
57 void *opaque);
58
59void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque);
60void register_device_unmigratable(DeviceState *dev, const char *idstr,
61 void *opaque);
62
63
64typedef struct VMStateInfo VMStateInfo;
65typedef struct VMStateDescription VMStateDescription;
66
67struct VMStateInfo {
68 const char *name;
69 int (*get)(QEMUFile *f, void *pv, size_t size);
70 void (*put)(QEMUFile *f, void *pv, size_t size);
71};
72
73enum VMStateFlags {
74 VMS_SINGLE = 0x001,
75 VMS_POINTER = 0x002,
76 VMS_ARRAY = 0x004,
77 VMS_STRUCT = 0x008,
78 VMS_VARRAY_INT32 = 0x010,
79 VMS_BUFFER = 0x020,
80 VMS_ARRAY_OF_POINTER = 0x040,
81 VMS_VARRAY_UINT16 = 0x080,
82 VMS_VBUFFER = 0x100,
83 VMS_MULTIPLY = 0x200,
84 VMS_VARRAY_UINT8 = 0x400,
85 VMS_VARRAY_UINT32 = 0x800,
86};
87
88typedef struct {
89 const char *name;
90 size_t offset;
91 size_t size;
92 size_t start;
93 int num;
94 size_t num_offset;
95 size_t size_offset;
96 const VMStateInfo *info;
97 enum VMStateFlags flags;
98 const VMStateDescription *vmsd;
99 int version_id;
100 bool (*field_exists)(void *opaque, int version_id);
101} VMStateField;
102
103typedef struct VMStateSubsection {
104 const VMStateDescription *vmsd;
105 bool (*needed)(void *opaque);
106} VMStateSubsection;
107
108struct VMStateDescription {
109 const char *name;
110 int unmigratable;
111 int version_id;
112 int minimum_version_id;
113 int minimum_version_id_old;
114 LoadStateHandler *load_state_old;
115 int (*pre_load)(void *opaque);
116 int (*post_load)(void *opaque, int version_id);
117 void (*pre_save)(void *opaque);
118 VMStateField *fields;
119 const VMStateSubsection *subsections;
120};
121
122extern const VMStateInfo vmstate_info_bool;
123
124extern const VMStateInfo vmstate_info_int8;
125extern const VMStateInfo vmstate_info_int16;
126extern const VMStateInfo vmstate_info_int32;
127extern const VMStateInfo vmstate_info_int64;
128
129extern const VMStateInfo vmstate_info_uint8_equal;
130extern const VMStateInfo vmstate_info_uint16_equal;
131extern const VMStateInfo vmstate_info_int32_equal;
132extern const VMStateInfo vmstate_info_uint32_equal;
133extern const VMStateInfo vmstate_info_int32_le;
134
135extern const VMStateInfo vmstate_info_uint8;
136extern const VMStateInfo vmstate_info_uint16;
137extern const VMStateInfo vmstate_info_uint32;
138extern const VMStateInfo vmstate_info_uint64;
139
140extern const VMStateInfo vmstate_info_timer;
141extern const VMStateInfo vmstate_info_buffer;
142extern const VMStateInfo vmstate_info_unused_buffer;
143extern const VMStateInfo vmstate_info_bitmap;
144
145#define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
146#define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
147
148#define vmstate_offset_value(_state, _field, _type) \
149 (offsetof(_state, _field) + \
150 type_check(_type, typeof_field(_state, _field)))
151
152#define vmstate_offset_pointer(_state, _field, _type) \
153 (offsetof(_state, _field) + \
154 type_check_pointer(_type, typeof_field(_state, _field)))
155
156#define vmstate_offset_array(_state, _field, _type, _num) \
157 (offsetof(_state, _field) + \
158 type_check_array(_type, typeof_field(_state, _field), _num))
159
160#define vmstate_offset_sub_array(_state, _field, _type, _start) \
161 (offsetof(_state, _field[_start]))
162
163#define vmstate_offset_buffer(_state, _field) \
164 vmstate_offset_array(_state, _field, uint8_t, \
165 sizeof(typeof_field(_state, _field)))
166
167#define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
168 .name = (stringify(_field)), \
169 .version_id = (_version), \
170 .field_exists = (_test), \
171 .size = sizeof(_type), \
172 .info = &(_info), \
173 .flags = VMS_SINGLE, \
174 .offset = vmstate_offset_value(_state, _field, _type), \
175}
176
177#define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
178 .name = (stringify(_field)), \
179 .version_id = (_version), \
180 .info = &(_info), \
181 .size = sizeof(_type), \
182 .flags = VMS_SINGLE|VMS_POINTER, \
183 .offset = vmstate_offset_value(_state, _field, _type), \
184}
185
186#define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) { \
187 .name = (stringify(_field)), \
188 .info = &(_info), \
189 .field_exists = (_test), \
190 .size = sizeof(_type), \
191 .flags = VMS_SINGLE|VMS_POINTER, \
192 .offset = vmstate_offset_value(_state, _field, _type), \
193}
194
195#define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
196 .name = (stringify(_field)), \
197 .version_id = (_version), \
198 .num = (_num), \
199 .info = &(_info), \
200 .size = sizeof(_type), \
201 .flags = VMS_ARRAY, \
202 .offset = vmstate_offset_array(_state, _field, _type, _num), \
203}
204
205#define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
206 .name = (stringify(_field)), \
207 .field_exists = (_test), \
208 .num = (_num), \
209 .info = &(_info), \
210 .size = sizeof(_type), \
211 .flags = VMS_ARRAY, \
212 .offset = vmstate_offset_array(_state, _field, _type, _num),\
213}
214
215#define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
216 .name = (stringify(_field)), \
217 .version_id = (_version), \
218 .num = (_num), \
219 .info = &(_info), \
220 .size = sizeof(_type), \
221 .flags = VMS_ARRAY, \
222 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
223}
224
225#define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\
226 .name = (stringify(_field)), \
227 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
228 .info = &(_info), \
229 .size = sizeof(_type), \
230 .flags = VMS_VARRAY_INT32, \
231 .offset = offsetof(_state, _field), \
232}
233
234#define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
235 .name = (stringify(_field)), \
236 .version_id = (_version), \
237 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
238 .info = &(_info), \
239 .size = sizeof(_type), \
240 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
241 .offset = vmstate_offset_pointer(_state, _field, _type), \
242}
243
244#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\
245 .name = (stringify(_field)), \
246 .version_id = (_version), \
247 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
248 .info = &(_info), \
249 .size = sizeof(_type), \
250 .flags = VMS_VARRAY_UINT32|VMS_POINTER, \
251 .offset = vmstate_offset_pointer(_state, _field, _type), \
252}
253
254#define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
255 .name = (stringify(_field)), \
256 .version_id = (_version), \
257 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
258 .info = &(_info), \
259 .size = sizeof(_type), \
260 .flags = VMS_VARRAY_UINT16, \
261 .offset = offsetof(_state, _field), \
262}
263
264#define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \
265 .name = (stringify(_field)), \
266 .version_id = (_version), \
267 .field_exists = (_test), \
268 .vmsd = &(_vmsd), \
269 .size = sizeof(_type), \
270 .flags = VMS_STRUCT, \
271 .offset = vmstate_offset_value(_state, _field, _type), \
272}
273
274#define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \
275 .name = (stringify(_field)), \
276 .field_exists = (_test), \
277 .vmsd = &(_vmsd), \
278 .size = sizeof(_type), \
279 .flags = VMS_STRUCT|VMS_POINTER, \
280 .offset = vmstate_offset_value(_state, _field, _type), \
281}
282
283#define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
284 .name = (stringify(_field)), \
285 .version_id = (_version), \
286 .num = (_num), \
287 .info = &(_info), \
288 .size = sizeof(_type), \
289 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
290 .offset = vmstate_offset_array(_state, _field, _type, _num), \
291}
292
293#define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \
294 .name = (stringify(_field)), \
295 .num = (_num), \
296 .field_exists = (_test), \
297 .version_id = (_version), \
298 .vmsd = &(_vmsd), \
299 .size = sizeof(_type), \
300 .flags = VMS_STRUCT|VMS_ARRAY, \
301 .offset = vmstate_offset_array(_state, _field, _type, _num),\
302}
303
304#define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \
305 .name = (stringify(_field)), \
306 .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
307 .version_id = (_version), \
308 .vmsd = &(_vmsd), \
309 .size = sizeof(_type), \
310 .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \
311 .offset = offsetof(_state, _field), \
312}
313
314#define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \
315 .name = (stringify(_field)), \
316 .version_id = 0, \
317 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
318 .size = sizeof(_type), \
319 .vmsd = &(_vmsd), \
320 .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
321 .offset = vmstate_offset_pointer(_state, _field, _type), \
322}
323
324#define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
325 .name = (stringify(_field)), \
326 .version_id = 0, \
327 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
328 .size = sizeof(_type), \
329 .vmsd = &(_vmsd), \
330 .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \
331 .offset = vmstate_offset_pointer(_state, _field, _type), \
332}
333
334#define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \
335 .name = (stringify(_field)), \
336 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
337 .version_id = (_version), \
338 .vmsd = &(_vmsd), \
339 .size = sizeof(_type), \
340 .flags = VMS_STRUCT|VMS_VARRAY_INT32, \
341 .offset = offsetof(_state, _field), \
342}
343
344#define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \
345 .name = (stringify(_field)), \
346 .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \
347 .version_id = (_version), \
348 .vmsd = &(_vmsd), \
349 .size = sizeof(_type), \
350 .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \
351 .offset = offsetof(_state, _field), \
352}
353
354#define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
355 .name = (stringify(_field)), \
356 .version_id = (_version), \
357 .field_exists = (_test), \
358 .size = (_size - _start), \
359 .info = &vmstate_info_buffer, \
360 .flags = VMS_BUFFER, \
361 .offset = vmstate_offset_buffer(_state, _field) + _start, \
362}
363
364#define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \
365 .name = (stringify(_field)), \
366 .version_id = (_version), \
367 .field_exists = (_test), \
368 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
369 .size = (_multiply), \
370 .info = &vmstate_info_buffer, \
371 .flags = VMS_VBUFFER|VMS_MULTIPLY, \
372 .offset = offsetof(_state, _field), \
373 .start = (_start), \
374}
375
376#define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
377 .name = (stringify(_field)), \
378 .version_id = (_version), \
379 .field_exists = (_test), \
380 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
381 .info = &vmstate_info_buffer, \
382 .flags = VMS_VBUFFER|VMS_POINTER, \
383 .offset = offsetof(_state, _field), \
384 .start = (_start), \
385}
386
387#define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _start, _field_size) { \
388 .name = (stringify(_field)), \
389 .version_id = (_version), \
390 .field_exists = (_test), \
391 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
392 .info = &vmstate_info_buffer, \
393 .flags = VMS_VBUFFER|VMS_POINTER, \
394 .offset = offsetof(_state, _field), \
395 .start = (_start), \
396}
397
398#define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
399 .name = (stringify(_field)), \
400 .version_id = (_version), \
401 .size = (_size), \
402 .info = &(_info), \
403 .flags = VMS_BUFFER, \
404 .offset = offsetof(_state, _field), \
405}
406
407#define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
408 .name = "unused", \
409 .field_exists = (_test), \
410 .version_id = (_version), \
411 .size = (_size), \
412 .info = &vmstate_info_unused_buffer, \
413 .flags = VMS_BUFFER, \
414}
415
416
417
418
419#define VMSTATE_BITMAP(_field, _state, _version, _field_size) { \
420 .name = (stringify(_field)), \
421 .version_id = (_version), \
422 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
423 .info = &vmstate_info_bitmap, \
424 .flags = VMS_VBUFFER|VMS_POINTER, \
425 .offset = offsetof(_state, _field), \
426}
427
428
429
430
431
432
433
434
435#define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
436 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
437
438#define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \
439 VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
440
441#define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \
442 VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)
443
444#define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \
445 VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \
446 _vmsd, _type)
447
448#define VMSTATE_BOOL_V(_f, _s, _v) \
449 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool)
450
451#define VMSTATE_INT8_V(_f, _s, _v) \
452 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
453#define VMSTATE_INT16_V(_f, _s, _v) \
454 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
455#define VMSTATE_INT32_V(_f, _s, _v) \
456 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
457#define VMSTATE_INT64_V(_f, _s, _v) \
458 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
459
460#define VMSTATE_UINT8_V(_f, _s, _v) \
461 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
462#define VMSTATE_UINT16_V(_f, _s, _v) \
463 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
464#define VMSTATE_UINT32_V(_f, _s, _v) \
465 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
466#define VMSTATE_UINT64_V(_f, _s, _v) \
467 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
468
469#define VMSTATE_BOOL(_f, _s) \
470 VMSTATE_BOOL_V(_f, _s, 0)
471
472#define VMSTATE_INT8(_f, _s) \
473 VMSTATE_INT8_V(_f, _s, 0)
474#define VMSTATE_INT16(_f, _s) \
475 VMSTATE_INT16_V(_f, _s, 0)
476#define VMSTATE_INT32(_f, _s) \
477 VMSTATE_INT32_V(_f, _s, 0)
478#define VMSTATE_INT64(_f, _s) \
479 VMSTATE_INT64_V(_f, _s, 0)
480
481#define VMSTATE_UINT8(_f, _s) \
482 VMSTATE_UINT8_V(_f, _s, 0)
483#define VMSTATE_UINT16(_f, _s) \
484 VMSTATE_UINT16_V(_f, _s, 0)
485#define VMSTATE_UINT32(_f, _s) \
486 VMSTATE_UINT32_V(_f, _s, 0)
487#define VMSTATE_UINT64(_f, _s) \
488 VMSTATE_UINT64_V(_f, _s, 0)
489
490#define VMSTATE_UINT8_EQUAL(_f, _s) \
491 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
492
493#define VMSTATE_UINT16_EQUAL(_f, _s) \
494 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
495
496#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
497 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
498
499#define VMSTATE_INT32_EQUAL(_f, _s) \
500 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
501
502#define VMSTATE_UINT32_EQUAL(_f, _s) \
503 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint32_equal, uint32_t)
504
505#define VMSTATE_INT32_LE(_f, _s) \
506 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
507
508#define VMSTATE_UINT8_TEST(_f, _s, _t) \
509 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
510
511#define VMSTATE_UINT16_TEST(_f, _s, _t) \
512 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
513
514#define VMSTATE_UINT32_TEST(_f, _s, _t) \
515 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
516
517#define VMSTATE_TIMER_TEST(_f, _s, _test) \
518 VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
519
520#define VMSTATE_TIMER_V(_f, _s, _v) \
521 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
522
523#define VMSTATE_TIMER(_f, _s) \
524 VMSTATE_TIMER_V(_f, _s, 0)
525
526#define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
527 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
528
529#define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \
530 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool)
531
532#define VMSTATE_BOOL_ARRAY(_f, _s, _n) \
533 VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0)
534
535#define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
536 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
537
538#define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
539 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
540
541#define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
542 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
543
544#define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
545 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
546
547#define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
548 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
549
550#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
551 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
552
553#define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
554 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
555
556#define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
557 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
558
559#define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
560 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
561
562#define VMSTATE_INT16_ARRAY(_f, _s, _n) \
563 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
564
565#define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
566 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
567
568#define VMSTATE_INT32_ARRAY(_f, _s, _n) \
569 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
570
571#define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
572 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
573
574#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
575 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
576
577#define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \
578 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t)
579
580#define VMSTATE_INT64_ARRAY(_f, _s, _n) \
581 VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)
582
583#define VMSTATE_BUFFER_V(_f, _s, _v) \
584 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
585
586#define VMSTATE_BUFFER(_f, _s) \
587 VMSTATE_BUFFER_V(_f, _s, 0)
588
589#define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
590 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
591
592#define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
593 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
594
595#define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \
596 VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size)
597
598#define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) \
599 VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size)
600
601#define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \
602 VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size)
603
604#define VMSTATE_BUFFER_TEST(_f, _s, _test) \
605 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
606
607#define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
608 VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
609
610#define VMSTATE_UNUSED_V(_v, _size) \
611 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
612
613#define VMSTATE_UNUSED(_size) \
614 VMSTATE_UNUSED_V(0, _size)
615
616#define VMSTATE_UNUSED_TEST(_test, _size) \
617 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
618
619#define VMSTATE_END_OF_LIST() \
620 {}
621
622int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
623 void *opaque, int version_id);
624void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
625 void *opaque);
626int vmstate_register(DeviceState *dev, int instance_id,
627 const VMStateDescription *vmsd, void *base);
628int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
629 const VMStateDescription *vmsd,
630 void *base, int alias_id,
631 int required_for_version);
632void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
633 void *opaque);
634
635struct MemoryRegion;
636void vmstate_register_ram(struct MemoryRegion *memory, DeviceState *dev);
637void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev);
638void vmstate_register_ram_global(struct MemoryRegion *memory);
639
640#endif
641