# HG changeset patch
# User Brendan Cully <brendan@xxxxxxxxx>
# Date 1168565202 28800
# Node ID b10287396924bf9973987cc3bfeb442847189e21
# Parent b5414e713c97fff9b13c290f3a80d42183665e0e
Make xen_suspend handle resume.
Don't destroy xenstore watches on suspend, and only recreate them when
resuming in a new domain. Likewise, only invoke frontend device resume
code when in a new domain (the resume functions all tear down the
existing function and wait for the backend to negotiate a new one,
which does not happen in the source domain).
Signed-off-by: Brendan Cully <brendan@xxxxxxxxx>
diff -r b5414e713c97 -r b10287396924
linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c Thu Jan 11
17:26:42 2007 -0800
+++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c Thu Jan 11
17:26:42 2007 -0800
@@ -85,13 +85,20 @@ static void pre_suspend(void)
mfn_to_pfn(xen_start_info->console.domU.mfn);
}
-static void post_suspend(void)
+static void post_suspend(int reconnect)
{
int i, j, k, fpp;
extern unsigned long max_pfn;
extern unsigned long *pfn_to_mfn_frame_list_list;
extern unsigned long *pfn_to_mfn_frame_list[];
+ if (!reconnect) {
+ xen_start_info->store_mfn =
+ pfn_to_mfn(xen_start_info->store_mfn);
+ xen_start_info->console.domU.mfn =
+ pfn_to_mfn(xen_start_info->console.domU.mfn);
+ }
+
set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
@@ -120,7 +127,7 @@ static void post_suspend(void)
#define switch_idle_mm() ((void)0)
#define mm_pin_all() ((void)0)
#define pre_suspend() ((void)0)
-#define post_suspend() ((void)0)
+#define post_suspend(x) ((void)0)
#endif
@@ -158,16 +165,18 @@ int __xen_suspend(void)
pre_suspend();
/*
- * We'll stop somewhere inside this hypercall. When it returns,
- * we'll start resuming after the restore.
+ * This hypercall returns 0 if suspend was cancelled or
+ * the domain was merely checkpointed, and 1 if it is
+ * resuming in a new domain.
*/
- HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
+ err = HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
- post_suspend();
+ post_suspend(err);
gnttab_resume();
- irq_resume();
+ if (err)
+ irq_resume();
time_resume();
@@ -175,9 +184,10 @@ int __xen_suspend(void)
local_irq_enable();
- xencons_resume();
+ if (err)
+ xencons_resume();
- xenbus_resume();
+ xenbus_resume(err);
smp_resume();
diff -r b5414e713c97 -r b10287396924
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Thu Jan 11
17:26:42 2007 -0800
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Thu Jan 11
17:26:42 2007 -0800
@@ -727,11 +727,15 @@ void xenbus_suspend(void)
}
EXPORT_SYMBOL_GPL(xenbus_suspend);
-void xenbus_resume(void)
-{
- xb_init_comms();
- xs_resume();
- bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
+void xenbus_resume(int reconnect)
+{
+ if (reconnect)
+ xb_init_comms();
+ xs_resume(reconnect);
+
+ if (reconnect) {
+ bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
+ }
xenbus_backend_resume(resume_dev);
}
EXPORT_SYMBOL_GPL(xenbus_resume);
diff -r b5414e713c97 -r b10287396924
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Thu Jan 11
17:26:42 2007 -0800
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Thu Jan 11
17:26:42 2007 -0800
@@ -668,31 +668,23 @@ EXPORT_SYMBOL_GPL(unregister_xenbus_watc
void xs_suspend(void)
{
+ down_write(&xs_state.suspend_mutex);
+ mutex_lock(&xs_state.request_mutex);
+}
+
+void xs_resume(int reconnect)
+{
struct xenbus_watch *watch;
char token[sizeof(watch) * 2 + 1];
- down_write(&xs_state.suspend_mutex);
-
- /* No need for watches_lock: the suspend_mutex is sufficient. */
- list_for_each_entry(watch, &watches, list) {
- sprintf(token, "%lX", (long)watch);
- xs_unwatch(watch->node, token);
- }
-
- mutex_lock(&xs_state.request_mutex);
-}
-
-void xs_resume(void)
-{
- struct xenbus_watch *watch;
- char token[sizeof(watch) * 2 + 1];
-
mutex_unlock(&xs_state.request_mutex);
- /* No need for watches_lock: the suspend_mutex is sufficient. */
- list_for_each_entry(watch, &watches, list) {
- sprintf(token, "%lX", (long)watch);
- xs_watch(watch->node, token);
+ if (reconnect) {
+ /* No need for watches_lock: the suspend_mutex is sufficient. */
+ list_for_each_entry(watch, &watches, list) {
+ sprintf(token, "%lX", (long)watch);
+ xs_watch(watch->node, token);
+ }
}
up_write(&xs_state.suspend_mutex);
diff -r b5414e713c97 -r b10287396924 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h Thu Jan 11 17:26:42 2007 -0800
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h Thu Jan 11 17:26:42 2007 -0800
@@ -159,14 +159,14 @@ int register_xenbus_watch(struct xenbus_
int register_xenbus_watch(struct xenbus_watch *watch);
void unregister_xenbus_watch(struct xenbus_watch *watch);
void xs_suspend(void);
-void xs_resume(void);
+void xs_resume(int reconnect);
/* Used by xenbus_dev to borrow kernel's store connection. */
void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg);
/* Called from xen core code. */
void xenbus_suspend(void);
-void xenbus_resume(void);
+void xenbus_resume(int reconnect);
#define XENBUS_IS_ERR_READ(str) ({ \
if (!IS_ERR(str) && strlen(str) == 0) { \
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|