diff options
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 29 |
1 files changed, 27 insertions, 2 deletions
@@ -15,11 +15,18 @@ /* ----------------------------------------------------------------- */ +static void show_error(struct qemu_window *win, char *cmd, char *reply) +{ + /* FIXME: show error dialog */ + fprintf(stderr, "ERROR: %s: %s\n", cmd, reply); +} + static int monitor_parse(struct qemu_window *win, char *buf, int len) { char *reply, *prompt, *cmd; int off; + /* handle vnc password change */ if (win->vnc_send_password && win->mrun && !strcmp(win->mrun->cmd, "change vnc password") && strstr(buf, "Password: ")) @@ -35,6 +42,7 @@ static int monitor_parse(struct qemu_window *win, char *buf, int len) return 0; } + /* parse buffer */ prompt = strstr(buf, "(qemu) "); if (NULL == prompt) { return 0; @@ -57,15 +65,18 @@ static int monitor_parse(struct qemu_window *win, char *buf, int len) goto out; } reply += 2; - if (debug) fprintf(stderr, "%s: \"%s\" -> [%s]\n", __FUNCTION__, cmd, reply); + + /* parse reply */ if (0 == strcmp(cmd, "info version")) { snprintf(win->version, sizeof(win->version), "%s", reply); update_status(win); + } else if (0 == strcmp(cmd, "info name")) { snprintf(win->name, sizeof(win->name), "%s", reply); update_status(win); + } else if (0 == strcmp(cmd, "info vnc")) { if (1 == sscanf(reply, "VNC server active on: %127[^\r\n]", win->vnc_display) && @@ -83,8 +94,16 @@ static int monitor_parse(struct qemu_window *win, char *buf, int len) vnc_connect(win); } } + } else if (0 == strcmp(cmd, "change vnc password")) { vnc_connect(win); + + } else if (0 == strcmp(cmd, "info block")) { + devices_parse_info_block(win, reply); + + } else if (0 == strncmp(cmd, "eject ", 6) || + 0 == strncmp(cmd, "change ", 7)) { + show_error(win, cmd, reply); } out: @@ -118,11 +137,16 @@ void monitor_append(struct qemu_window *win, char *cmd) ; mq->next = malloc(sizeof(*mq)); mq = mq->next; + if (debug) + fprintf(stderr, "%s: tail: %s\n", __FUNCTION__, cmd); } else { win->mqueue = malloc(sizeof(*mq)); mq = win->mqueue; - if (!win->mused && win->msize) + if (!win->mrun && !win->mused && win->msize) try_send = 1; + if (debug) + fprintf(stderr, "%s: %s: %s\n", __FUNCTION__, + try_send ? "send" : "head", cmd); } mq->next = NULL; snprintf(mq->cmd, sizeof(mq->cmd), "%s", cmd); @@ -200,5 +224,6 @@ int monitor_connect(struct qemu_window *win, char *dest) monitor_append(win, "info version"); monitor_append(win, "info name"); monitor_append(win, "info vnc"); + monitor_append(win, "info block"); return fd; } |