Use the host exit syscall for exiting (Lauro Ramos Venancio).
[qemu/mini2440/sniper_sniper_test.git] / migration.c
blob9e6c43731ee6f6f2524c67eff2af6b7d7ea0e82c
1 /*
2 * QEMU live migration
4 * Copyright IBM, Corp. 2008
6 * Authors:
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 #include "qemu-common.h"
15 #include "migration.h"
16 #include "console.h"
18 /* Migration speed throttling */
19 static uint32_t max_throttle = (32 << 20);
21 static MigrationState *current_migration;
23 void qemu_start_incoming_migration(const char *uri)
25 const char *p;
27 if (strstart(uri, "tcp:", &p))
28 tcp_start_incoming_migration(p);
29 else
30 fprintf(stderr, "unknown migration protocol: %s\n", uri);
33 void do_migrate(int detach, const char *uri)
35 MigrationState *s = NULL;
36 const char *p;
38 if (strstart(uri, "tcp:", &p))
39 s = tcp_start_outgoing_migration(p, max_throttle, detach);
40 else
41 term_printf("unknown migration protocol: %s\n", uri);
43 if (s == NULL)
44 term_printf("migration failed\n");
45 else {
46 if (current_migration)
47 current_migration->release(current_migration);
49 current_migration = s;
53 void do_migrate_cancel(void)
55 MigrationState *s = current_migration;
57 if (s)
58 s->cancel(s);
61 void do_migrate_set_speed(const char *value)
63 double d;
64 char *ptr;
66 d = strtod(value, &ptr);
67 switch (*ptr) {
68 case 'G': case 'g':
69 d *= 1024;
70 case 'M': case 'm':
71 d *= 1024;
72 case 'K': case 'k':
73 d *= 1024;
74 default:
75 break;
78 max_throttle = (uint32_t)d;
81 void do_info_migrate(void)
83 MigrationState *s = current_migration;
85 if (s) {
86 term_printf("Migration status: ");
87 switch (s->get_status(s)) {
88 case MIG_STATE_ACTIVE:
89 term_printf("active\n");
90 break;
91 case MIG_STATE_COMPLETED:
92 term_printf("completed\n");
93 break;
94 case MIG_STATE_ERROR:
95 term_printf("failed\n");
96 break;
97 case MIG_STATE_CANCELLED:
98 term_printf("cancelled\n");
99 break;