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