2 * QEMU migration vmstate registration
4 * Copyright IBM, Corp. 2008
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 #include "hw/vmstate-if.h"
19 typedef struct SaveVMHandlers
{
20 /* This runs inside the iothread lock. */
21 SaveStateHandler
*save_state
;
23 void (*save_cleanup
)(void *opaque
);
24 int (*save_live_complete_postcopy
)(QEMUFile
*f
, void *opaque
);
25 int (*save_live_complete_precopy
)(QEMUFile
*f
, void *opaque
);
27 /* This runs both outside and inside the iothread lock. */
28 bool (*is_active
)(void *opaque
);
29 bool (*has_postcopy
)(void *opaque
);
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
38 bool (*is_active_iterate
)(void *opaque
);
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
45 int (*save_live_iterate
)(QEMUFile
*f
, void *opaque
);
47 /* This runs outside the iothread lock! */
48 int (*save_setup
)(QEMUFile
*f
, void *opaque
);
49 /* Note for save_live_pending:
51 * - must be migrated in precopy or in stopped state
52 * - i.e. must be migrated before target start
55 * - can migrate in postcopy or in stopped state
56 * - i.e. can migrate after target start
57 * - some can also be migrated during precopy (RAM)
58 * - some must be migrated after source stops (block-dirty-bitmap)
60 * Sum of can_postcopy and must_postcopy is the whole amount of
63 /* This estimates the remaining data to transfer */
64 void (*state_pending_estimate
)(void *opaque
, uint64_t *must_precopy
,
65 uint64_t *can_postcopy
);
66 /* This calculate the exact remaining data to transfer */
67 void (*state_pending_exact
)(void *opaque
, uint64_t *must_precopy
,
68 uint64_t *can_postcopy
);
69 LoadStateHandler
*load_state
;
70 int (*load_setup
)(QEMUFile
*f
, void *opaque
);
71 int (*load_cleanup
)(void *opaque
);
72 /* Called when postcopy migration wants to resume from failure */
73 int (*resume_prepare
)(MigrationState
*s
, void *opaque
);
76 int register_savevm_live(const char *idstr
,
79 const SaveVMHandlers
*ops
,
82 void unregister_savevm(VMStateIf
*obj
, const char *idstr
, void *opaque
);