From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MIxeD-0008I5-O0 for qemu-devel@nongnu.org; Tue, 23 Jun 2009 00:30:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MIxe9-0008Fz-9I for qemu-devel@nongnu.org; Tue, 23 Jun 2009 00:30:17 -0400 Received: from [199.232.76.173] (port=35695 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MIxe8-0008Fp-PH for qemu-devel@nongnu.org; Tue, 23 Jun 2009 00:30:12 -0400 Received: from mx2.redhat.com ([66.187.237.31]:32844) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MIxe8-0003MI-A2 for qemu-devel@nongnu.org; Tue, 23 Jun 2009 00:30:12 -0400 Date: Tue, 23 Jun 2009 01:30:05 -0300 From: Luiz Capitulino Message-ID: <20090623013005.39e27923@doriath> In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 11/11] QMP: Command-line flag to enable control mode List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, ehabkost@redhat.com, jan.kiszka@siemens.com, dlaor@redhat.com, avi@redhat.com This change adds a flag called 'control' to the already existing '-monitor' command-line option. This flag can be used to enable control mode. Its syntax is: qemu [...] -monitor control, Where is a chardev (excluding 'vc', for obvious reasons). For example: $ qemu [...] -monitor control,tcp:localhost:4444,server Will run QEMU in control mode, waiting for a client TCP connection on localhost port 4444. Signed-off-by: Luiz Capitulino --- monitor.c | 19 +++++++++++++++++++ monitor.h | 1 + vl.c | 5 +++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index 7ebf0ea..c1baeac 100644 --- a/monitor.c +++ b/monitor.c @@ -3192,6 +3192,25 @@ static void monitor_event(void *opaque, int event) * End: */ +const char *monitor_cmdline_parse(const char *cmdline, int *flags) +{ + const char *dev; + + *flags = MONITOR_IS_DEFAULT; + if (strstart(cmdline, "control,", &dev)) { + if (strstart(dev, "vc", NULL)) { + fprintf(stderr, "qemu: control mode is for low-level interaction "); + fprintf(stderr, "cannot be used with device 'vc'\n"); + exit(1); + } + *flags |= MONITOR_USE_CONTROL; + return dev; + } + + *flags |= MONITOR_USE_READLINE; + return cmdline; +} + void monitor_init(CharDriverState *chr, int flags) { static int is_first_init = 1; diff --git a/monitor.h b/monitor.h index 579b80b..9ddd264 100644 --- a/monitor.h +++ b/monitor.h @@ -20,6 +20,7 @@ typedef enum MonitorEvent { EVENT_MAX, } MonitorEvent; +const char *monitor_cmdline_parse(const char *cmdline, int *flags); void monitor_init(CharDriverState *chr, int flags); int monitor_suspend(Monitor *mon); diff --git a/vl.c b/vl.c index 7dc5954..bd83dac 100644 --- a/vl.c +++ b/vl.c @@ -4977,6 +4977,7 @@ int main(int argc, char **argv, char **envp) const char *r, *optarg; CharDriverState *monitor_hd = NULL; const char *monitor_device; + int monitor_flags = MONITOR_IS_DEFAULT | MONITOR_USE_READLINE; const char *serial_devices[MAX_SERIAL_PORTS]; int serial_device_index; const char *parallel_devices[MAX_PARALLEL_PORTS]; @@ -5462,7 +5463,7 @@ int main(int argc, char **argv, char **envp) break; } case QEMU_OPTION_monitor: - monitor_device = optarg; + monitor_device = monitor_cmdline_parse(optarg, &monitor_flags); break; case QEMU_OPTION_serial: if (serial_device_index >= MAX_SERIAL_PORTS) { @@ -6150,7 +6151,7 @@ int main(int argc, char **argv, char **envp) qemu_chr_initial_reset(); if (monitor_device && monitor_hd) - monitor_init(monitor_hd, MONITOR_USE_READLINE | MONITOR_IS_DEFAULT); + monitor_init(monitor_hd, monitor_flags); for(i = 0; i < MAX_SERIAL_PORTS; i++) { const char *devname = serial_devices[i]; -- 1.6.3.GIT