From 838fa1204854eb4f6c7b14974b26b57bd6ce4f6c Mon Sep 17 00:00:00 2001 From: Uri Lublin <uril@redhat.com> Date: Tue, 2 Jun 2009 18:32:59 +0300 Subject: [PATCH 2/5] qemu: add "-notify" command line option to enable async notifications (v2) Use "-notify <event>" similar to "notify event on" monitor command. All "notify" monitor-command events are supported. Exits upon a bad event. Needed for receiving notifications (e.g. upon migration completion on the destination) especially for (incoming) migration from file. bz 501693 Signed-off-by: Uri Lublin <uril@redhat.com> Message-Id: <1243956781-29993-3-git-send-email-uril@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> RH-Upstream-status: not-applicable Obsoletes: <1243182659-8254-2-git-send-email-uril@redhat.com> Acked-by: john cooper <john.cooper@redhat.com> Acked-by: "Michael S. Tsirkin" <mst@redhat.com> Acked-by: Dor Laor <dlaor@redhat.com> Bugzilla: 504237 --- qemu/monitor.c | 26 +++++++++++++++++++++++--- qemu/vl.c | 12 ++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/qemu/monitor.c b/qemu/monitor.c index c627656..66246fd 100644 --- a/qemu/monitor.c +++ b/qemu/monitor.c @@ -243,7 +243,10 @@ static void do_help(const char *name) help_cmd(name); } -static void do_notify_async_events(char *event_str, char *enable) +/* + * return 0 upon success, non-0 upon failure + */ +static int set_notify_async_events(const char *event_str, const char *enable) { int event; @@ -265,15 +268,32 @@ static void do_notify_async_events(char *event_str, char *enable) event = VDI_ASYNC_EVENT; else { term_printf("notify: invalid event %s\n", event_str); - return; + return 1; } if (!strcmp(enable, "on")) async_printable_events[event] = 1; else if (!strcmp(enable, "off")) async_printable_events[event] = 0; - else + else { term_printf("notify: invalid argument\n"); + return 2; + } + return 0; +} + +static void do_notify_async_events(char *event_str, char *enable) +{ + set_notify_async_events(event_str, enable); +} + +/* + * Enables async notification for event_str event. + * Returns 0 on success, non-0 otherwise. + */ +int enable_async_notification(const char *event_str) +{ + return set_notify_async_events(event_str, "on"); } static void do_commit(const char *device) diff --git a/qemu/vl.c b/qemu/vl.c index 89f260e..a0a4075 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -4176,6 +4176,7 @@ static void help(int exitcode) #endif "-name string set the name of the guest\n" "-uuid %%08x-%%04x-%%04x-%%04x-%%012x specify machine UUID\n" + "-notify event enable async-notifications for event\n" #ifdef CONFIG_QXL "-qxl <num>[,ram=megs]\n" " use 'num' qxl display devices, each with RAM size of 'megs' MB\n" @@ -4458,6 +4459,7 @@ enum { #ifdef MAP_POPULATE QEMU_OPTION_mem_prealloc, #endif + QEMU_OPTION_notify, }; typedef struct QEMUOption { @@ -4607,6 +4609,7 @@ static const QEMUOption qemu_options[] = { #ifdef MAP_POPULATE { "mem-prealloc", 0, QEMU_OPTION_mem_prealloc }, #endif + { "notify", 1, QEMU_OPTION_notify}, { NULL }, }; @@ -5847,6 +5850,15 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_incoming: incoming = optarg; break; + case QEMU_OPTION_notify: { + extern int enable_async_notification(const char *); + if (enable_async_notification(optarg)) { + fprintf(stderr, "qemu: failed to enable async event" + " notification for %s\n", optarg); + exit(1); + } + break; + } } } } -- 1.6.3.rc4.29.g8146