From: Amit Shah <amit.shah@redhat.com>
To: aliguori@us.ibm.com
Cc: Amit Shah <amit.shah@redhat.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/2] Print asynchronous notifications on request
Date: Tue, 20 Jan 2009 16:11:05 +0530 [thread overview]
Message-ID: <1232448066-32209-1-git-send-email-amit.shah@redhat.com> (raw)
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 <amit.shah@redhat.com>
---
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
next reply other threads:[~2009-01-20 10:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-20 10:41 Amit Shah [this message]
2009-01-20 10:41 ` [Qemu-devel] [PATCH 2/2] vnc: Use async notifications for closing down messages Amit Shah
2009-01-20 11:35 ` [Qemu-devel] Re: [PATCH 1/2] Print asynchronous notifications on request Jan Kiszka
2009-01-20 12:56 ` Avi Kivity
2009-01-20 13:32 ` Amit Shah
2009-01-20 15:27 ` Jan Kiszka
2009-01-20 20:42 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1232448066-32209-1-git-send-email-amit.shah@redhat.com \
--to=amit.shah@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).