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 | #include "qemu-common.h" |
| 15 | #include "migration.h" |
| 16 | #include "console.h" |
| 17 | |
| 18 | /* Migration speed throttling */ |
| 19 | static uint32_t max_throttle = (32 << 20); |
| 20 | |
| 21 | static MigrationState *current_migration; |
| 22 | |
| 23 | void qemu_start_incoming_migration(const char *uri) |
| 24 | { |
| 25 | fprintf(stderr, "unknown migration protocol: %s\n", uri); |
| 26 | } |
| 27 | |
| 28 | void do_migrate(int detach, const char *uri) |
| 29 | { |
| 30 | term_printf("unknown migration protocol: %s\n", uri); |
| 31 | } |
| 32 | |
| 33 | void do_migrate_cancel(void) |
| 34 | { |
| 35 | MigrationState *s = current_migration; |
| 36 | |
| 37 | if (s) |
| 38 | s->cancel(s); |
| 39 | } |
| 40 | |
| 41 | void do_migrate_set_speed(const char *value) |
| 42 | { |
| 43 | double d; |
| 44 | char *ptr; |
| 45 | |
| 46 | d = strtod(value, &ptr); |
| 47 | switch (*ptr) { |
| 48 | case 'G': case 'g': |
| 49 | d *= 1024; |
| 50 | case 'M': case 'm': |
| 51 | d *= 1024; |
| 52 | case 'K': case 'k': |
| 53 | d *= 1024; |
| 54 | default: |
| 55 | break; |
| 56 | } |
| 57 | |
| 58 | max_throttle = (uint32_t)d; |
| 59 | } |
| 60 | |
| 61 | void do_info_migrate(void) |
| 62 | { |
| 63 | MigrationState *s = current_migration; |
| 64 | |
| 65 | if (s) { |
| 66 | term_printf("Migration status: "); |
| 67 | switch (s->get_status(s)) { |
| 68 | case MIG_STATE_ACTIVE: |
| 69 | term_printf("active\n"); |
| 70 | break; |
| 71 | case MIG_STATE_COMPLETED: |
| 72 | term_printf("completed\n"); |
| 73 | break; |
| 74 | case MIG_STATE_ERROR: |
| 75 | term_printf("failed\n"); |
| 76 | break; |
| 77 | case MIG_STATE_CANCELLED: |
| 78 | term_printf("cancelled\n"); |
| 79 | break; |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |