]>
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 | ||
08fc4cb5 AH |
23 | /* |
24 | * save_prepare is called early, even before migration starts, and can be | |
25 | * used to perform early checks. | |
26 | */ | |
27 | int (*save_prepare)(void *opaque, Error **errp); | |
930e239d | 28 | int (*save_setup)(QEMUFile *f, void *opaque); |
70f794fc | 29 | void (*save_cleanup)(void *opaque); |
f2a8f0a6 JQ |
30 | int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); |
31 | int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); | |
32 | ||
33 | /* This runs both outside and inside the iothread lock. */ | |
34 | bool (*is_active)(void *opaque); | |
c6467627 | 35 | bool (*has_postcopy)(void *opaque); |
f2a8f0a6 | 36 | |
c865d848 VSO |
37 | /* is_active_iterate |
38 | * If it is not NULL then qemu_savevm_state_iterate will skip iteration if | |
39 | * it returns false. For example, it is needed for only-postcopy-states, | |
40 | * which needs to be handled by qemu_savevm_state_setup and | |
41 | * qemu_savevm_state_pending, but do not need iterations until not in | |
42 | * postcopy stage. | |
43 | */ | |
44 | bool (*is_active_iterate)(void *opaque); | |
45 | ||
f2a8f0a6 JQ |
46 | /* This runs outside the iothread lock in the migration case, and |
47 | * within the lock in the savevm case. The callback had better only | |
48 | * use data that is local to the migration thread or protected | |
49 | * by other locks. | |
50 | */ | |
51 | int (*save_live_iterate)(QEMUFile *f, void *opaque); | |
52 | ||
53 | /* This runs outside the iothread lock! */ | |
47995026 | 54 | /* Note for save_live_pending: |
24beea4e JQ |
55 | * must_precopy: |
56 | * - must be migrated in precopy or in stopped state | |
57 | * - i.e. must be migrated before target start | |
47995026 | 58 | * |
24beea4e JQ |
59 | * can_postcopy: |
60 | * - can migrate in postcopy or in stopped state | |
61 | * - i.e. can migrate after target start | |
62 | * - some can also be migrated during precopy (RAM) | |
63 | * - some must be migrated after source stops (block-dirty-bitmap) | |
64 | * | |
65 | * Sum of can_postcopy and must_postcopy is the whole amount of | |
66 | * pending data. | |
47995026 | 67 | */ |
c8df4a7a | 68 | /* This estimates the remaining data to transfer */ |
24beea4e JQ |
69 | void (*state_pending_estimate)(void *opaque, uint64_t *must_precopy, |
70 | uint64_t *can_postcopy); | |
c8df4a7a | 71 | /* This calculate the exact remaining data to transfer */ |
24beea4e JQ |
72 | void (*state_pending_exact)(void *opaque, uint64_t *must_precopy, |
73 | uint64_t *can_postcopy); | |
f2a8f0a6 | 74 | LoadStateHandler *load_state; |
acb5ea86 JQ |
75 | int (*load_setup)(QEMUFile *f, void *opaque); |
76 | int (*load_cleanup)(void *opaque); | |
d1b8eadb PX |
77 | /* Called when postcopy migration wants to resume from failure */ |
78 | int (*resume_prepare)(MigrationState *s, void *opaque); | |
1b4adb10 AH |
79 | /* Checks if switchover ack should be used. Called only in dest */ |
80 | bool (*switchover_ack_needed)(void *opaque); | |
f2a8f0a6 JQ |
81 | } SaveVMHandlers; |
82 | ||
ce62df53 | 83 | int register_savevm_live(const char *idstr, |
93062e23 | 84 | uint32_t instance_id, |
f2a8f0a6 | 85 | int version_id, |
de22ded0 | 86 | const SaveVMHandlers *ops, |
f2a8f0a6 JQ |
87 | void *opaque); |
88 | ||
3cad405b | 89 | void unregister_savevm(VMStateIf *obj, const char *idstr, void *opaque); |
f2a8f0a6 JQ |
90 | |
91 | #endif |