4 * Copyright IBM, Corp. 2008
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #ifndef QEMU_MIGRATION_H
15 #define QEMU_MIGRATION_H
18 #include "qemu-common.h"
21 #define MIG_STATE_ERROR -1
22 #define MIG_STATE_COMPLETED 0
23 #define MIG_STATE_CANCELLED 1
24 #define MIG_STATE_ACTIVE 2
26 typedef struct MigrationState MigrationState
;
30 /* FIXME: add more accessors to print migration info */
31 void (*cancel
)(MigrationState
*s
);
32 int (*get_status
)(MigrationState
*s
);
33 void (*release
)(MigrationState
*s
);
38 typedef struct FdMigrationState FdMigrationState
;
40 struct FdMigrationState
42 MigrationState mig_state
;
43 int64_t bandwidth_limit
;
48 int (*get_error
)(struct FdMigrationState
*);
49 int (*close
)(struct FdMigrationState
*);
50 int (*write
)(struct FdMigrationState
*, const void *, size_t);
54 void process_incoming_migration(QEMUFile
*f
);
56 int qemu_start_incoming_migration(const char *uri
);
58 int do_migrate(Monitor
*mon
, const QDict
*qdict
, QObject
**ret_data
);
60 int do_migrate_cancel(Monitor
*mon
, const QDict
*qdict
, QObject
**ret_data
);
62 int do_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
, QObject
**ret_data
);
64 uint64_t migrate_max_downtime(void);
66 int do_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
,
69 void do_info_migrate_print(Monitor
*mon
, const QObject
*data
);
71 void do_info_migrate(Monitor
*mon
, QObject
**ret_data
);
73 int exec_start_incoming_migration(const char *host_port
);
75 MigrationState
*exec_start_outgoing_migration(Monitor
*mon
,
76 const char *host_port
,
77 int64_t bandwidth_limit
,
82 int tcp_start_incoming_migration(const char *host_port
);
84 MigrationState
*tcp_start_outgoing_migration(Monitor
*mon
,
85 const char *host_port
,
86 int64_t bandwidth_limit
,
91 int unix_start_incoming_migration(const char *path
);
93 MigrationState
*unix_start_outgoing_migration(Monitor
*mon
,
95 int64_t bandwidth_limit
,
100 int fd_start_incoming_migration(const char *path
);
102 MigrationState
*fd_start_outgoing_migration(Monitor
*mon
,
104 int64_t bandwidth_limit
,
109 void migrate_fd_monitor_suspend(FdMigrationState
*s
, Monitor
*mon
);
111 void migrate_fd_error(FdMigrationState
*s
);
113 int migrate_fd_cleanup(FdMigrationState
*s
);
115 void migrate_fd_put_notify(void *opaque
);
117 ssize_t
migrate_fd_put_buffer(void *opaque
, const void *data
, size_t size
);
119 void migrate_fd_connect(FdMigrationState
*s
);
121 void migrate_fd_put_ready(void *opaque
);
123 int migrate_fd_get_status(MigrationState
*mig_state
);
125 void migrate_fd_cancel(MigrationState
*mig_state
);
127 void migrate_fd_release(MigrationState
*mig_state
);
129 void migrate_fd_wait_for_unfreeze(void *opaque
);
131 int migrate_fd_close(void *opaque
);
133 static inline FdMigrationState
*migrate_to_fms(MigrationState
*mig_state
)
135 return container_of(mig_state
, FdMigrationState
, mig_state
);
138 void add_migration_state_change_notifier(Notifier
*notify
);
139 void remove_migration_state_change_notifier(Notifier
*notify
);
140 int get_migration_state(void);