Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 35

kvm-83-270.el5_11.src.rpm

From bef1532047dcc2b71dc59e34a069364320a08dbf Mon Sep 17 00:00:00 2001
From: Amit Shah <amit.shah@redhat.com>
Date: Thu, 1 Jan 2009 10:00:52 +0200
Subject: [PATCH 30/54] qemu: Use async notification for guest shutdown messages

If "notify shutdown on" is issued on the monitor, guest shutdown events will be
shown on the monitor, prefixed with the '#' character.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
RH-Upstream-status: pending
---
 qemu/console.h |    3 ++-
 qemu/monitor.c |    4 +++-
 qemu/vl.c      |    2 ++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/qemu/console.h b/qemu/console.h
index ff04790..c969c6a 100644
--- a/qemu/console.h
+++ b/qemu/console.h
@@ -190,7 +190,8 @@ extern uint8_t _translate_keycode(const int key);
 
 #define VNC_ASYNC_EVENT   1
 #define RTC_ASYNC_EVENT   2
-#define MAX_ASYNC_EVENTS  RTC_ASYNC_EVENT
+#define SHUTDOWN_ASYNC_EVENT 3
+#define MAX_ASYNC_EVENTS  SHUTDOWN_ASYNC_EVENT
 
 /* FIXME: term_printf et al should probably go elsewhere so everything
    does not need to include console.h  */
diff --git a/qemu/monitor.c b/qemu/monitor.c
index 0046980..d2078f8 100644
--- a/qemu/monitor.c
+++ b/qemu/monitor.c
@@ -251,6 +251,8 @@ static void do_notify_async_events(char *event_str, char *enable)
         event = VNC_ASYNC_EVENT;
     else if (!strcmp(event_str, "rtc"))
         event = RTC_ASYNC_EVENT;
+    else if (!strcmp(event_str, "shutdown"))
+        event = SHUTDOWN_ASYNC_EVENT;
     else
         return;
 
@@ -1609,7 +1611,7 @@ static term_cmd_t term_cmds[] = {
     { "set_qxl_log_level", "i", qxl_do_set_log_level, "", "set qxl log level" },
 #endif
     { "notify", "ss", do_notify_async_events,
-      "vnc|rtc on|off", "enable / disable printing of notifications for the specified event" },
+      "vnc|rtc|shutdown on|off", "enable / disable printing of notifications for the specified event" },
     { NULL, NULL, },
 };
 
diff --git a/qemu/vl.c b/qemu/vl.c
index 4ed4375..78a7fda 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -3653,6 +3653,7 @@ void qemu_system_reset_request(void)
 
 void qemu_system_shutdown_request(void)
 {
+    term_printf_async(SHUTDOWN_ASYNC_EVENT, "GUEST: Got shutdown request\n");
     shutdown_requested = 1;
     if (cpu_single_env)
         cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
@@ -3660,6 +3661,7 @@ void qemu_system_shutdown_request(void)
 
 void qemu_system_powerdown_request(void)
 {
+    term_printf_async(SHUTDOWN_ASYNC_EVENT, "GUEST: Got powerdown request\n");
     powerdown_requested = 1;
     if (cpu_single_env)
         cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
-- 
1.6.1