[CRIU] [PATCH v6 7/7] mount: Restore binfmt_misc content in case of missing mount

Kirill Tkhai ktkhai at virtuozzo.com
Tue Aug 23 09:17:19 PDT 2016


In case of mount image is not containing binfmt_misc mountpoint,
add temporary mountpoint to mount tree and try to restore
binfmt_misc content in ordinary way. Then, umount temporary mountpoint.

v4: New
v5: Check for opts.has_binfmt_misc to determine if image presents
v6: Check for binfmt_misc_list to determine if binfmt_misc entries present

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/mount.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/criu/mount.c b/criu/mount.c
index ff3a90c..7fd9b0a 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -2488,6 +2488,15 @@ static int do_new_mount(struct mount_info *mi)
 	if (tp->restore && tp->restore(mi))
 		return -1;
 
+	if (mi->mnt_id == CRTIME_MNT_ID) {
+		/* C-r time mountpoint, umount it */
+		if (umount(mi->mountpoint) < 0) {
+			pr_perror("Can't umount %s\n", mi->mountpoint);
+			return -1;
+		}
+		goto out;
+	}
+
 	if (remount_ro && mount(NULL, mi->mountpoint, tp->name,
 				     MS_REMOUNT | MS_RDONLY, NULL)) {
 		pr_perror("Unable to apply mount options");
@@ -2507,7 +2516,7 @@ static int do_new_mount(struct mount_info *mi)
 	BUG_ON(mi->master_id);
 	if (restore_shared_options(mi, !mi->shared_id, mi->shared_id, 0))
 		return -1;
-
+out:
 	mi->mounted = true;
 
 	return 0;
@@ -3399,6 +3408,13 @@ static int populate_mnt_ns(void)
 	if (!pms)
 		return -1;
 
+	if (!opts.has_binfmt_misc && !list_empty(&binfmt_misc_list)) {
+		/* Add to mount tree. Generic code will mount it later */
+		ret = add_cr_time_mount(pms, "binfmt_misc", BINFMT_MISC_HOME, 0);
+		if (ret)
+			return -1;
+	}
+
 	if (resolve_shared_mounts(mntinfo, pms->master_id))
 		return -1;
 



More information about the CRIU mailing list