Commit 056047bd authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

criu: Add --cpu-cap option

This option will serve to manage CPU capabilities
to be matched/ignored on restore procedure. At the
moment we introduce 'fpu','all' capability arguments.
By default 'all' is set.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ad0f6980
...@@ -77,6 +77,16 @@ OPTIONS ...@@ -77,6 +77,16 @@ OPTIONS
done with help of 'post-dump' script. done with help of 'post-dump' script.
In other words, do not use it until really needed. In other words, do not use it until really needed.
*--cpu-cap* 'cap'[,'cap']::
When restore process require 'cap' CPU capability to be present. To inverse
capability prefix it with '^'.
- *fpu*. Requre the CPU to have comaptible FPU. For example the process
might be dumped with xsave capability but attempted to restore
without it present on target cpu. In such case we refuse to procceed.
- *all*. Require all capability. This is *default* mode.
*-f*, *--file* 'file':: *-f*, *--file* 'file'::
This option is valid for *show* command only and allows to see content of This option is valid for *show* command only and allows to see content of
the 'file' specified. the 'file' specified.
......
...@@ -45,6 +45,8 @@ void init_opts(void) ...@@ -45,6 +45,8 @@ void init_opts(void)
opts.final_state = TASK_DEAD; opts.final_state = TASK_DEAD;
INIT_LIST_HEAD(&opts.veth_pairs); INIT_LIST_HEAD(&opts.veth_pairs);
INIT_LIST_HEAD(&opts.scripts); INIT_LIST_HEAD(&opts.scripts);
opts.cpu_cap = CPU_CAP_ALL;
} }
static int parse_ns_string(const char *ptr) static int parse_ns_string(const char *ptr)
...@@ -75,6 +77,43 @@ bad_ns: ...@@ -75,6 +77,43 @@ bad_ns:
return -1; return -1;
} }
static int parse_cpu_cap(struct cr_options *opts, const char *optarg)
{
bool inverse = false;
#define ____cpu_set_cap(__opts, __cap, __inverse) \
do { \
if ((__inverse)) \
(__opts)->cpu_cap &= ~(__cap); \
else \
(__opts)->cpu_cap |= (__cap); \
} while (0)
for (; *optarg; optarg++) {
if (optarg[0] == '^') {
inverse = !inverse;
continue;
} else if (optarg[0] == ',') {
inverse = false;
continue;
}
if (!strncmp(optarg, "fpu", 3))
____cpu_set_cap(opts, CPU_CAP_FPU, inverse);
if (!strncmp(optarg, "all", 3))
____cpu_set_cap(opts, CPU_CAP_ALL, inverse);
else
goto Esyntax;
}
#undef ____cpu_set_cap
return 0;
Esyntax:
pr_err("Unknown FPU mode `%s' selected\n", optarg);
return -1;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
pid_t pid = 0, tree_id = 0; pid_t pid = 0, tree_id = 0;
...@@ -121,6 +160,7 @@ int main(int argc, char *argv[]) ...@@ -121,6 +160,7 @@ int main(int argc, char *argv[])
{ "track-mem", no_argument, 0, 55}, { "track-mem", no_argument, 0, 55},
{ "auto-dedup", no_argument, 0, 56}, { "auto-dedup", no_argument, 0, 56},
{ "libdir", required_argument, 0, 'L'}, { "libdir", required_argument, 0, 'L'},
{ "cpu-cap", required_argument, 0, 57},
{ }, { },
}; };
...@@ -279,6 +319,10 @@ int main(int argc, char *argv[]) ...@@ -279,6 +319,10 @@ int main(int argc, char *argv[])
case 56: case 56:
opts.auto_dedup = true; opts.auto_dedup = true;
break; break;
case 57:
if (parse_cpu_cap(&opts, optarg))
goto usage;
break;
case 54: case 54:
opts.check_ms_kernel = true; opts.check_ms_kernel = true;
break; break;
...@@ -410,6 +454,8 @@ usage: ...@@ -410,6 +454,8 @@ usage:
" --pidfile FILE write root task, service or page-server pid to FILE\n" " --pidfile FILE write root task, service or page-server pid to FILE\n"
" -W|--work-dir DIR directory to cd and write logs/pidfiles/stats to\n" " -W|--work-dir DIR directory to cd and write logs/pidfiles/stats to\n"
" (if not specified, value of --images-dir is used)\n" " (if not specified, value of --images-dir is used)\n"
" --cpu-cap CAP require certain cpu capability. CAP: may be one of:\n"
" 'fpu','all'. To disable capability, prefix it with '^'.\n"
"\n" "\n"
"* Special resources support:\n" "* Special resources support:\n"
" -x|--" USK_EXT_PARAM " allow external unix connections\n" " -x|--" USK_EXT_PARAM " allow external unix connections\n"
......
...@@ -13,6 +13,12 @@ struct script { ...@@ -13,6 +13,12 @@ struct script {
#define SCRIPT_RPC_NOTIFY (char *)0x1 #define SCRIPT_RPC_NOTIFY (char *)0x1
/*
* CPU capability options.
*/
#define CPU_CAP_FPU (1u)
#define CPU_CAP_ALL (-1u)
struct cr_options { struct cr_options {
int final_state; int final_state;
char *show_dump_file; char *show_dump_file;
...@@ -40,6 +46,7 @@ struct cr_options { ...@@ -40,6 +46,7 @@ struct cr_options {
bool track_mem; bool track_mem;
char *img_parent; char *img_parent;
bool auto_dedup; bool auto_dedup;
unsigned int cpu_cap;
}; };
extern struct cr_options opts; extern struct cr_options opts;
......
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