libxc: Flush I/O before xc_domain_save completion
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 12 Apr 2010 06:22:16 +0000 (07:22 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 12 Apr 2010 06:22:16 +0000 (07:22 +0100)
The final, flushing call to discard_file_cache also discards any
errors from fsync. Call fsync explicitly before leaving, to check if
all VM memory actually made it to the disk.

Signed-off-by: Daniel Stodden <daniel.stodden@citrix.com>
tools/libxc/xc_domain_save.c

index 2334b49c07d910e9cd5316dc0750b107eeaa625e..cb98374e020870d200130c96ad9b45be8a17b9c0 100644 (file)
@@ -1764,6 +1764,13 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
         goto out;
     }
 
+    /* Flush last write and check for errors. */
+    if ( fsync(io_fd) && errno != EINVAL )
+    {
+        PERROR("Error when flushing state file");
+        goto out;
+    }
+
     /* Success! */
     rc = 0;