block: Only the main loop can change AioContexts
[qemu/ar7.git] / include / migration / register.h
blob3d0b9833c6fd7c07b46c82c861fd4d9985ada9b3
1 /*
2 * QEMU migration vmstate registration
4 * Copyright IBM, Corp. 2008
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #ifndef MIGRATION_REGISTER_H
15 #define MIGRATION_REGISTER_H
17 typedef struct SaveVMHandlers {
18 /* This runs inside the iothread lock. */
19 SaveStateHandler *save_state;
21 void (*save_cleanup)(void *opaque);
22 int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque);
23 int (*save_live_complete_precopy)(QEMUFile *f, void *opaque);
25 /* This runs both outside and inside the iothread lock. */
26 bool (*is_active)(void *opaque);
27 bool (*has_postcopy)(void *opaque);
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.
36 bool (*is_active_iterate)(void *opaque);
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.
43 int (*save_live_iterate)(QEMUFile *f, void *opaque);
45 /* This runs outside the iothread lock! */
46 int (*save_setup)(QEMUFile *f, void *opaque);
47 void (*save_live_pending)(QEMUFile *f, void *opaque,
48 uint64_t threshold_size,
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
59 * Sum of res_postcopy_only, res_compatible and res_postcopy_only is the
60 * whole amount of pending data.
64 LoadStateHandler *load_state;
65 int (*load_setup)(QEMUFile *f, void *opaque);
66 int (*load_cleanup)(void *opaque);
67 /* Called when postcopy migration wants to resume from failure */
68 int (*resume_prepare)(MigrationState *s, void *opaque);
69 } SaveVMHandlers;
71 int register_savevm_live(DeviceState *dev,
72 const char *idstr,
73 int instance_id,
74 int version_id,
75 const SaveVMHandlers *ops,
76 void *opaque);
78 void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque);
80 #endif