Commit 86e94dea authored by Thiemo Seufer's avatar Thiemo Seufer
Browse files

Reinitialize monitor upon reconnect, by Anthony Liguori.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2300 c046a42c-6fe2-441c-8c8c-71466251a162
parent 8f28f3fb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1086,5 +1086,7 @@ CharDriverState *text_console_init(DisplayState *ds)
    s->t_attrib = s->t_attrib_default;
    text_console_resize(s);

    qemu_chr_reset(chr);

    return chr;
}
+15 −5
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ typedef struct term_cmd_t {
} term_cmd_t;

static CharDriverState *monitor_hd;
static int hide_banner;

static term_cmd_t term_cmds[];
static term_cmd_t info_cmds[];
@@ -2438,15 +2439,24 @@ static void monitor_start_input(void)
    readline_start("(qemu) ", 0, monitor_handle_command1, NULL);
}

void monitor_init(CharDriverState *hd, int show_banner)
static void term_event(void *opaque, int event)
{
    monitor_hd = hd;
    if (show_banner) {
    if (event != CHR_EVENT_RESET)
	return;

    if (!hide_banner)
	    term_printf("QEMU %s monitor - type 'help' for more information\n",
			QEMU_VERSION);
    monitor_start_input();
}

void monitor_init(CharDriverState *hd, int show_banner)
{
    monitor_hd = hd;
    hide_banner = !show_banner;

    qemu_chr_add_read_handler(hd, term_can_read, term_read, NULL);
    monitor_start_input();
    qemu_chr_add_event_handler(hd, term_event);
}

/* XXX: use threads ? */
+28 −0
Original line number Diff line number Diff line
@@ -1165,6 +1165,23 @@ void quit_timers(void)
/***********************************************************/
/* character device */

static void qemu_chr_reset_bh(void *opaque)
{
    CharDriverState *s = opaque;
    if (s->chr_event)
	s->chr_event(s, CHR_EVENT_RESET);
    qemu_bh_delete(s->bh);
    s->bh = NULL;
}

void qemu_chr_reset(CharDriverState *s)
{
    if (s->bh == NULL) {
	s->bh = qemu_bh_new(qemu_chr_reset_bh, s);
	qemu_bh_schedule(s->bh);
    }
}

int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len)
{
    return s->chr_write(s, buf, len);
@@ -1402,6 +1419,9 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
    chr->opaque = s;
    chr->chr_write = fd_chr_write;
    chr->chr_add_read_handler = fd_chr_add_read_handler;

    qemu_chr_reset(chr);

    return chr;
}

@@ -1819,6 +1839,7 @@ static CharDriverState *qemu_chr_open_tty(const char *filename)
    if (!chr)
        return NULL;
    chr->chr_ioctl = tty_serial_ioctl;
    qemu_chr_reset(chr);
    return chr;
}

@@ -1882,6 +1903,9 @@ static CharDriverState *qemu_chr_open_pp(const char *filename)
    chr->chr_write = null_chr_write;
    chr->chr_add_read_handler = null_chr_add_read_handler;
    chr->chr_ioctl = pp_ioctl;

    qemu_chr_reset(chr);

    return chr;
}

@@ -2127,6 +2151,7 @@ static CharDriverState *qemu_chr_open_win(const char *filename)
        free(chr);
        return NULL;
    }
    qemu_chr_reset(chr);
    return chr;
}

@@ -2230,6 +2255,7 @@ static CharDriverState *qemu_chr_open_win_pipe(const char *filename)
        free(chr);
        return NULL;
    }
    qemu_chr_reset(chr);
    return chr;
}

@@ -2250,6 +2276,7 @@ static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out)
    chr->opaque = s;
    chr->chr_write = win_chr_write;
    chr->chr_add_read_handler = win_chr_add_read_handler;
    qemu_chr_reset(chr);
    return chr;
}
    
@@ -2537,6 +2564,7 @@ static void tcp_chr_connect(void *opaque)
    s->connected = 1;
    qemu_set_fd_handler2(s->fd, tcp_chr_read_poll,
                         tcp_chr_read, NULL, chr);
    qemu_chr_reset(chr);
}

#define IACSET(x,a,b,c) x[0] = a; x[1] = b; x[2] = c;
+5 −2
Original line number Diff line number Diff line
@@ -260,11 +260,13 @@ int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
#endif

typedef struct QEMUBH QEMUBH;

/* character device */

#define CHR_EVENT_BREAK 0 /* serial break char */
#define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */

#define CHR_EVENT_RESET 2 /* new connection established */


#define CHR_IOCTL_SERIAL_SET_PARAMS   1
@@ -295,6 +297,7 @@ typedef struct CharDriverState {
    void (*chr_send_event)(struct CharDriverState *chr, int event);
    void (*chr_close)(struct CharDriverState *chr);
    void *opaque;
    QEMUBH *bh;
} CharDriverState;

void qemu_chr_printf(CharDriverState *s, const char *fmt, ...);
@@ -305,6 +308,7 @@ void qemu_chr_add_read_handler(CharDriverState *s,
                               IOReadHandler *fd_read, void *opaque);
void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event);
int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg);
void qemu_chr_reset(CharDriverState *s);

/* consoles */

@@ -513,7 +517,6 @@ void do_delvm(const char *name);
void do_info_snapshots(void);

/* bottom halves */
typedef struct QEMUBH QEMUBH;
typedef void QEMUBHFunc(void *opaque);

QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);