Commit 731b0364 authored by aliguori's avatar aliguori

monitor: Decouple terminals (Jan Kiszka)

Currently all registered (and activate) monitor terminals work in
broadcast mode: Everyone sees what someone else types on some other
terminal and what the monitor reports back. This model is broken when
you have a management monitor terminal that is automatically operated
and some other terminal used for independent guest inspection. Such
additional terminals can be multiplexed device channels or a gdb
frontend connected to QEMU's stub.

Therefore, this patch decouples the buffers and states of all monitor
terminals, allowing the user to operate them independently. It finally
starts to use the 'mon' parameter that was introduced earlier with the
API rework. It also defines the default monitor: the first instantance
that has the MONITOR_IS_DEFAULT flag set, and that is the monitor
created via the "-monitor" command line switch (or "vc" if none is
given).

As the patch requires to rework the monitor suspension interface, it
also takes the freedom to make it "truely" suspending (so far suspending
meant suppressing the prompt, but inputs were still processed).
Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6715 c046a42c-6fe2-441c-8c8c-71466251a162
parent 4c36ba32
......@@ -18,7 +18,6 @@
#include "migration.h"
#include "qemu-char.h"
#include "sysemu.h"
#include "monitor.h"
#include "buffered_file.h"
#include "block.h"
......@@ -55,7 +54,7 @@ static int exec_close(FdMigrationState *s)
MigrationState *exec_start_outgoing_migration(const char *command,
int64_t bandwidth_limit,
int async)
int detach)
{
FdMigrationState *s;
FILE *f;
......@@ -89,14 +88,11 @@ MigrationState *exec_start_outgoing_migration(const char *command,
s->mig_state.release = migrate_fd_release;
s->state = MIG_STATE_ACTIVE;
s->detach = !async;
s->mon_resume = NULL;
s->bandwidth_limit = bandwidth_limit;
if (s->detach == 1) {
dprintf("detaching from monitor\n");
monitor_suspend(cur_mon);
s->detach = 2;
}
if (!detach)
migrate_fd_monitor_suspend(s);
migrate_fd_connect(s);
return &s->mig_state;
......
......@@ -16,7 +16,6 @@
#include "migration.h"
#include "qemu-char.h"
#include "sysemu.h"
#include "monitor.h"
#include "buffered_file.h"
#include "block.h"
......@@ -79,7 +78,7 @@ static void tcp_wait_for_connect(void *opaque)
MigrationState *tcp_start_outgoing_migration(const char *host_port,
int64_t bandwidth_limit,
int async)
int detach)
{
struct sockaddr_in addr;
FdMigrationState *s;
......@@ -98,7 +97,7 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,
s->mig_state.release = migrate_fd_release;
s->state = MIG_STATE_ACTIVE;
s->detach = !async;
s->mon_resume = NULL;
s->bandwidth_limit = bandwidth_limit;
s->fd = socket(PF_INET, SOCK_STREAM, 0);
if (s->fd == -1) {
......@@ -108,11 +107,8 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,
socket_set_nonblock(s->fd);
if (s->detach == 1) {
dprintf("detaching from monitor\n");
monitor_suspend(cur_mon);
s->detach = 2;
}
if (!detach)
migrate_fd_monitor_suspend(s);
do {
ret = connect(s->fd, (struct sockaddr *)&addr, sizeof(addr));
......
......@@ -125,6 +125,13 @@ void do_info_migrate(Monitor *mon)
/* shared migration helpers */
void migrate_fd_monitor_suspend(FdMigrationState *s)
{
s->mon_resume = cur_mon;
monitor_suspend(cur_mon);
dprintf("suspending monitor\n");
}
void migrate_fd_error(FdMigrationState *s)
{
dprintf("setting error state\n");
......@@ -145,10 +152,8 @@ void migrate_fd_cleanup(FdMigrationState *s)
close(s->fd);
/* Don't resume monitor until we've flushed all of the buffers */
if (s->detach == 2) {
monitor_resume(cur_mon);
s->detach = 0;
}
if (s->mon_resume)
monitor_resume(s->mon_resume);
s->fd = -1;
}
......
......@@ -39,7 +39,7 @@ struct FdMigrationState
int64_t bandwidth_limit;
QEMUFile *file;
int fd;
int detach;
Monitor *mon_resume;
int state;
int (*get_error)(struct FdMigrationState*);
int (*close)(struct FdMigrationState*);
......@@ -69,6 +69,8 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,
int64_t bandwidth_limit,
int detach);
void migrate_fd_monitor_suspend(FdMigrationState *s);
void migrate_fd_error(FdMigrationState *s);
void migrate_fd_cleanup(FdMigrationState *s);
......
This diff is collapsed.
......@@ -7,7 +7,10 @@
extern Monitor *cur_mon;
void monitor_init(CharDriverState *chr);
/* flags for monitor_init */
#define MONITOR_IS_DEFAULT 0x01
void monitor_init(CharDriverState *chr, int flags);
void monitor_suspend(Monitor *mon);
void monitor_resume(Monitor *mon);
......
......@@ -2123,7 +2123,7 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i
chr = qemu_chr_open(label, p, NULL);
if (chr) {
chr = qemu_chr_open_mux(chr);
monitor_init(chr);
monitor_init(chr, 0);
} else {
printf("Unable to open driver: %s\n", p);
}
......
......@@ -5684,7 +5684,7 @@ int main(int argc, char **argv, char **envp)
qemu_chr_initial_reset();
if (monitor_device && monitor_hd)
monitor_init(monitor_hd);
monitor_init(monitor_hd, MONITOR_IS_DEFAULT);
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
const char *devname = serial_devices[i];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment