diff options
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 63 |
1 files changed, 49 insertions, 14 deletions
@@ -24,7 +24,7 @@ #include "vl.h" #include "disas.h" #include <dirent.h> - +#include "migration.h" //#define DEBUG //#define DEBUG_COMPLETION @@ -41,6 +41,7 @@ * 'i' 32 bit integer * 'l' target long (32 or 64 bit) * '/' optional gdb-like print format (like "/10x") + * 'A' pass the rest of cmdline as one argument (for subcommands). * * '?' optional type (for 'F', 's' and 'i') * @@ -58,11 +59,15 @@ static CharDriverState *monitor_hd; static term_cmd_t term_cmds[]; static term_cmd_t info_cmds[]; +static term_cmd_t migration_cmds[]; static char term_outbuf[1024]; static int term_outbuf_index; static void monitor_start_input(void); +static void monitor_handle_command(const term_cmd_t *cmds, + const char *cmdline); + CPUState *mon_cpu = NULL; @@ -425,13 +430,13 @@ static void do_log(const char *items) static void do_savevm(const char *filename) { - if (qemu_savevm(filename) < 0) + if (qemu_savevm(filename, &qemu_savevm_method_file) < 0) term_printf("I/O error when saving VM to '%s'\n", filename); } static void do_loadvm(const char *filename) { - if (qemu_loadvm(filename) < 0) + if (qemu_loadvm(filename, &qemu_savevm_method_file) < 0) term_printf("I/O error when loading VM from '%s'\n", filename); } @@ -1152,6 +1157,16 @@ static void do_stop_capture (int n) } } +static void do_migration(const char *subcmdline) +{ + monitor_handle_command(migration_cmds, subcmdline); +} + +static void do_migration_help(char *name) +{ + help_cmd1(migration_cmds, "migration ", name); +} + #ifdef HAS_AUDIO int wav_start_capture (CaptureState *s, const char *path, int freq, int bits, int nchannels); @@ -1246,6 +1261,8 @@ static term_cmd_t term_cmds[] = { "capture index", "stop capture" }, { "create_snapshot", "ss?s?s?", do_snapshot, "hda [hdb] [hdc] [hdd]", "create snapshot of one or more images (VMDK format)" }, + { "migration", "A", do_migration, "subcommand|help", + "start/stop/manage migrations"}, { NULL, NULL, }, }; @@ -1289,6 +1306,25 @@ static term_cmd_t info_cmds[] = { { NULL, NULL, }, }; + +static term_cmd_t migration_cmds[] = { + { "listen", "s?s?", do_migration_listen, + "[local_host:port [remote_host:port]]", "listen to a port" }, + { "connect", "s?s?", do_migration_connect, + "[local_host:port [remote_host:port]]", "connect to a port"}, + { "getfd", "i", do_migration_getfd, "fd (socket)", + "get established connection"}, + { "start", "s", do_migration_start, "online|offline" , + "start the migration proccess"}, + { "cancel", "", do_migration_cancel, "", + "cancel an ongoing migration procces"}, + { "status", "", do_migration_status, "", "get migration status/progress"}, + { "set", "A", do_migration_set, "params", "set migration parameters"}, + { "show", "", do_migration_show, "", "show migration parameters"}, + { "help", "s?", do_migration_help, "[subcommand]", "show help message"}, + { NULL, NULL, }, +}; + /*******************************************************************/ static const char *pch; @@ -1905,7 +1941,7 @@ static int default_fmt_size = 4; #define MAX_ARGS 16 -static void monitor_handle_command(const char *cmdline) +static void monitor_handle_command(const term_cmd_t *cmds, const char *cmdline) { const char *p, *pstart, *typestr; char *q; @@ -1937,7 +1973,7 @@ static void monitor_handle_command(const char *cmdline) cmdname[len] = '\0'; /* find the command */ - for(cmd = term_cmds; cmd->name != NULL; cmd++) { + for(cmd = cmds; cmd->name != NULL; cmd++) { if (compare_cmd(cmdname, cmd->name)) goto found; } @@ -1952,6 +1988,8 @@ static void monitor_handle_command(const char *cmdline) typestr = cmd->args_type; nb_args = 0; for(;;) { + while (isspace(*p)) /* eat whitespaces */ + p++; c = *typestr; if (c == '\0') break; @@ -1964,8 +2002,6 @@ static void monitor_handle_command(const char *cmdline) int ret; char *str; - while (isspace(*p)) - p++; if (*typestr == '?') { typestr++; if (*p == '\0') { @@ -2005,8 +2041,6 @@ static void monitor_handle_command(const char *cmdline) { int count, format, size; - while (isspace(*p)) - p++; if (*p == '/') { /* format found */ p++; @@ -2085,8 +2119,6 @@ static void monitor_handle_command(const char *cmdline) case 'l': { target_long val; - while (isspace(*p)) - p++; if (*typestr == '?' || *typestr == '.') { if (*typestr == '?') { if (*p == '\0') @@ -2133,6 +2165,11 @@ static void monitor_handle_command(const char *cmdline) } } break; + case 'A': + args[nb_args++] = p; + while (*p) /* goto end of cmdline */ + p++; + break; case '-': { int has_option; @@ -2141,8 +2178,6 @@ static void monitor_handle_command(const char *cmdline) c = *typestr++; if (c == '\0') goto bad_type; - while (isspace(*p)) - p++; has_option = 0; if (*p == '-') { p++; @@ -2419,7 +2454,7 @@ static void monitor_start_input(void); static void monitor_handle_command1(void *opaque, const char *cmdline) { - monitor_handle_command(cmdline); + monitor_handle_command(term_cmds, cmdline); monitor_start_input(); } |