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" |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 20 | |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 21 | #define MIG_STATE_ERROR -1 |
| 22 | #define MIG_STATE_COMPLETED 0 |
| 23 | #define MIG_STATE_CANCELLED 1 |
| 24 | #define MIG_STATE_ACTIVE 2 |
| 25 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 26 | typedef struct MigrationState MigrationState; |
Juan Quintela | dc7acc6 | 2010-05-11 15:46:39 +0200 | [diff] [blame] | 27 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 28 | struct MigrationState |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 29 | { |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 30 | int64_t bandwidth_limit; |
| 31 | QEMUFile *file; |
| 32 | int fd; |
Jan Kiszka | f327aa0 | 2009-11-30 18:21:21 +0100 | [diff] [blame] | 33 | Monitor *mon; |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 34 | int state; |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 35 | int (*get_error)(MigrationState *s); |
| 36 | int (*close)(MigrationState *s); |
| 37 | int (*write)(MigrationState *s, const void *buff, size_t size); |
| 38 | void (*cancel)(MigrationState *s); |
| 39 | int (*get_status)(MigrationState *s); |
| 40 | void (*release)(MigrationState *s); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 41 | void *opaque; |
Juan Quintela | 3f77fc5 | 2010-05-11 15:51:36 +0200 | [diff] [blame] | 42 | int blk; |
| 43 | int shared; |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
Juan Quintela | 511c023 | 2010-06-09 14:10:55 +0200 | [diff] [blame] | 46 | void process_incoming_migration(QEMUFile *f); |
| 47 | |
Juan Quintela | 8ca5e80 | 2010-06-09 14:10:54 +0200 | [diff] [blame] | 48 | int qemu_start_incoming_migration(const char *uri); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 49 | |
Luiz Capitulino | b5d17ad | 2010-02-10 23:49:57 -0200 | [diff] [blame] | 50 | int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 51 | |
Luiz Capitulino | ef4b7ee | 2010-02-10 23:49:48 -0200 | [diff] [blame] | 52 | int do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 53 | |
Luiz Capitulino | ef4b7ee | 2010-02-10 23:49:48 -0200 | [diff] [blame] | 54 | int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 55 | |
Glauber Costa | a0a3fd6 | 2009-05-28 15:22:57 -0400 | [diff] [blame] | 56 | uint64_t migrate_max_downtime(void); |
| 57 | |
Luiz Capitulino | ef4b7ee | 2010-02-10 23:49:48 -0200 | [diff] [blame] | 58 | int do_migrate_set_downtime(Monitor *mon, const QDict *qdict, |
| 59 | QObject **ret_data); |
Glauber Costa | 2ea4295 | 2009-05-28 15:22:58 -0400 | [diff] [blame] | 60 | |
Luiz Capitulino | c86a668 | 2009-12-10 17:16:05 -0200 | [diff] [blame] | 61 | void do_info_migrate_print(Monitor *mon, const QObject *data); |
| 62 | |
| 63 | void do_info_migrate(Monitor *mon, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 64 | |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 65 | int exec_start_incoming_migration(const char *host_port); |
| 66 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 67 | MigrationState *exec_start_outgoing_migration(Monitor *mon, |
Jan Kiszka | f327aa0 | 2009-11-30 18:21:21 +0100 | [diff] [blame] | 68 | const char *host_port, |
lirans@il.ibm.com | c163b5c | 2009-11-02 15:40:58 +0200 | [diff] [blame] | 69 | int64_t bandwidth_limit, |
| 70 | int detach, |
| 71 | int blk, |
| 72 | int inc); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 73 | |
aliguori | 34c9dd8 | 2008-10-13 03:14:31 +0000 | [diff] [blame] | 74 | int tcp_start_incoming_migration(const char *host_port); |
| 75 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 76 | MigrationState *tcp_start_outgoing_migration(Monitor *mon, |
Jan Kiszka | f327aa0 | 2009-11-30 18:21:21 +0100 | [diff] [blame] | 77 | const char *host_port, |
aliguori | 34c9dd8 | 2008-10-13 03:14:31 +0000 | [diff] [blame] | 78 | int64_t bandwidth_limit, |
lirans@il.ibm.com | c163b5c | 2009-11-02 15:40:58 +0200 | [diff] [blame] | 79 | int detach, |
| 80 | int blk, |
| 81 | int inc); |
aliguori | 34c9dd8 | 2008-10-13 03:14:31 +0000 | [diff] [blame] | 82 | |
Chris Lalancette | 4951f65 | 2009-08-05 17:24:29 +0200 | [diff] [blame] | 83 | int unix_start_incoming_migration(const char *path); |
| 84 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 85 | MigrationState *unix_start_outgoing_migration(Monitor *mon, |
Jan Kiszka | f327aa0 | 2009-11-30 18:21:21 +0100 | [diff] [blame] | 86 | const char *path, |
Chris Lalancette | 4951f65 | 2009-08-05 17:24:29 +0200 | [diff] [blame] | 87 | int64_t bandwidth_limit, |
lirans@il.ibm.com | c163b5c | 2009-11-02 15:40:58 +0200 | [diff] [blame] | 88 | int detach, |
| 89 | int blk, |
| 90 | int inc); |
Chris Lalancette | 4951f65 | 2009-08-05 17:24:29 +0200 | [diff] [blame] | 91 | |
Paolo Bonzini | 5ac1fad | 2009-08-18 15:56:25 +0200 | [diff] [blame] | 92 | int fd_start_incoming_migration(const char *path); |
| 93 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 94 | MigrationState *fd_start_outgoing_migration(Monitor *mon, |
Paolo Bonzini | 5ac1fad | 2009-08-18 15:56:25 +0200 | [diff] [blame] | 95 | const char *fdname, |
| 96 | int64_t bandwidth_limit, |
lirans@il.ibm.com | c163b5c | 2009-11-02 15:40:58 +0200 | [diff] [blame] | 97 | int detach, |
| 98 | int blk, |
| 99 | int inc); |
Paolo Bonzini | 5ac1fad | 2009-08-18 15:56:25 +0200 | [diff] [blame] | 100 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 101 | void migrate_fd_monitor_suspend(MigrationState *s, Monitor *mon); |
aliguori | 731b036 | 2009-03-05 23:01:42 +0000 | [diff] [blame] | 102 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 103 | void migrate_fd_error(MigrationState *s); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 104 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 105 | int migrate_fd_cleanup(MigrationState *s); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 106 | |
| 107 | void migrate_fd_put_notify(void *opaque); |
| 108 | |
| 109 | ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size); |
| 110 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 111 | void migrate_fd_connect(MigrationState *s); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 112 | |
| 113 | void migrate_fd_put_ready(void *opaque); |
| 114 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 115 | int migrate_fd_get_status(MigrationState *mig_state); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 116 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 117 | void migrate_fd_cancel(MigrationState *mig_state); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 118 | |
Juan Quintela | 22f00a4 | 2010-05-11 15:56:35 +0200 | [diff] [blame^] | 119 | void migrate_fd_release(MigrationState *mig_state); |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 120 | |
| 121 | void migrate_fd_wait_for_unfreeze(void *opaque); |
| 122 | |
| 123 | int migrate_fd_close(void *opaque); |
| 124 | |
Gerd Hoffmann | 99a0db9 | 2010-12-13 17:30:12 +0100 | [diff] [blame] | 125 | void add_migration_state_change_notifier(Notifier *notify); |
| 126 | void remove_migration_state_change_notifier(Notifier *notify); |
| 127 | int get_migration_state(void); |
| 128 | |
Blue Swirl | adc56dd | 2011-04-03 08:23:19 +0000 | [diff] [blame] | 129 | uint64_t ram_bytes_remaining(void); |
| 130 | uint64_t ram_bytes_transferred(void); |
| 131 | uint64_t ram_bytes_total(void); |
| 132 | |
| 133 | int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque); |
| 134 | int ram_load(QEMUFile *f, void *opaque, int version_id); |
| 135 | |
| 136 | extern int incoming_expected; |
| 137 | |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 138 | #endif |