Commit f2bf4965 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

x86: cpu -- Use special bit for image manipulation

Current scheme of when to write and verify cpuinfo
images is unclear: we define default mode to 'fpu'
and this implies that no cpuinfo image get written
on dump and read on restore. In turn if 'cpu' or
'ins' mode specified in command line we write and
verify this image.

This is all wrong -- we need to produce image if
any mode ecxept 'none' is specified. The 'none'
mode is designed exactly for skipping cpuinfo
image production or verification.

Because any non-default mode requires explicit
--cpu-cap option to be passed we can use this
and setup new CPU_CAP_IMAGE telling criu to
write or read this image.

Note the default mode doesn't break backward
compatibility because by default we don't
write or read the image at all.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Reviewed-by: 's avatarDmitry Safonov <0x7f454c46@gmaill.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent ee478bed
...@@ -289,6 +289,7 @@ static int parse_cpu_cap(struct cr_options *opts, const char *optarg) ...@@ -289,6 +289,7 @@ static int parse_cpu_cap(struct cr_options *opts, const char *optarg)
if (!optarg) { if (!optarg) {
____cpu_set_cap(opts, CPU_CAP_ALL, false); ____cpu_set_cap(opts, CPU_CAP_ALL, false);
____cpu_set_cap(opts, CPU_CAP_IMAGE, false);
return 0; return 0;
} }
...@@ -324,6 +325,9 @@ static int parse_cpu_cap(struct cr_options *opts, const char *optarg) ...@@ -324,6 +325,9 @@ static int parse_cpu_cap(struct cr_options *opts, const char *optarg)
} else } else
goto Esyntax; goto Esyntax;
} }
if (opts->cpu_cap != CPU_CAP_NONE)
____cpu_set_cap(opts, CPU_CAP_IMAGE, false);
#undef ____cpu_set_cap #undef ____cpu_set_cap
return 0; return 0;
......
...@@ -1791,7 +1791,7 @@ int cr_dump_tasks(pid_t pid) ...@@ -1791,7 +1791,7 @@ int cr_dump_tasks(pid_t pid)
if (prepare_inventory(&he)) if (prepare_inventory(&he))
goto err; goto err;
if (opts.cpu_cap & (CPU_CAP_CPU | CPU_CAP_INS)) { if (opts.cpu_cap & CPU_CAP_IMAGE) {
if (cpu_dump_cpuinfo()) if (cpu_dump_cpuinfo())
goto err; goto err;
} }
......
...@@ -2364,7 +2364,7 @@ int cr_restore_tasks(void) ...@@ -2364,7 +2364,7 @@ int cr_restore_tasks(void)
if (vdso_init_restore()) if (vdso_init_restore())
goto err; goto err;
if (opts.cpu_cap & (CPU_CAP_INS | CPU_CAP_CPU)) { if (opts.cpu_cap & CPU_CAP_IMAGE) {
if (cpu_validate_cpuinfo()) if (cpu_validate_cpuinfo())
goto err; goto err;
} }
......
...@@ -511,8 +511,10 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -511,8 +511,10 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
goto err; goto err;
} }
if (req->has_cpu_cap) if (req->has_cpu_cap) {
opts.cpu_cap = req->cpu_cap; opts.cpu_cap = req->cpu_cap;
opts.cpu_cap |= CPU_CAP_IMAGE;
}
/* /*
* FIXME: For backward compatibility we setup * FIXME: For backward compatibility we setup
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#define CPU_CAP_FPU (1u << 0) /* Only FPU capability required */ #define CPU_CAP_FPU (1u << 0) /* Only FPU capability required */
#define CPU_CAP_CPU (1u << 1) /* Strict CPU capability required */ #define CPU_CAP_CPU (1u << 1) /* Strict CPU capability required */
#define CPU_CAP_INS (1u << 2) /* Instructions CPU capability */ #define CPU_CAP_INS (1u << 2) /* Instructions CPU capability */
#define CPU_CAP_IMAGE (1u << 3) /* Write capability on dump and read on restore*/
#define CPU_CAP_ALL (CPU_CAP_FPU | CPU_CAP_CPU | CPU_CAP_INS) #define CPU_CAP_ALL (CPU_CAP_FPU | CPU_CAP_CPU | CPU_CAP_INS)
#define CPU_CAP_DEFAULT (CPU_CAP_FPU) #define CPU_CAP_DEFAULT (CPU_CAP_FPU)
......
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