thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
958e1b
From 2462c7df4513e298596559627c61108e13809470 Mon Sep 17 00:00:00 2001
958e1b
From: Gerd Hoffmann <kraxel@redhat.com>
958e1b
Date: Fri, 5 Sep 2014 12:30:38 +0200
958e1b
Subject: [PATCH 04/12] qemu: Adjust qemu wakeup
958e1b
958e1b
Message-id: <1409920238-9070-5-git-send-email-kraxel@redhat.com>
958e1b
Patchwork-id: 60872
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH 4/4] qemu: Adjust qemu wakeup
958e1b
Bugzilla: 1064156
958e1b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
958e1b
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
958e1b
958e1b
From: "Liu, Jinsong" <jinsong.liu@intel.com>
958e1b
958e1b
Currently Xen hvm s3 has a bug coming from the difference between
958e1b
qemu-traditioanl and qemu-xen. For qemu-traditional, the way to
958e1b
resume from hvm s3 is via 'xl trigger' command. However, for
958e1b
qemu-xen, the way to resume from hvm s3 inherited from standard
958e1b
qemu, i.e. via QMP, and it doesn't work under Xen.
958e1b
958e1b
The root cause is, for qemu-xen, 'xl trigger' command didn't reset
958e1b
devices, while QMP didn't unpause hvm domain though they did qemu
958e1b
system reset.
958e1b
958e1b
We have two qemu patches and one xl patch to fix Xen hvm s3 bug.
958e1b
This patch is the qemu patch 1. It adjusts qemu wakeup so that
958e1b
Xen s3 resume logic (which will be implemented at qemu patch 2)
958e1b
will be notified after qemu system reset.
958e1b
958e1b
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
958e1b
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
958e1b
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
958e1b
(cherry picked from commit 4bc78a877252d772b983810a7d2c0be00e9be70e)
958e1b
---
958e1b
 hw/acpi/core.c          |  3 ++-
958e1b
 include/sysemu/sysemu.h |  4 +++-
958e1b
 vl.c                    | 15 +++++++--------
958e1b
 3 files changed, 12 insertions(+), 10 deletions(-)
958e1b
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 hw/acpi/core.c          |    3 ++-
958e1b
 include/sysemu/sysemu.h |    4 +++-
958e1b
 vl.c                    |   15 +++++++--------
958e1b
 3 files changed, 12 insertions(+), 10 deletions(-)
958e1b
958e1b
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
958e1b
index 3352d17..88efba7 100644
958e1b
--- a/hw/acpi/core.c
958e1b
+++ b/hw/acpi/core.c
958e1b
@@ -364,12 +364,13 @@ static void acpi_notify_wakeup(Notifier *notifier, void *data)
958e1b
             (ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_TIMER_STATUS);
958e1b
         break;
958e1b
     case QEMU_WAKEUP_REASON_OTHER:
958e1b
-    default:
958e1b
         /* ACPI_BITMASK_WAKE_STATUS should be set on resume.
958e1b
            Pretend that resume was caused by power button */
958e1b
         ar->pm1.evt.sts |=
958e1b
             (ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_POWER_BUTTON_STATUS);
958e1b
         break;
958e1b
+    default:
958e1b
+        break;
958e1b
     }
958e1b
 }
958e1b
 
958e1b
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
958e1b
index 07181ac..3e457b8 100644
958e1b
--- a/include/sysemu/sysemu.h
958e1b
+++ b/include/sysemu/sysemu.h
958e1b
@@ -42,9 +42,11 @@ int vm_stop(RunState state);
958e1b
 int vm_stop_force_state(RunState state);
958e1b
 
958e1b
 typedef enum WakeupReason {
958e1b
-    QEMU_WAKEUP_REASON_OTHER = 0,
958e1b
+    /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */
958e1b
+    QEMU_WAKEUP_REASON_NONE = 0,
958e1b
     QEMU_WAKEUP_REASON_RTC,
958e1b
     QEMU_WAKEUP_REASON_PMTIMER,
958e1b
+    QEMU_WAKEUP_REASON_OTHER,
958e1b
 } WakeupReason;
958e1b
 
958e1b
 void qemu_system_reset_request(void);
958e1b
diff --git a/vl.c b/vl.c
958e1b
index fcc8fd1..7c1b9d2 100644
958e1b
--- a/vl.c
958e1b
+++ b/vl.c
958e1b
@@ -1690,14 +1690,14 @@ static pid_t shutdown_pid;
958e1b
 static int powerdown_requested;
958e1b
 static int debug_requested;
958e1b
 static int suspend_requested;
958e1b
-static int wakeup_requested;
958e1b
+static WakeupReason wakeup_reason;
958e1b
 static NotifierList powerdown_notifiers =
958e1b
     NOTIFIER_LIST_INITIALIZER(powerdown_notifiers);
958e1b
 static NotifierList suspend_notifiers =
958e1b
     NOTIFIER_LIST_INITIALIZER(suspend_notifiers);
958e1b
 static NotifierList wakeup_notifiers =
958e1b
     NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
958e1b
-static uint32_t wakeup_reason_mask = ~0;
958e1b
+static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
958e1b
 static RunState vmstop_requested = RUN_STATE_MAX;
958e1b
 
958e1b
 int qemu_shutdown_requested_get(void)
958e1b
@@ -1747,11 +1747,9 @@ static int qemu_suspend_requested(void)
958e1b
     return r;
958e1b
 }
958e1b
 
958e1b
-static int qemu_wakeup_requested(void)
958e1b
+static WakeupReason qemu_wakeup_requested(void)
958e1b
 {
958e1b
-    int r = wakeup_requested;
958e1b
-    wakeup_requested = 0;
958e1b
-    return r;
958e1b
+    return wakeup_reason;
958e1b
 }
958e1b
 
958e1b
 static int qemu_powerdown_requested(void)
958e1b
@@ -1868,8 +1866,7 @@ void qemu_system_wakeup_request(WakeupReason reason)
958e1b
         return;
958e1b
     }
958e1b
     runstate_set(RUN_STATE_RUNNING);
958e1b
-    notifier_list_notify(&wakeup_notifiers, &reason);
958e1b
-    wakeup_requested = 1;
958e1b
+    wakeup_reason = reason;
958e1b
     qemu_notify_event();
958e1b
 }
958e1b
 
958e1b
@@ -1961,6 +1958,8 @@ static bool main_loop_should_exit(void)
958e1b
         pause_all_vcpus();
958e1b
         cpu_synchronize_all_states();
958e1b
         qemu_system_reset(VMRESET_SILENT);
958e1b
+        notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
958e1b
+        wakeup_reason = QEMU_WAKEUP_REASON_NONE;
958e1b
         resume_all_vcpus();
958e1b
         monitor_protocol_event(QEVENT_WAKEUP, NULL);
958e1b
     }
958e1b
-- 
958e1b
1.7.1
958e1b