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" |
| 19 | |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 20 | #define MIG_STATE_ERROR -1 |
| 21 | #define MIG_STATE_COMPLETED 0 |
| 22 | #define MIG_STATE_CANCELLED 1 |
| 23 | #define MIG_STATE_ACTIVE 2 |
| 24 | |
| 25 | typedef struct MigrationState MigrationState; |
| 26 | |
| 27 | struct MigrationState |
| 28 | { |
| 29 | /* FIXME: add more accessors to print migration info */ |
| 30 | void (*cancel)(MigrationState *s); |
| 31 | int (*get_status)(MigrationState *s); |
| 32 | void (*release)(MigrationState *s); |
| 33 | }; |
| 34 | |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 35 | typedef struct FdMigrationState FdMigrationState; |
| 36 | |
| 37 | struct FdMigrationState |
| 38 | { |
| 39 | MigrationState mig_state; |
| 40 | int64_t bandwidth_limit; |
| 41 | QEMUFile *file; |
| 42 | int fd; |
aliguori | 731b036 | 2009-03-05 23:01:42 +0000 | [diff] [blame] | 43 | Monitor *mon_resume; |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 44 | int state; |
| 45 | int (*get_error)(struct FdMigrationState*); |
| 46 | int (*close)(struct FdMigrationState*); |
| 47 | int (*write)(struct FdMigrationState*, const void *, size_t); |
| 48 | void *opaque; |
| 49 | }; |
| 50 | |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 51 | void qemu_start_incoming_migration(const char *uri); |
| 52 | |
Luiz Capitulino | 5f79da0 | 2009-10-16 12:23:45 -0300 | [diff] [blame] | 53 | void do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 54 | |
Luiz Capitulino | 911d296 | 2009-10-16 12:23:47 -0300 | [diff] [blame] | 55 | void do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 56 | |
Luiz Capitulino | 3a49210 | 2009-10-16 12:23:46 -0300 | [diff] [blame] | 57 | void do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data); |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 58 | |
Glauber Costa | a0a3fd6 | 2009-05-28 15:22:57 -0400 | [diff] [blame] | 59 | uint64_t migrate_max_downtime(void); |
| 60 | |
Luiz Capitulino | d54908a | 2009-08-28 15:27:13 -0300 | [diff] [blame] | 61 | void do_migrate_set_downtime(Monitor *mon, const QDict *qdict); |
Glauber Costa | 2ea4295 | 2009-05-28 15:22:58 -0400 | [diff] [blame] | 62 | |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 63 | void do_info_migrate(Monitor *mon); |
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 | |
| 67 | MigrationState *exec_start_outgoing_migration(const char *host_port, |
| 68 | int64_t bandwidth_limit, |
| 69 | int detach); |
| 70 | |
aliguori | 34c9dd8 | 2008-10-13 03:14:31 +0000 | [diff] [blame] | 71 | int tcp_start_incoming_migration(const char *host_port); |
| 72 | |
| 73 | MigrationState *tcp_start_outgoing_migration(const char *host_port, |
| 74 | int64_t bandwidth_limit, |
| 75 | int detach); |
| 76 | |
Chris Lalancette | 4951f65 | 2009-08-05 17:24:29 +0200 | [diff] [blame] | 77 | int unix_start_incoming_migration(const char *path); |
| 78 | |
| 79 | MigrationState *unix_start_outgoing_migration(const char *path, |
| 80 | int64_t bandwidth_limit, |
| 81 | int detach); |
| 82 | |
Paolo Bonzini | 5ac1fad | 2009-08-18 15:56:25 +0200 | [diff] [blame] | 83 | int fd_start_incoming_migration(const char *path); |
| 84 | |
| 85 | MigrationState *fd_start_outgoing_migration(Monitor *mon, |
| 86 | const char *fdname, |
| 87 | int64_t bandwidth_limit, |
| 88 | int detach); |
| 89 | |
aliguori | 731b036 | 2009-03-05 23:01:42 +0000 | [diff] [blame] | 90 | void migrate_fd_monitor_suspend(FdMigrationState *s); |
| 91 | |
aliguori | 065e281 | 2008-11-11 16:46:33 +0000 | [diff] [blame] | 92 | void migrate_fd_error(FdMigrationState *s); |
| 93 | |
| 94 | void migrate_fd_cleanup(FdMigrationState *s); |
| 95 | |
| 96 | void migrate_fd_put_notify(void *opaque); |
| 97 | |
| 98 | ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size); |
| 99 | |
| 100 | void migrate_fd_connect(FdMigrationState *s); |
| 101 | |
| 102 | void migrate_fd_put_ready(void *opaque); |
| 103 | |
| 104 | int migrate_fd_get_status(MigrationState *mig_state); |
| 105 | |
| 106 | void migrate_fd_cancel(MigrationState *mig_state); |
| 107 | |
| 108 | void migrate_fd_release(MigrationState *mig_state); |
| 109 | |
| 110 | void migrate_fd_wait_for_unfreeze(void *opaque); |
| 111 | |
| 112 | int migrate_fd_close(void *opaque); |
| 113 | |
| 114 | static inline FdMigrationState *migrate_to_fms(MigrationState *mig_state) |
| 115 | { |
| 116 | return container_of(mig_state, FdMigrationState, mig_state); |
| 117 | } |
| 118 | |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 119 | #endif |