[6715] monitor: Decouple terminals (Jan Kiszka)
Revision: 6715
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6715 Author: aliguori Date: 2009-03-05 23:01:42 +0000 (Thu, 05 Mar 2009)
Log Message:
-----------
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).
Modified Paths:
--------------
trunk/migration-exec.c
trunk/migration-tcp.c
trunk/migration.c
trunk/migration.h
trunk/monitor.c
trunk/monitor.h
trunk/qemu-char.c
trunk/vl.c
Modified: trunk/migration-exec.c
===================================================================
migration-exec.c +4 -8
@@ -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 @@MigrationState *exec_start_outgoing_migration (const char *command,int64_t bandwidth_limit, -int async) +int detach) {FdMigrationState *s;FILE *f;
@@ -89,14 +88,11 @@ 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;
Modified: trunk/migration-tcp.c
===================================================================
migration-tcp.c +4 -8
@@ -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 @@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 @@ 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 @@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));
Modified: trunk/migration.c
===================================================================
migration.c +9 -4
@@ -125,6 +125,13 @@/* 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 @@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 ; }
Modified: trunk/migration.h
===================================================================
migration.h +3 -1
@@ -39,7 +39,7 @@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 @@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);
Modified: trunk/monitor.c
===================================================================
monitor.c +75 -71
315 lines not on this page · raw message
Modified: trunk/monitor.h
===================================================================
monitor.h +4 -1
@@ -7,8 +7,11 @@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);
Modified: trunk/qemu-char.c
===================================================================
qemu-char.c +1 -1
@@ -2123,7 +2123,7 @@ 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); }
Modified: trunk/vl.c
===================================================================
vl.c +1 -1
@@ -5684,7 +5684,7 @@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];