]> git.proxmox.com Git - qemu.git/blame - migration.c
target-alpha: fix decoding of CVTST /S
[qemu.git] / migration.c
CommitLineData
5bb7910a
AL
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#include "qemu-common.h"
15#include "migration.h"
16#include "console.h"
17
18/* Migration speed throttling */
19static uint32_t max_throttle = (32 << 20);
20
21static MigrationState *current_migration;
22
23void qemu_start_incoming_migration(const char *uri)
24{
34c9dd8e
AL
25 const char *p;
26
27 if (strstart(uri, "tcp:", &p))
28 tcp_start_incoming_migration(p);
29 else
30 fprintf(stderr, "unknown migration protocol: %s\n", uri);
5bb7910a
AL
31}
32
33void do_migrate(int detach, const char *uri)
34{
34c9dd8e
AL
35 MigrationState *s = NULL;
36 const char *p;
37
38 if (strstart(uri, "tcp:", &p))
ff8d81d8 39 s = tcp_start_outgoing_migration(p, max_throttle, detach);
34c9dd8e
AL
40 else
41 term_printf("unknown migration protocol: %s\n", uri);
42
43 if (s == NULL)
ff8d81d8 44 term_printf("migration failed\n");
34c9dd8e 45 else {
ff8d81d8
AL
46 if (current_migration)
47 current_migration->release(current_migration);
34c9dd8e 48
ff8d81d8 49 current_migration = s;
34c9dd8e 50 }
5bb7910a
AL
51}
52
53void do_migrate_cancel(void)
54{
55 MigrationState *s = current_migration;
56
57 if (s)
ff8d81d8 58 s->cancel(s);
5bb7910a
AL
59}
60
61void do_migrate_set_speed(const char *value)
62{
63 double d;
64 char *ptr;
65
66 d = strtod(value, &ptr);
67 switch (*ptr) {
68 case 'G': case 'g':
ff8d81d8 69 d *= 1024;
5bb7910a 70 case 'M': case 'm':
ff8d81d8 71 d *= 1024;
5bb7910a 72 case 'K': case 'k':
ff8d81d8 73 d *= 1024;
5bb7910a 74 default:
ff8d81d8 75 break;
5bb7910a
AL
76 }
77
78 max_throttle = (uint32_t)d;
79}
80
81void do_info_migrate(void)
82{
83 MigrationState *s = current_migration;
84
85 if (s) {
ff8d81d8
AL
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;
100 }
5bb7910a
AL
101 }
102}
103