[CRIU] [PATCH 2/5] crtools: add ability to set list of external resources
Andrey Vagin
avagin at openvz.org
Fri Dec 25 06:49:34 PST 2015
From: Andrew Vagin <avagin at virtuozzo.com>
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: Andrew Vagin <avagin at virtuozzo.com>
---
crtools.c | 19 +++++++++++++++++++
files.c | 10 ++++++++++
include/cr_options.h | 6 ++++++
include/files.h | 2 ++
4 files changed, 37 insertions(+)
diff --git a/crtools.c b/crtools.c
index 29c383e..1e547c7 100644
--- a/crtools.c
+++ b/crtools.c
@@ -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"
diff --git a/files.c b/files.c
index c88c287..3b51af2 100644
--- a/files.c
+++ b/files.c
@@ -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;
+}
diff --git a/include/cr_options.h b/include/cr_options.h
index 133595a..3f14b43 100644
--- a/include/cr_options.h
+++ b/include/cr_options.h
@@ -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;
diff --git a/include/files.h b/include/files.h
index db7e108..56de89d 100644
--- a/include/files.h
+++ b/include/files.h
@@ -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__ */
--
2.4.3
More information about the CRIU
mailing list