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 4 of 4] libxc: restore: reset I/O fd to flags to back

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 4 of 4] libxc: restore: reset I/O fd to flags to back to state caller passed us
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 06 Sep 2010 11:03:16 +0100
Cc: Brendan Cully <brendan@xxxxxxxxx>
Delivery-date: Mon, 06 Sep 2010 03:11:26 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1283767392@xxxxxxxxxxxxxxxxxxxxx>
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 Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1283766891 -3600
# Node ID b93e43ba481f62026991c5a6afb85cd395059505
# Parent  bdf8ce09160d715451e1204babe5f80886ea6183
libxc: restore: reset I/O fd to flags to back to state caller passed us

In particular this causes us to turn O_NONBLOCK back off if we set it.

The caller may continue to use the fd for it's own protocol needs and
may not be prepared to have it become non-blocking.

This probably only effects Remus now after my previous patch to signal
the last checkpoint, since a regular migration will no longer set the
fd non-blocking.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r bdf8ce09160d -r b93e43ba481f tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c   Mon Sep 06 10:54:51 2010 +0100
+++ b/tools/libxc/xc_domain_restore.c   Mon Sep 06 10:54:51 2010 +0100
@@ -1094,6 +1094,8 @@ int xc_domain_restore(xc_interface *xch,
     void* vcpup;
     uint64_t console_pfn = 0;
 
+    int orig_io_fd_flags;
+
     static struct restore_ctx _ctx = {
         .live_p2m = NULL,
         .p2m = NULL,
@@ -1110,6 +1112,11 @@ int xc_domain_restore(xc_interface *xch,
 
     if ( superpages )
         return 1;
+
+    if ( (orig_io_fd_flags = fcntl(io_fd, F_GETFL, 0)) < 0 ) {
+        PERROR("unable to read IO FD flags");
+        goto out;
+    }
 
     if ( read_exact(io_fd, &dinfo->p2m_size, sizeof(unsigned long)) )
     {
@@ -1294,7 +1301,6 @@ int xc_domain_restore(xc_interface *xch,
     // DPRINTF("Received all pages (%d races)\n", nraces);
 
     if ( !ctx->completed ) {
-        int flags = 0;
 
         if ( buffer_tail(xch, ctx, &tailbuf, io_fd, max_vcpu_id, vcpumap,
                          ext_vcpucontext) < 0 ) {
@@ -1308,11 +1314,7 @@ int xc_domain_restore(xc_interface *xch,
          * nonblocking mode for the remainder.
          */
         if ( !ctx->last_checkpoint )
-        {
-            if ( (flags = fcntl(io_fd, F_GETFL,0)) < 0 )
-                flags = 0;
-            fcntl(io_fd, F_SETFL, flags | O_NONBLOCK);
-        }
+            fcntl(io_fd, F_SETFL, orig_io_fd_flags | O_NONBLOCK);
     }
 
     if ( ctx->last_checkpoint )
@@ -1805,8 +1807,10 @@ int xc_domain_restore(xc_interface *xch,
     /* discard cache for save file  */
     discard_file_cache(xch, io_fd, 1 /*flush*/);
 
+    fcntl(io_fd, F_SETFL, orig_io_fd_flags);
+
     DPRINTF("Restore exit with rc=%d\n", rc);
-    
+
     return rc;
 }
 /*

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