]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: Rewind toolstack_save_fd in libxl_save_helper when using remus
authorYang Hongyang <yanghy@cn.fujitsu.com>
Fri, 20 Jun 2014 06:59:34 +0000 (14:59 +0800)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 23 Jun 2014 16:58:54 +0000 (17:58 +0100)
Commit b327a3f421bb57d262b7d1fb3c43b710852b103b moved the rewinding of
toolstack_save_fd to libxl.  This breaks remus, because in remus mode,
toolstack_save_cb will be called in every checkpoint, and if we don't
rewind it in libxl_save_helper, it will surely fail.

This fix is just a hack: in fact the whole toolstack save thing should
be done in libxl.  But for now (until migration v2) this fix should
solve both remus and Jason Adryuk's use case.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Tested-by: Jason Andryuk <andryuk@aero.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl_save_helper.c

index b259bd0215ff3a5ffe7ef599cb77c765d0a61229..4619fa34a338c4e391b2b4cddc84689acd13b5b0 100644 (file)
@@ -159,6 +159,7 @@ int helper_getreply(void *user)
 
 static int toolstack_save_fd;
 static uint32_t toolstack_save_len;
+static struct save_callbacks helper_save_callbacks;
 
 static int toolstack_save_cb(uint32_t domid, uint8_t **buf,
                              uint32_t *len, void *data)
@@ -167,6 +168,12 @@ static int toolstack_save_cb(uint32_t domid, uint8_t **buf,
 
     assert(toolstack_save_fd > 0);
 
+    /* This is a hack for remus */
+    if (helper_save_callbacks.checkpoint) {
+        r = lseek(toolstack_save_fd, 0, SEEK_SET);
+        if (r) fail(errno,"rewind toolstack data tmpfile");
+    }
+
     *buf = xmalloc(toolstack_save_len);
     r = read_exactly(toolstack_save_fd, *buf, toolstack_save_len);
     if (r<0) fail(errno,"read toolstack data");
@@ -191,7 +198,6 @@ static void complete(int retval) {
     exit(0);
 }
 
-static struct save_callbacks helper_save_callbacks;
 static struct restore_callbacks helper_restore_callbacks;
 
 int main(int argc, char **argv)