qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/2] Print asynchronous notifications on request


From: Amit Shah
Subject: [Qemu-devel] [PATCH 1/2] Print asynchronous notifications on request
Date: Tue, 20 Jan 2009 16:11:05 +0530

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.

A sample invocation will look like this:

(qemu)
    <vnc connection closed>
(qemu) notify vnc on
    <vnc connection closed>
(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 <address@hidden>
---
 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, },
 };
 
-- 
1.6.0.6





reply via email to

[Prev in Thread] Current Thread [Next in Thread]