aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * QEMU live migration |
| 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 QEMU_MIGRATION_H |
| 15 | #define QEMU_MIGRATION_H |
| 16 | |
Luiz Capitulino | f96fc8a | 2009-08-28 15:27:12 -0300 | [diff] [blame] | 17 | #include "qdict.h" |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 18 | #include "qemu-common.h" |
Gerd Hoffmann | 99a0db9 | 2010-12-13 17:30:12 +0100 | [diff] [blame] | 19 | #include "notify.h" |
Anthony Liguori | fa2756b | 2011-11-14 15:09:43 -0600 | [diff] [blame^] | 20 | #include "error.h" |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 21 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame] | 22 | typedef struct MigrationState MigrationState; |
Juan Quintela | dc7acc6 | 2010-05-11 15:46:39 +0200 | [diff] [blame] | 23 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame] | 24 | struct MigrationState |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 25 | { |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 26 | int64_t bandwidth_limit; |
| 27 | QEMUFile *file; |
| 28 | int fd; |
Jan Kiszka | f327aa0 | 2009-11-30 18:21:21 +0100 | [diff] [blame] | 29 | Monitor *mon; |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 30 | int state; |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame] | 31 | int (*get_error)(MigrationState *s); |
| 32 | int (*close)(MigrationState *s); |
| 33 | int (*write)(MigrationState *s, const void *buff, size_t size); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 34 | void *opaque; |
Juan Quintela | 3f77fc5 | 2010-05-11 15:51:36 +0200 | [diff] [blame] | 35 | int blk; |
| 36 | int shared; |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 37 | }; |
| 38 | |
Juan Quintela | 511c023 | 2010-06-09 14:10:55 +0200 | [diff] [blame] | 39 | void process_incoming_migration(QEMUFile *f); |
| 40 | |
Juan Quintela | 8ca5e80 | 2010-06-09 14:10:54 +0200 | [diff] [blame] | 41 | int qemu_start_incoming_migration(const char *uri); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 42 | |
Luiz Capitulino | b5d17ad | 2010-02-10 23:49:57 -0200 | [diff] [blame] | 43 | int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 44 | |
Luiz Capitulino | ef4b7ee | 2010-02-10 23:49:48 -0200 | [diff] [blame] | 45 | int do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 46 | |
Luiz Capitulino | ef4b7ee | 2010-02-10 23:49:48 -0200 | [diff] [blame] | 47 | int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 48 | |
Glauber Costa | a0a3fd6 | 2009-05-28 15:22:57 -0400 | [diff] [blame] | 49 | uint64_t migrate_max_downtime(void); |
| 50 | |
Luiz Capitulino | ef4b7ee | 2010-02-10 23:49:48 -0200 | [diff] [blame] | 51 | int do_migrate_set_downtime(Monitor *mon, const QDict *qdict, |
| 52 | QObject **ret_data); |
Glauber Costa | 2ea4295 | 2009-05-28 15:22:58 -0400 | [diff] [blame] | 53 | |
Luiz Capitulino | c86a668 | 2009-12-10 17:16:05 -0200 | [diff] [blame] | 54 | void do_info_migrate_print(Monitor *mon, const QObject *data); |
| 55 | |
| 56 | void do_info_migrate(Monitor *mon, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 57 | |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 58 | int exec_start_incoming_migration(const char *host_port); |
| 59 | |
Juan Quintela | 07af445 | 2010-05-11 22:27:45 +0200 | [diff] [blame] | 60 | int exec_start_outgoing_migration(MigrationState *s, const char *host_port); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 61 | |
aliguori | 34c9dd8 | 2008-10-13 03:14:31 +0000 | [diff] [blame] | 62 | int tcp_start_incoming_migration(const char *host_port); |
| 63 | |
Juan Quintela | 07af445 | 2010-05-11 22:27:45 +0200 | [diff] [blame] | 64 | int tcp_start_outgoing_migration(MigrationState *s, const char *host_port); |
aliguori | 34c9dd8 | 2008-10-13 03:14:31 +0000 | [diff] [blame] | 65 | |
Chris Lalancette | 4951f65 | 2009-08-05 17:24:29 +0200 | [diff] [blame] | 66 | int unix_start_incoming_migration(const char *path); |
| 67 | |
Juan Quintela | 07af445 | 2010-05-11 22:27:45 +0200 | [diff] [blame] | 68 | int unix_start_outgoing_migration(MigrationState *s, const char *path); |
Chris Lalancette | 4951f65 | 2009-08-05 17:24:29 +0200 | [diff] [blame] | 69 | |
Paolo Bonzini | 5ac1fad | 2009-08-18 15:56:25 +0200 | [diff] [blame] | 70 | int fd_start_incoming_migration(const char *path); |
| 71 | |
Juan Quintela | 07af445 | 2010-05-11 22:27:45 +0200 | [diff] [blame] | 72 | int fd_start_outgoing_migration(MigrationState *s, const char *fdname); |
Paolo Bonzini | 5ac1fad | 2009-08-18 15:56:25 +0200 | [diff] [blame] | 73 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame] | 74 | void migrate_fd_error(MigrationState *s); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 75 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame] | 76 | void migrate_fd_connect(MigrationState *s); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 77 | |
Gerd Hoffmann | 99a0db9 | 2010-12-13 17:30:12 +0100 | [diff] [blame] | 78 | void add_migration_state_change_notifier(Notifier *notify); |
| 79 | void remove_migration_state_change_notifier(Notifier *notify); |
Gerd Hoffmann | afe2df6 | 2011-10-25 13:50:11 +0200 | [diff] [blame] | 80 | bool migration_is_active(MigrationState *); |
Juan Quintela | 7073693 | 2011-02-23 00:43:59 +0100 | [diff] [blame] | 81 | bool migration_has_finished(MigrationState *); |
Gerd Hoffmann | afe2df6 | 2011-10-25 13:50:11 +0200 | [diff] [blame] | 82 | bool migration_has_failed(MigrationState *); |
Gerd Hoffmann | 99a0db9 | 2010-12-13 17:30:12 +0100 | [diff] [blame] | 83 | |
Blue Swirl | adc56dd | 2011-04-03 08:23:19 +0000 | [diff] [blame] | 84 | uint64_t ram_bytes_remaining(void); |
| 85 | uint64_t ram_bytes_transferred(void); |
| 86 | uint64_t ram_bytes_total(void); |
| 87 | |
| 88 | int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque); |
| 89 | int ram_load(QEMUFile *f, void *opaque, int version_id); |
| 90 | |
| 91 | extern int incoming_expected; |
| 92 | |
Anthony Liguori | fa2756b | 2011-11-14 15:09:43 -0600 | [diff] [blame^] | 93 | /** |
| 94 | * @migrate_add_blocker - prevent migration from proceeding |
| 95 | * |
| 96 | * @reason - an error to be returned whenever migration is attempted |
| 97 | */ |
| 98 | void migrate_add_blocker(Error *reason); |
| 99 | |
| 100 | /** |
| 101 | * @migrate_del_blocker - remove a blocking error from migration |
| 102 | * |
| 103 | * @reason - the error blocking migration |
| 104 | */ |
| 105 | void migrate_del_blocker(Error *reason); |
| 106 | |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 107 | #endif |