[CRIU] [PATCH] bfd: Check images got flushed at the end

Pavel Emelyanov xemul at parallels.com
Wed Oct 29 04:43:46 PDT 2014


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 bfd.c         | 13 +++++++++++--
 cr-dump.c     |  6 ++++++
 include/bfd.h |  1 +
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/bfd.c b/bfd.c
index d7fa16c..04f5789 100644
--- a/bfd.c
+++ b/bfd.c
@@ -97,6 +97,12 @@ int bfdopen(struct bfd *f)
 }
 
 static int bflush(struct bfd *bfd);
+static bool flush_failed = false;
+
+int bfd_flush_images(void)
+{
+	return flush_failed ? -1 : 0;
+}
 
 void bclose(struct bfd *f)
 {
@@ -107,15 +113,18 @@ void bclose(struct bfd *f)
 		 * becase we read _all_ data from them and the
 		 * b->sz would be 0 by the time we close them.
 		 */
-		if (bflush(f) < 0)
+		if (bflush(f) < 0) {
 			/*
-			 * FIXME -- propagate error up. It's
+			 * This is to propagate error up. It's
 			 * hardly possible by returning and
 			 * checking it, but setting a static
 			 * flag, failing further bfdopen-s and
 			 * checking one at the end would work.
 			 */
+			flush_failed = true;
 			pr_err("Error flushing image\n");
+		}
+
 		buf_put(&f->b);
 	}
 	close(f->fd);
diff --git a/cr-dump.c b/cr-dump.c
index 7d33e3d..3057a47 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1766,6 +1766,9 @@ err:
 	if (disconnect_from_page_server())
 		ret = -1;
 
+	if (bfd_flush_images())
+		ret = -1;
+
 	if (ret)
 		pr_err("Pre-dumping FAILED.\n");
 	else {
@@ -1891,6 +1894,9 @@ err:
 
 	close_cr_imgset(&glob_imgset);
 
+	if (bfd_flush_images())
+		ret = -1;
+
 	cr_plugin_fini(CR_PLUGIN_STAGE__DUMP, ret);
 
 	if (!ret) {
diff --git a/include/bfd.h b/include/bfd.h
index f40ae5f..55e2e9d 100644
--- a/include/bfd.h
+++ b/include/bfd.h
@@ -33,4 +33,5 @@ int bwrite(struct bfd *f, const void *buf, int sz);
 struct iovec;
 int bwritev(struct bfd *f, const struct iovec *iov, int cnt);
 int bread(struct bfd *f, void *buf, int sz);
+int bfd_flush_images(void);
 #endif
-- 
1.8.4.2



More information about the CRIU mailing list