|
|
298366 |
From bc05a488b49f903e404323b76ca9b675318393fc Mon Sep 17 00:00:00 2001
|
|
|
298366 |
From: "Liu, Jinsong" <jinsong.liu@intel.com>
|
|
|
298366 |
Date: Wed, 25 Sep 2013 16:38:29 +0000
|
|
|
298366 |
Subject: [PATCH] qemu: Adjust qemu wakeup
|
|
|
298366 |
|
|
|
298366 |
Currently Xen hvm s3 has a bug coming from the difference between
|
|
|
298366 |
qemu-traditioanl and qemu-xen. For qemu-traditional, the way to
|
|
|
298366 |
resume from hvm s3 is via 'xl trigger' command. However, for
|
|
|
298366 |
qemu-xen, the way to resume from hvm s3 inherited from standard
|
|
|
298366 |
qemu, i.e. via QMP, and it doesn't work under Xen.
|
|
|
298366 |
|
|
|
298366 |
The root cause is, for qemu-xen, 'xl trigger' command didn't reset
|
|
|
298366 |
devices, while QMP didn't unpause hvm domain though they did qemu
|
|
|
298366 |
system reset.
|
|
|
298366 |
|
|
|
298366 |
We have two qemu patches and one xl patch to fix Xen hvm s3 bug.
|
|
|
298366 |
This patch is the qemu patch 1. It adjusts qemu wakeup so that
|
|
|
298366 |
Xen s3 resume logic (which will be implemented at qemu patch 2)
|
|
|
298366 |
will be notified after qemu system reset.
|
|
|
298366 |
|
|
|
298366 |
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
|
|
|
298366 |
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
|
|
|
298366 |
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
298366 |
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
|
|
|
298366 |
(cherry picked from commit 4bc78a877252d772b983810a7d2c0be00e9be70e)
|
|
|
298366 |
|
|
|
298366 |
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
298366 |
---
|
|
|
298366 |
hw/acpi/core.c | 3 ++-
|
|
|
298366 |
include/sysemu/sysemu.h | 4 +++-
|
|
|
298366 |
vl.c | 15 +++++++--------
|
|
|
298366 |
3 files changed, 12 insertions(+), 10 deletions(-)
|
|
|
298366 |
|
|
|
298366 |
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
|
|
|
298366 |
index b07feda..769cfdb 100644
|
|
|
298366 |
--- a/hw/acpi/core.c
|
|
|
298366 |
+++ b/hw/acpi/core.c
|
|
|
298366 |
@@ -324,12 +324,13 @@ static void acpi_notify_wakeup(Notifier *notifier, void *data)
|
|
|
298366 |
(ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_TIMER_STATUS);
|
|
|
298366 |
break;
|
|
|
298366 |
case QEMU_WAKEUP_REASON_OTHER:
|
|
|
298366 |
- default:
|
|
|
298366 |
/* ACPI_BITMASK_WAKE_STATUS should be set on resume.
|
|
|
298366 |
Pretend that resume was caused by power button */
|
|
|
298366 |
ar->pm1.evt.sts |=
|
|
|
298366 |
(ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_POWER_BUTTON_STATUS);
|
|
|
298366 |
break;
|
|
|
298366 |
+ default:
|
|
|
298366 |
+ break;
|
|
|
298366 |
}
|
|
|
298366 |
}
|
|
|
298366 |
|
|
|
298366 |
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
|
|
|
298366 |
index d7a77b6..1a77c99 100644
|
|
|
298366 |
--- a/include/sysemu/sysemu.h
|
|
|
298366 |
+++ b/include/sysemu/sysemu.h
|
|
|
298366 |
@@ -39,9 +39,11 @@ int vm_stop(RunState state);
|
|
|
298366 |
int vm_stop_force_state(RunState state);
|
|
|
298366 |
|
|
|
298366 |
typedef enum WakeupReason {
|
|
|
298366 |
- QEMU_WAKEUP_REASON_OTHER = 0,
|
|
|
298366 |
+ /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */
|
|
|
298366 |
+ QEMU_WAKEUP_REASON_NONE = 0,
|
|
|
298366 |
QEMU_WAKEUP_REASON_RTC,
|
|
|
298366 |
QEMU_WAKEUP_REASON_PMTIMER,
|
|
|
298366 |
+ QEMU_WAKEUP_REASON_OTHER,
|
|
|
298366 |
} WakeupReason;
|
|
|
298366 |
|
|
|
298366 |
void qemu_system_reset_request(void);
|
|
|
298366 |
diff --git a/vl.c b/vl.c
|
|
|
298366 |
index f422a1c..2160933 100644
|
|
|
298366 |
--- a/vl.c
|
|
|
298366 |
+++ b/vl.c
|
|
|
298366 |
@@ -1792,14 +1792,14 @@ static pid_t shutdown_pid;
|
|
|
298366 |
static int powerdown_requested;
|
|
|
298366 |
static int debug_requested;
|
|
|
298366 |
static int suspend_requested;
|
|
|
298366 |
-static int wakeup_requested;
|
|
|
298366 |
+static WakeupReason wakeup_reason;
|
|
|
298366 |
static NotifierList powerdown_notifiers =
|
|
|
298366 |
NOTIFIER_LIST_INITIALIZER(powerdown_notifiers);
|
|
|
298366 |
static NotifierList suspend_notifiers =
|
|
|
298366 |
NOTIFIER_LIST_INITIALIZER(suspend_notifiers);
|
|
|
298366 |
static NotifierList wakeup_notifiers =
|
|
|
298366 |
NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
|
|
|
298366 |
-static uint32_t wakeup_reason_mask = ~0;
|
|
|
298366 |
+static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
|
|
|
298366 |
static RunState vmstop_requested = RUN_STATE_MAX;
|
|
|
298366 |
|
|
|
298366 |
int qemu_shutdown_requested_get(void)
|
|
|
298366 |
@@ -1849,11 +1849,9 @@ static int qemu_suspend_requested(void)
|
|
|
298366 |
return r;
|
|
|
298366 |
}
|
|
|
298366 |
|
|
|
298366 |
-static int qemu_wakeup_requested(void)
|
|
|
298366 |
+static WakeupReason qemu_wakeup_requested(void)
|
|
|
298366 |
{
|
|
|
298366 |
- int r = wakeup_requested;
|
|
|
298366 |
- wakeup_requested = 0;
|
|
|
298366 |
- return r;
|
|
|
298366 |
+ return wakeup_reason;
|
|
|
298366 |
}
|
|
|
298366 |
|
|
|
298366 |
static int qemu_powerdown_requested(void)
|
|
|
298366 |
@@ -1970,8 +1968,7 @@ void qemu_system_wakeup_request(WakeupReason reason)
|
|
|
298366 |
return;
|
|
|
298366 |
}
|
|
|
298366 |
runstate_set(RUN_STATE_RUNNING);
|
|
|
298366 |
- notifier_list_notify(&wakeup_notifiers, &reason);
|
|
|
298366 |
- wakeup_requested = 1;
|
|
|
298366 |
+ wakeup_reason = reason;
|
|
|
298366 |
qemu_notify_event();
|
|
|
298366 |
}
|
|
|
298366 |
|
|
|
298366 |
@@ -2063,6 +2060,8 @@ static bool main_loop_should_exit(void)
|
|
|
298366 |
pause_all_vcpus();
|
|
|
298366 |
cpu_synchronize_all_states();
|
|
|
298366 |
qemu_system_reset(VMRESET_SILENT);
|
|
|
298366 |
+ notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
|
|
|
298366 |
+ wakeup_reason = QEMU_WAKEUP_REASON_NONE;
|
|
|
298366 |
resume_all_vcpus();
|
|
|
298366 |
monitor_protocol_event(QEVENT_WAKEUP, NULL);
|
|
|
298366 |
}
|