]>
Commit | Line | Data |
---|---|---|
f2a8f0a6 JQ |
1 | /* |
2 | * QEMU migration vmstate registration | |
3 | * | |
4 | * Copyright IBM, Corp. 2008 | |
5 | * | |
6 | * Authors: | |
7 | * Anthony Liguori <aliguori@us.ibm.com> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2. See | |
10 | * the COPYING file in the top-level directory. | |
11 | * | |
12 | */ | |
13 | ||
14 | #ifndef MIGRATION_REGISTER_H | |
15 | #define MIGRATION_REGISTER_H | |
16 | ||
107b5969 MAL |
17 | #include "hw/vmstate-if.h" |
18 | ||
f2a8f0a6 JQ |
19 | typedef struct SaveVMHandlers { |
20 | /* This runs inside the iothread lock. */ | |
21 | SaveStateHandler *save_state; | |
22 | ||
70f794fc | 23 | void (*save_cleanup)(void *opaque); |
f2a8f0a6 JQ |
24 | int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); |
25 | int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); | |
26 | ||
27 | /* This runs both outside and inside the iothread lock. */ | |
28 | bool (*is_active)(void *opaque); | |
c6467627 | 29 | bool (*has_postcopy)(void *opaque); |
f2a8f0a6 | 30 | |
c865d848 VSO |
31 | /* is_active_iterate |
32 | * If it is not NULL then qemu_savevm_state_iterate will skip iteration if | |
33 | * it returns false. For example, it is needed for only-postcopy-states, | |
34 | * which needs to be handled by qemu_savevm_state_setup and | |
35 | * qemu_savevm_state_pending, but do not need iterations until not in | |
36 | * postcopy stage. | |
37 | */ | |
38 | bool (*is_active_iterate)(void *opaque); | |
39 | ||
f2a8f0a6 JQ |
40 | /* This runs outside the iothread lock in the migration case, and |
41 | * within the lock in the savevm case. The callback had better only | |
42 | * use data that is local to the migration thread or protected | |
43 | * by other locks. | |
44 | */ | |
45 | int (*save_live_iterate)(QEMUFile *f, void *opaque); | |
46 | ||
47 | /* This runs outside the iothread lock! */ | |
9907e842 | 48 | int (*save_setup)(QEMUFile *f, void *opaque); |
f2a8f0a6 JQ |
49 | void (*save_live_pending)(QEMUFile *f, void *opaque, |
50 | uint64_t threshold_size, | |
47995026 VSO |
51 | uint64_t *res_precopy_only, |
52 | uint64_t *res_compatible, | |
53 | uint64_t *res_postcopy_only); | |
54 | /* Note for save_live_pending: | |
55 | * - res_precopy_only is for data which must be migrated in precopy phase | |
56 | * or in stopped state, in other words - before target vm start | |
57 | * - res_compatible is for data which may be migrated in any phase | |
58 | * - res_postcopy_only is for data which must be migrated in postcopy phase | |
59 | * or in stopped state, in other words - after source vm stop | |
60 | * | |
61 | * Sum of res_postcopy_only, res_compatible and res_postcopy_only is the | |
62 | * whole amount of pending data. | |
63 | */ | |
64 | ||
65 | ||
f2a8f0a6 | 66 | LoadStateHandler *load_state; |
acb5ea86 JQ |
67 | int (*load_setup)(QEMUFile *f, void *opaque); |
68 | int (*load_cleanup)(void *opaque); | |
d1b8eadb PX |
69 | /* Called when postcopy migration wants to resume from failure */ |
70 | int (*resume_prepare)(MigrationState *s, void *opaque); | |
f2a8f0a6 JQ |
71 | } SaveVMHandlers; |
72 | ||
ce62df53 | 73 | int register_savevm_live(const char *idstr, |
f2a8f0a6 JQ |
74 | int instance_id, |
75 | int version_id, | |
de22ded0 | 76 | const SaveVMHandlers *ops, |
f2a8f0a6 JQ |
77 | void *opaque); |
78 | ||
3cad405b | 79 | void unregister_savevm(VMStateIf *obj, const char *idstr, void *opaque); |
f2a8f0a6 JQ |
80 | |
81 | #endif |