mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-08-01 14:30:53 +00:00
mnt: Create roots in criu context
In case root task restore failure we'll have to remove the roots yard dir from criu, so we have to create one by criu to at least have the dit name. It's OK to do it in criu, since the yards is created in the opts.root which is the same for any mnt ns we deal with on restore. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
e3f5ba3c37
commit
c5c65fe17a
3 changed files with 35 additions and 10 deletions
|
|
@ -117,5 +117,6 @@ extern int fini_mnt_ns(void);
|
|||
|
||||
extern char *rst_get_mnt_root(int mnt_id);
|
||||
extern int ext_mount_add(char *key, char *val);
|
||||
extern int mntns_maybe_create_roots(void);
|
||||
|
||||
#endif /* __CR_MOUNT_H__ */
|
||||
|
|
|
|||
36
mount.c
36
mount.c
|
|
@ -2529,16 +2529,6 @@ static int read_mnt_ns_img(void)
|
|||
if (nsid->nd != &mnt_ns_desc)
|
||||
continue;
|
||||
|
||||
if (nsid->type != NS_ROOT) {
|
||||
BUG_ON(nsid->type == NS_CRIU);
|
||||
/*
|
||||
* If we have more than one (root) namespace,
|
||||
* then we'll need the roots yard.
|
||||
*/
|
||||
if (create_mnt_roots())
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (collect_mnt_from_image(&pms, nsid))
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2568,6 +2558,32 @@ char *rst_get_mnt_root(int mnt_id)
|
|||
return path;
|
||||
}
|
||||
|
||||
int mntns_maybe_create_roots(void)
|
||||
{
|
||||
struct ns_id *ns;
|
||||
|
||||
if (!(root_ns_mask & CLONE_NEWNS))
|
||||
return 0;
|
||||
|
||||
for (ns = ns_ids; ns != NULL; ns = ns->next) {
|
||||
if (ns->nd != &mnt_ns_desc)
|
||||
continue;
|
||||
|
||||
if (ns->type != NS_ROOT) {
|
||||
BUG_ON(ns->type == NS_CRIU);
|
||||
|
||||
/*
|
||||
* If we have more than one (root) namespace,
|
||||
* then we'll need the roots yard.
|
||||
*/
|
||||
return create_mnt_roots();
|
||||
}
|
||||
}
|
||||
|
||||
/* No "other" mntns found, just go ahead, we don't need roots yard. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_restore_task_mnt_ns(struct ns_id *nsid, struct pstree_item *current)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
|
|
|
|||
|
|
@ -1321,8 +1321,16 @@ int prepare_namespace_before_tasks(void)
|
|||
if (netns_keep_nsfd())
|
||||
goto err_netns;
|
||||
|
||||
if (mntns_maybe_create_roots())
|
||||
goto err_mnt;
|
||||
|
||||
return 0;
|
||||
|
||||
err_mnt:
|
||||
/*
|
||||
* Nothing, netns' descriptor will be closed
|
||||
* on criu exit
|
||||
*/
|
||||
err_netns:
|
||||
stop_usernsd();
|
||||
err_unds:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue