WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xc_save: ignore the first suspend event channel notification
From: Brendan Cully <brendan@xxxxxxxxx>
Date: Fri, 05 Sep 2008 12:16:38 -0700
Delivery-date: Fri, 05 Sep 2008 12:17:02 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# 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