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