48
48
fprintf(stderr, "unknown migration protocol: %s\n", uri);
51
void do_migrate(int detach, const char *uri)
51
void do_migrate(Monitor *mon, int detach, const char *uri)
53
53
MigrationState *s = NULL;
60
60
s = exec_start_outgoing_migration(p, max_throttle, detach);
63
term_printf("unknown migration protocol: %s\n", uri);
63
monitor_printf(mon, "unknown migration protocol: %s\n", uri);
66
term_printf("migration failed\n");
66
monitor_printf(mon, "migration failed\n");
68
68
if (current_migration)
69
69
current_migration->release(current_migration);
100
101
max_throttle = (uint32_t)d;
102
s = migrate_to_fms(current_migration);
103
void do_info_migrate(void)
105
MigrationState *s = current_migration;
105
qemu_file_set_rate_limit(s->file, max_throttle);
110
/* amount of nanoseconds we are willing to wait for migration to be down.
111
* the choice of nanoseconds is because it is the maximum resolution that
112
* get_clock() can achieve. It is an internal measure. All user-visible
113
* units must be in seconds */
114
static uint64_t max_downtime = 30000000;
116
uint64_t migrate_max_downtime(void)
121
void do_migrate_set_downtime(Monitor *mon, const char *value)
126
d = strtod(value, &ptr);
127
if (!strcmp(ptr,"ms")) {
129
} else if (!strcmp(ptr,"us")) {
131
} else if (!strcmp(ptr,"ns")) {
133
/* all else considered to be seconds */
137
max_downtime = (uint64_t)d;
140
void do_info_migrate(Monitor *mon)
142
MigrationState *s = current_migration;
108
term_printf("Migration status: ");
145
monitor_printf(mon, "Migration status: ");
109
146
switch (s->get_status(s)) {
110
147
case MIG_STATE_ACTIVE:
111
term_printf("active\n");
148
monitor_printf(mon, "active\n");
149
monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n", ram_bytes_transferred() >> 10);
150
monitor_printf(mon, "remaining ram: %" PRIu64 " kbytes\n", ram_bytes_remaining() >> 10);
151
monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n", ram_bytes_total() >> 10);
113
153
case MIG_STATE_COMPLETED:
114
term_printf("completed\n");
154
monitor_printf(mon, "completed\n");
116
156
case MIG_STATE_ERROR:
117
term_printf("failed\n");
157
monitor_printf(mon, "failed\n");
119
159
case MIG_STATE_CANCELLED:
120
term_printf("cancelled\n");
160
monitor_printf(mon, "cancelled\n");
126
166
/* shared migration helpers */
168
void migrate_fd_monitor_suspend(FdMigrationState *s)
170
s->mon_resume = cur_mon;
171
if (monitor_suspend(cur_mon) == 0)
172
dprintf("suspending monitor\n");
174
monitor_printf(cur_mon, "terminal does not allow synchronous "
175
"migration, continuing detached\n");
128
178
void migrate_fd_error(FdMigrationState *s)
130
180
dprintf("setting error state\n");
213
261
dprintf("iterate\n");
214
262
if (qemu_savevm_state_iterate(s->file) == 1) {
264
int old_vm_running = vm_running;
216
266
dprintf("done iterating\n");
219
270
bdrv_flush_all();
220
271
if ((qemu_savevm_state_complete(s->file)) < 0) {
272
if (old_vm_running) {
222
275
state = MIG_STATE_ERROR;
224
277
state = MIG_STATE_COMPLETED;
283
336
int migrate_fd_close(void *opaque)
285
338
FdMigrationState *s = opaque;
340
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
286
341
return s->close(s);