Commit 6280625a authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

crtools: add ability to set list of external resources

This option is used to mark external resources on dump.

Currently it's going to be used to handle external tty-s,
but in a future it can be used to any type of resources.

We can have a few ways to restore external resources and
we will have a separate options to say how to restore each type.

For example, we can use --inherit-fd to restore external
file descriptors.
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2245a433
......@@ -58,6 +58,7 @@ void init_opts(void)
INIT_LIST_HEAD(&opts.scripts);
INIT_LIST_HEAD(&opts.ext_mounts);
INIT_LIST_HEAD(&opts.inherit_fds);
INIT_LIST_HEAD(&opts.external);
INIT_LIST_HEAD(&opts.new_cgroup_roots);
INIT_LIST_HEAD(&opts.irmap_scan_paths);
......@@ -257,6 +258,7 @@ int main(int argc, char *argv[], char *envp[])
{ "irmap-scan-path", required_argument, 0, 1070 },
{ "lsm-profile", required_argument, 0, 1071 },
{ "timeout", required_argument, 0, 1072 },
{ "external", required_argument, 0, 1073 },
{ },
};
......@@ -523,6 +525,17 @@ int main(int argc, char *argv[], char *envp[])
return 1;
}
break;
case 1073:
{
struct external *ext;
ext = xmalloc(sizeof(*ext));
if (!ext)
return 1;
ext->id = optarg;
list_add(&ext->node, &opts.external);
}
break;
case 'V':
pr_msg("Version: %s\n", CRIU_VERSION);
if (strcmp(CRIU_GITID, "0"))
......@@ -594,6 +607,11 @@ int main(int argc, char *argv[], char *envp[])
if (log_init(opts.output))
return 1;
if (!list_empty(&opts.external) && strcmp(argv[optind], "dump")) {
pr_err("--external is dump-only option\n");
return 1;
}
if (!list_empty(&opts.inherit_fds)) {
if (strcmp(argv[optind], "restore")) {
pr_err("--inherit-fd is restore-only option\n");
......@@ -754,6 +772,7 @@ usage:
" --enable-fs FSNAMES a comma separated list of filesystem names or \"all\".\n"
" force criu to (try to) dump/restore these filesystem's\n"
" mountpoints even if fs is not supported.\n"
" --external RES dump objects from this list as external resources\n"
"\n"
"* Logging:\n"
" -o|--log-file FILE log file name\n"
......
......@@ -1575,3 +1575,13 @@ int inherit_fd_fini()
}
return 0;
}
bool external_lookup_id(char *id)
{
struct external *ext;
list_for_each_entry(ext, &opts.external, node)
if (!strcmp(ext->id, id))
return true;
return false;
}
......@@ -47,6 +47,11 @@ struct irmap_path_opt {
struct irmap *ir;
};
struct external {
struct list_head node;
char *id;
};
struct cr_options {
int final_state;
char *show_dump_file;
......@@ -76,6 +81,7 @@ struct cr_options {
struct list_head scripts;
struct list_head ext_mounts;
struct list_head inherit_fds;
struct list_head external;
char *libdir;
bool use_page_server;
unsigned short port;
......
......@@ -175,6 +175,8 @@ extern void inherit_fd_log(void);
extern int inherit_fd_resolve_clash(int fd);
extern int inherit_fd_fini(void);
extern bool external_lookup_id(char *id);
extern bool inherited_fd(struct file_desc *, int *fdp);
#endif /* __CR_FILES_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment