[CRIU] [PATCH 2/2] mount: Config-out virtualized binfmt_misc
Pavel Emelyanov
xemul at virtuozzo.com
Mon Oct 31 20:20:08 PDT 2016
The need to mess with binfmt_misc super-blocks only exists
in OpenVZ kernel and troubes all the other users. So make
this code get compiled-out by default.
In VZ-builds the BINFMT_MISC_VIRTUALIZED should be put into
.config file before running make.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/filesystems.c | 6 ++++++
criu/include/cr_options.h | 2 ++
criu/include/mount.h | 4 ++++
criu/mount.c | 10 ++++++++--
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/criu/filesystems.c b/criu/filesystems.c
index f2780ec..b1c0502 100644
--- a/criu/filesystems.c
+++ b/criu/filesystems.c
@@ -30,6 +30,7 @@ static int attach_option(struct mount_info *pm, char *opt)
return pm->options ? 0 : -1;
}
+#ifdef CONFIG_BINFMT_MISC_VIRTUALIZED
struct binfmt_misc_info {
BinfmtMiscEntry *bme;
struct list_head list;
@@ -370,6 +371,11 @@ int collect_binfmt_misc(void)
{
return collect_image(&binfmt_misc_cinfo);
}
+#else
+#define binfmt_misc_dump NULL
+#define binfmt_misc_restore NULL
+#define binfmt_misc_parse NULL
+#endif
static int tmpfs_dump(struct mount_info *pm)
{
diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h
index 453071b..be96b50 100644
--- a/criu/include/cr_options.h
+++ b/criu/include/cr_options.h
@@ -96,7 +96,9 @@ struct cr_options {
bool enable_external_masters;
bool aufs; /* auto-deteced, not via cli */
bool overlayfs;
+#ifdef CONFIG_BINFMT_MISC_VIRTUALIZED
bool has_binfmt_misc; /* auto-detected */
+#endif
size_t ghost_limit;
struct list_head irmap_scan_paths;
bool lsm_supplied;
diff --git a/criu/include/mount.h b/criu/include/mount.h
index 798aa3e..a692b55 100644
--- a/criu/include/mount.h
+++ b/criu/include/mount.h
@@ -71,7 +71,11 @@ struct mount_info {
extern struct mount_info *mntinfo;
extern struct ns_desc mnt_ns_desc;
+#ifdef CONFIG_BINFMT_MISC_VIRTUALIZED
extern int collect_binfmt_misc(void);
+#else
+static inline int collect_binfmt_misc(void) { return 0; }
+#endif
extern struct mount_info *mnt_entry_alloc();
extern void mnt_entry_free(struct mount_info *mi);
diff --git a/criu/mount.c b/criu/mount.c
index 5583fc5..8638253 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1138,7 +1138,7 @@ out:
return -1;
}
-static int add_cr_time_mount(struct mount_info *root, char *fsname, const char *path, unsigned int s_dev)
+static __maybe_unused int add_cr_time_mount(struct mount_info *root, char *fsname, const char *path, unsigned int s_dev)
{
struct mount_info *mi, *t, *parent;
@@ -1186,7 +1186,7 @@ static int add_cr_time_mount(struct mount_info *root, char *fsname, const char *
}
/* Returns 1 in case of success, -errno in case of mount fail, and 0 on other errors */
-static int mount_cr_time_mount(struct ns_id *ns, unsigned int *s_dev, const char *source,
+static __maybe_unused int mount_cr_time_mount(struct ns_id *ns, unsigned int *s_dev, const char *source,
const char *target, const char *type)
{
int mnt_fd, ret, exit_code = 0;
@@ -2453,8 +2453,10 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
goto err;
}
+#ifdef CONFIG_BINFMT_MISC_VIRTUALIZED
if (me->fstype == FSTYPE__BINFMT_MISC)
opts.has_binfmt_misc = true;
+#endif
/* FIXME: abort unsupported early */
pm->fstype = decode_fstype(me->fstype);
@@ -2665,12 +2667,14 @@ static int populate_mnt_ns(void)
if (!pms)
return -1;
+#ifdef CONFIG_BINFMT_MISC_VIRTUALIZED
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;
}
+#endif
if (resolve_shared_mounts(mntinfo, pms->master_id))
return -1;
@@ -3126,6 +3130,7 @@ int collect_mnt_namespaces(bool for_dump)
if (ret)
goto err;
+#ifdef CONFIG_BINFMT_MISC_VIRTUALIZED
if (for_dump && !opts.has_binfmt_misc) {
unsigned int s_dev = 0;
struct ns_id *ns;
@@ -3153,6 +3158,7 @@ int collect_mnt_namespaces(bool for_dump)
}
}
}
+#endif
ret = resolve_external_mounts(mntinfo);
if (ret)
--
2.5.0
More information about the CRIU
mailing list