[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] xc_save: ignore the first suspend event channel notification



# HG changeset patch
# User Brendan Cully <brendan@xxxxxxxxx>
# Date 1220642148 25200
# Node ID 8b8456290da7eeb8b40d3d42b6e9e4adcd2f7077
# Parent  6e53036deb06fdbaa55489610ea8fc9c9b67ca64
xc_save: ignore the first suspend event channel notification

I've noticed that the suspend event channel becomes pending as soon as
it is bound. I'm not sure why or whether this is intentional, but it
means that the suspend function will return before the domain has
completed suspending unless the first notification is cleared. Without
this patch, xc_domain_save may find that the guest has not suspended
and sleep in 10ms chunks until it does. Typically this is several
milliseconds of wasted time.

diff --git a/tools/xcutils/xc_save.c b/tools/xcutils/xc_save.c
--- a/tools/xcutils/xc_save.c
+++ b/tools/xcutils/xc_save.c
@@ -57,6 +57,25 @@
     return 0;
 }
 
+static int await_suspend(struct suspendinfo *si)
+{
+    int rc;
+
+    do {
+      rc = xc_evtchn_pending(si->xce);
+      if (rc < 0) {
+       warnx("error polling suspend notification channel: %d", rc);
+       return -1;
+      }
+    } while (rc != si->suspend_evtchn);
+
+    /* harmless for one-off suspend */
+    if (xc_evtchn_unmask(si->xce, si->suspend_evtchn) < 0)
+       warnx("failed to unmask suspend notification channel: %d", rc);
+
+    return 0;
+}
+
 static int suspend_evtchn_init(int xc, int domid)
 {
     struct xs_handle *xs;
@@ -104,7 +123,8 @@
        goto cleanup;
     }
 
-    return 0;
+    /* event channel is pending immediately after binding? */
+    await_suspend(&si);
 
   cleanup:
     suspend_evtchn_release(xc, domid);
@@ -125,17 +145,10 @@
        return 0;
     }
 
-    do {
-      rc = xc_evtchn_pending(si.xce);
-      if (rc < 0) {
-       warnx("error polling suspend notification channel: %d", rc);
+    if (await_suspend(&si) < 0) {
+       warnx("suspend failed");
        return 0;
-      }
-    } while (rc != si.suspend_evtchn);
-
-    /* harmless for one-off suspend */
-    if (xc_evtchn_unmask(si.xce, si.suspend_evtchn) < 0)
-       warnx("failed to unmask suspend notification channel: %d", rc);
+    }
 
     /* notify xend that it can do device migration */
     printf("suspended\n");

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.