[Devel] [PATCH criu] files: Allow to dump ploopX files opened

Cyrill Gorcunov gorcunov at gmail.com
Sun Jul 17 01:01:47 PDT 2016


Sometimes container's systemd-udevd opens ploop device
for some reason. Since it's not forbidden allow it
to do so.

 | (13.131338) Dumping task (pid: 270073 comm: systemd-udevd)
 | (13.131343) ========================================
 | ...
 | (13.173422) 270073 fdinfo 8: pos: 0x               0 flags:          2504000/0x1
 | (13.173439) Error (files-ext.c:91): Can't dump file 8 (/dev/ploop18098) of that type [60600] (unknown (null))
 | (13.173444) ----------------------------------------
 | (13.352711) Error (cr-dump.c:1317): Dump files (pid: 270073) failed with -1
 | (13.583663) Waiting for 270073 to trap

https://jira.sw.ru/browse/PSBM-49723

Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
 criu/files.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/criu/files.c b/criu/files.c
index dfa3603..453993d 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -387,6 +387,30 @@ static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
 	return do_dump_gen_file(p, lfd, ops, img);
 }
 
+static int check_blkdev(struct fd_parms *p, int lfd)
+{
+	/*
+	 * @ploop_major is module parameter actually,
+	 * set to PLOOP_DEVICE_MAJOR by default. We may
+	 * need to scan module params or access
+	 * /sys/block/ploopX/dev to fetch major.
+	 *
+	 * For a while simply use predefined @major.
+	 */
+	static const int ploop_major = 182;
+	int maj = major(p->stat.st_rdev);
+
+	/*
+	 * It's been found that systemd-udevd sometimes
+	 * opens-up ploop device from inside of container,
+	 * so allow him to do that.
+	 */
+	if (maj == ploop_major)
+		return 0;
+
+	return -1;
+}
+
 static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_opts *opts,
 		       struct cr_img *img)
 {
@@ -431,9 +455,15 @@ static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_op
 		return do_dump_gen_file(&p, lfd, ops, img);
 	}
 
-	if (S_ISREG(p.stat.st_mode) || S_ISDIR(p.stat.st_mode)) {
+	if (S_ISREG(p.stat.st_mode) || S_ISDIR(p.stat.st_mode) ||
+	    S_ISBLK(p.stat.st_mode)) {
 		struct fd_link link;
 
+		if (S_ISBLK(p.stat.st_mode)) {
+			if (check_blkdev(&p, lfd))
+				return -1;
+		}
+
 		if (fill_fdlink(lfd, &p, &link))
 			return -1;
 
-- 
2.7.4



More information about the Devel mailing list