xref: /openbmc/qemu/include/migration/blocker.h (revision d349d5ab)
1 /*
2  * QEMU migration blockers
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_BLOCKER_H
15 #define MIGRATION_BLOCKER_H
16 
17 #include "qapi/qapi-types-migration.h"
18 
19 #define MIG_MODE_ALL MIG_MODE__MAX
20 
21 /**
22  * @migrate_add_blocker - prevent all modes of migration from proceeding
23  *
24  * @reasonp - address of an error to be returned whenever migration is attempted
25  *
26  * @errp - [out] The reason (if any) we cannot block migration right now.
27  *
28  * @returns - 0 on success, -EBUSY/-EACCES on failure, with errp set.
29  *
30  * *@reasonp is freed and set to NULL if failure is returned.
31  * On success, the caller must not free @reasonp, except by
32  *   calling migrate_del_blocker.
33  */
34 int migrate_add_blocker(Error **reasonp, Error **errp);
35 
36 /**
37  * @migrate_add_blocker_internal - prevent all modes of migration from
38  *                                 proceeding, but ignore -only-migratable
39  *
40  * @reasonp - address of an error to be returned whenever migration is attempted
41  *
42  * @errp - [out] The reason (if any) we cannot block migration right now.
43  *
44  * @returns - 0 on success, -EBUSY on failure, with errp set.
45  *
46  * Some of the migration blockers can be temporary (e.g., for a few seconds),
47  * so it shouldn't need to conflict with "-only-migratable".  For those cases,
48  * we can call this function rather than @migrate_add_blocker().
49  *
50  * *@reasonp is freed and set to NULL if failure is returned.
51  * On success, the caller must not free @reasonp, except by
52  *   calling migrate_del_blocker.
53  */
54 int migrate_add_blocker_internal(Error **reasonp, Error **errp);
55 
56 /**
57  * @migrate_del_blocker - remove a migration blocker from all modes and free it.
58  *
59  * @reasonp - address of the error blocking migration
60  *
61  * This function frees *@reasonp and sets it to NULL.
62  */
63 void migrate_del_blocker(Error **reasonp);
64 
65 /**
66  * @migrate_add_blocker_normal - prevent normal migration mode from proceeding
67  *
68  * @reasonp - address of an error to be returned whenever migration is attempted
69  *
70  * @errp - [out] The reason (if any) we cannot block migration right now.
71  *
72  * @returns - 0 on success, -EBUSY/-EACCES on failure, with errp set.
73  *
74  * *@reasonp is freed and set to NULL if failure is returned.
75  * On success, the caller must not free @reasonp, except by
76  *   calling migrate_del_blocker.
77  */
78 int migrate_add_blocker_normal(Error **reasonp, Error **errp);
79 
80 /**
81  * @migrate_add_blocker_modes - prevent some modes of migration from proceeding
82  *
83  * @reasonp - address of an error to be returned whenever migration is attempted
84  *
85  * @errp - [out] The reason (if any) we cannot block migration right now.
86  *
87  * @mode - one or more migration modes to be blocked.  The list is terminated
88  *         by -1 or MIG_MODE_ALL.  For the latter, all modes are blocked.
89  *
90  * @returns - 0 on success, -EBUSY/-EACCES on failure, with errp set.
91  *
92  * *@reasonp is freed and set to NULL if failure is returned.
93  * On success, the caller must not free *@reasonp before the blocker is removed.
94  */
95 int migrate_add_blocker_modes(Error **reasonp, Error **errp, MigMode mode, ...);
96 
97 #endif
98