2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

criu/config.c: added cli option for build-id

file_validation_method field added to cr_options structure in
"criu/include/cr_options.h" along with the constants:
FILE_VALIDATION_FILE_SIZE
FILE_VALIDATION_BUILD_ID
FILE_VALIDATION_DEFAULT (Equal to FILE_VALIDATION_BUILD_ID)

Usage and description information is yet to be added

Usage:
--file-validation="filesize" (To use only the file size check)
--file-validation="buildid" (To try and use only the build-id check)

Signed-off-by: Ajay Bharadwaj <ajayrbharadwaj@gmail.com>
This commit is contained in:
Ajay Bharadwaj
2020-06-26 16:31:47 +05:30
committed by Andrei Vagin
parent 9191f8728d
commit bb555b3720
5 changed files with 82 additions and 2 deletions

View File

@@ -400,6 +400,22 @@ By default the option is set to *fpu* and *ins*.
option is intended for post-copy (lazy) migration and should be
used in conjunction with *restore* with appropriate options.
*--file-validation* ['mode']::
Set the method to be used to validate open files. Validation is done
to ensure that the version of the file being restored is the same
version when it was dumped.
The 'mode' may be one of the following:
*filesize*:::
To explicitly use only the file size check all the time.
This is the fastest and least intensive check.
*buildid*:::
To validate ELF files with their build-ID. If the
build-ID cannot be obtained, 'chksm-first' method will be
used. This is the default if mode is unspecified.
*restore*
~~~~~~~~~
Restores previously checkpointed processes.
@@ -576,6 +592,22 @@ are not adequate, but this can be suppressed by using *--cpu-cap=none*.
restored process.
This option requires running *lazy-pages* daemon.
*--file-validation* ['mode']::
Set the method to be used to validate open files. Validation is done
to ensure that the version of the file being restored is the same
version when it was dumped.
The 'mode' may be one of the following:
*filesize*:::
To explicitly use only the file size check all the time.
This is the fastest and least intensive check.
*buildid*:::
To validate ELF files with their build-ID. If the
build-ID cannot be obtained, 'chksm-first' method will be
used. This is the default if mode is unspecified.
*check*
~~~~~~~
Checks whether the kernel supports the features needed by *criu* to

View File

@@ -280,6 +280,7 @@ void init_opts(void)
opts.status_fd = -1;
opts.log_level = DEFAULT_LOGLEVEL;
opts.pre_dump_mode = PRE_DUMP_SPLICE;
opts.file_validation_method = FILE_VALIDATION_DEFAULT;
}
bool deprecated_ok(char *what)
@@ -420,6 +421,22 @@ static int parse_join_ns(const char *ptr)
return 0;
}
static int parse_file_validation_method(struct cr_options *opts, const char *optarg)
{
if (!strcmp(optarg, "filesize"))
opts->file_validation_method = FILE_VALIDATION_FILE_SIZE;
else if (!strcmp(optarg, "buildid"))
opts->file_validation_method = FILE_VALIDATION_BUILD_ID;
else
goto Esyntax;
return 0;
Esyntax:
pr_err("Unknown file validation method `%s' selected\n", optarg);
return -1;
}
/*
* parse_options() is the point where the getopt parsing happens. The CLI
* parsing as well as the configuration file parsing happens here.
@@ -523,6 +540,7 @@ int parse_options(int argc, char **argv, bool *usage_error,
{"tls-no-cn-verify", no_argument, &opts.tls_no_cn_verify, true},
{ "cgroup-yard", required_argument, 0, 1096 },
{ "pre-dump-mode", required_argument, 0, 1097},
{ "file-validation", required_argument, 0, 1098 },
{ },
};
@@ -848,6 +866,10 @@ int parse_options(int argc, char **argv, bool *usage_error,
return 1;
}
break;
case 1098:
if (parse_file_validation_method(&opts, optarg))
return 2;
break;
case 'V':
pr_msg("Version: %s\n", CRIU_VERSION);
if (strcmp(CRIU_GITID, "0"))

View File

@@ -437,6 +437,9 @@ usage:
" Namespace can be specified as either pid or file path.\n"
" OPTIONS can be used to specify parameters for userns:\n"
" user:PID,UID,GID\n"
" --file-validation METHOD\n"
"pass the validation method to be used; argument\n"
"can be 'filesize' or 'buildid' (default).\n"
"\n"
"Check options:\n"
" Without options, \"criu check\" checks availability of absolutely required\n"

View File

@@ -1632,7 +1632,8 @@ static bool store_validation_data(RegFileEntry *rfe,
rfe->has_size = true;
rfe->size = p->stat.st_size;
result = store_validation_data_build_id(rfe, lfd, p);
if (opts.file_validation_method == FILE_VALIDATION_BUILD_ID)
result = store_validation_data_build_id(rfe, lfd, p);
if (result == -1)
return false;
@@ -2053,7 +2054,8 @@ static bool validate_file(const int fd, const struct stat *fd_status,
return false;
}
result = validate_with_build_id(fd, fd_status, rfi);
if (opts.file_validation_method == FILE_VALIDATION_BUILD_ID)
result = validate_with_build_id(fd, fd_status, rfi);
if (result == -1)
return false;

View File

@@ -63,6 +63,24 @@ struct cg_root_opt {
#define DEFAULT_TIMEOUT 10
enum FILE_VALIDATION_OPTIONS
{
/*
* This constant indicates that the file validation should be tried with the
* file size method by default.
*/
FILE_VALIDATION_FILE_SIZE,
/*
* This constant indicates that the file validation should be tried with the
* build-ID method by default.
*/
FILE_VALIDATION_BUILD_ID
};
/* This constant dictates which file validation method should be tried by default. */
#define FILE_VALIDATION_DEFAULT FILE_VALIDATION_BUILD_ID
struct irmap;
struct irmap_path_opt {
@@ -153,6 +171,9 @@ struct cr_options {
char *tls_key;
int tls;
int tls_no_cn_verify;
/* This stores which method to use for file validation. */
int file_validation_method;
};
extern struct cr_options opts;