From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LPNQz-00011M-QE for qemu-devel@nongnu.org; Tue, 20 Jan 2009 15:42:53 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LPNQz-00010o-AA for qemu-devel@nongnu.org; Tue, 20 Jan 2009 15:42:53 -0500 Received: from [199.232.76.173] (port=39640 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LPNQz-00010f-30 for qemu-devel@nongnu.org; Tue, 20 Jan 2009 15:42:53 -0500 Received: from e8.ny.us.ibm.com ([32.97.182.138]:54279) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LPNQy-0004qA-Mp for qemu-devel@nongnu.org; Tue, 20 Jan 2009 15:42:52 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e8.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n0KKahjl000434 for ; Tue, 20 Jan 2009 15:36:43 -0500 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id n0KKgnDq152866 for ; Tue, 20 Jan 2009 15:42:49 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n0KKgnOt001330 for ; Tue, 20 Jan 2009 15:42:49 -0500 Message-ID: <4976373E.6050305@us.ibm.com> Date: Tue, 20 Jan 2009 14:42:38 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1232448066-32209-1-git-send-email-amit.shah@redhat.com> In-Reply-To: <1232448066-32209-1-git-send-email-amit.shah@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 1/2] Print asynchronous notifications on request Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: qemu-devel@nongnu.org Amit Shah wrote: > This patch adds the ability to selectively enable asynchronous notifications > from individual qemu subsystems by a new 'notify' monitor command. > > This is helpful for programs currently parsing monitor output. > I'd rather see two monitors be supported and the second monitor issue an explicit "listen" command to wait for async notifications This mechanism scares me a fair bit since you're printing over the user prompt. > A sample invocation will look like this: > > (qemu) > > (qemu) notify vnc on > > (qemu) # VNC: Closing down connection 127.0.0.1:1 > > Notice that the output is prefixed by '#'. Also, it will appear on the > line that has '(qemu) ' already output on it. > > Signed-off-by: Amit Shah > --- > qemu/console.h | 4 ++++ > qemu/monitor.c | 34 ++++++++++++++++++++++++++++++++++ > 2 files changed, 38 insertions(+), 0 deletions(-) > > diff --git a/qemu/console.h b/qemu/console.h > index 383ea1a..0cf575c 100644 > --- a/qemu/console.h > +++ b/qemu/console.h > @@ -292,6 +292,8 @@ void curses_display_init(DisplayState *ds, int full_screen); > /* x_keymap.c */ > extern uint8_t _translate_keycode(const int key); > > +#define MAX_ASYNC_EVENTS 0 > + > /* FIXME: term_printf et al should probably go elsewhere so everything > does not need to include console.h */ > /* monitor.c */ > @@ -299,6 +301,8 @@ void monitor_init(CharDriverState *hd, int show_banner); > void term_puts(const char *str); > void term_vprintf(const char *fmt, va_list ap); > void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); > +void term_printf_async(const int event, const char *fmt, ...) > + __attribute__ ((__format__ (__printf__, 2, 3))); > void term_print_filename(const char *filename); > void term_flush(void); > void term_print_help(void); > diff --git a/qemu/monitor.c b/qemu/monitor.c > index 7ff9890..ef871d0 100644 > --- a/qemu/monitor.c > +++ b/qemu/monitor.c > @@ -65,6 +65,8 @@ typedef struct term_cmd_t { > const char *help; > } term_cmd_t; > > +int async_printable_events[MAX_ASYNC_EVENTS]; > + > #define MAX_MON 4 > static CharDriverState *monitor_hd[MAX_MON]; > static int hide_banner; > @@ -122,6 +124,24 @@ void term_printf(const char *fmt, ...) > va_end(ap); > } > > +void term_printf_async(const int event, const char *fmt, ...) > +{ > + va_list ap; > + va_start(ap, fmt); > + > + if (event > MAX_ASYNC_EVENTS) > + goto cleanup; > + if (!async_printable_events[event]) > + goto cleanup; > + > + term_printf("# "); > + term_vprintf(fmt, ap); > + > +cleanup: > + va_end(ap); > + return; > +} > + > void term_print_filename(const char *filename) > { > int i; > @@ -210,6 +230,18 @@ static void do_help(const char *name) > help_cmd(name); > } > > +static void do_notify_async_events(char *event_str, char *enable) > +{ > + int event; > + > + return; > + > + if (!strcmp(enable, "on")) > + async_printable_events[event] = 1; > + else > + async_printable_events[event] = 0; > +} > + > static void do_commit(const char *device) > { > int i, all_devices; > @@ -1517,6 +1549,8 @@ static const term_cmd_t term_cmds[] = { > { "balloon", "i", do_balloon, > "target", "request VM to change it's memory allocation (in MB)" }, > { "set_link", "ss", do_set_link, "name [up|down]" }, > + { "notify", "ss", do_notify_async_events, > + "NULL on|off", "enable / disable printing of notifications for the specified event" }, > { NULL, NULL, }, > }; > >