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:
committed by
Andrei Vagin
parent
9191f8728d
commit
bb555b3720
@@ -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
|
option is intended for post-copy (lazy) migration and should be
|
||||||
used in conjunction with *restore* with appropriate options.
|
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*
|
*restore*
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
Restores previously checkpointed processes.
|
Restores previously checkpointed processes.
|
||||||
@@ -576,6 +592,22 @@ are not adequate, but this can be suppressed by using *--cpu-cap=none*.
|
|||||||
restored process.
|
restored process.
|
||||||
This option requires running *lazy-pages* daemon.
|
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*
|
*check*
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
Checks whether the kernel supports the features needed by *criu* to
|
Checks whether the kernel supports the features needed by *criu* to
|
||||||
|
@@ -280,6 +280,7 @@ void init_opts(void)
|
|||||||
opts.status_fd = -1;
|
opts.status_fd = -1;
|
||||||
opts.log_level = DEFAULT_LOGLEVEL;
|
opts.log_level = DEFAULT_LOGLEVEL;
|
||||||
opts.pre_dump_mode = PRE_DUMP_SPLICE;
|
opts.pre_dump_mode = PRE_DUMP_SPLICE;
|
||||||
|
opts.file_validation_method = FILE_VALIDATION_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool deprecated_ok(char *what)
|
bool deprecated_ok(char *what)
|
||||||
@@ -420,6 +421,22 @@ static int parse_join_ns(const char *ptr)
|
|||||||
return 0;
|
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
|
* parse_options() is the point where the getopt parsing happens. The CLI
|
||||||
* parsing as well as the configuration file parsing happens here.
|
* 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},
|
{"tls-no-cn-verify", no_argument, &opts.tls_no_cn_verify, true},
|
||||||
{ "cgroup-yard", required_argument, 0, 1096 },
|
{ "cgroup-yard", required_argument, 0, 1096 },
|
||||||
{ "pre-dump-mode", required_argument, 0, 1097},
|
{ "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;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 1098:
|
||||||
|
if (parse_file_validation_method(&opts, optarg))
|
||||||
|
return 2;
|
||||||
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
pr_msg("Version: %s\n", CRIU_VERSION);
|
pr_msg("Version: %s\n", CRIU_VERSION);
|
||||||
if (strcmp(CRIU_GITID, "0"))
|
if (strcmp(CRIU_GITID, "0"))
|
||||||
|
@@ -437,6 +437,9 @@ usage:
|
|||||||
" Namespace can be specified as either pid or file path.\n"
|
" Namespace can be specified as either pid or file path.\n"
|
||||||
" OPTIONS can be used to specify parameters for userns:\n"
|
" OPTIONS can be used to specify parameters for userns:\n"
|
||||||
" user:PID,UID,GID\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"
|
"\n"
|
||||||
"Check options:\n"
|
"Check options:\n"
|
||||||
" Without options, \"criu check\" checks availability of absolutely required\n"
|
" Without options, \"criu check\" checks availability of absolutely required\n"
|
||||||
|
@@ -1632,7 +1632,8 @@ static bool store_validation_data(RegFileEntry *rfe,
|
|||||||
rfe->has_size = true;
|
rfe->has_size = true;
|
||||||
rfe->size = p->stat.st_size;
|
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)
|
if (result == -1)
|
||||||
return false;
|
return false;
|
||||||
@@ -2053,7 +2054,8 @@ static bool validate_file(const int fd, const struct stat *fd_status,
|
|||||||
return false;
|
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)
|
if (result == -1)
|
||||||
return false;
|
return false;
|
||||||
|
@@ -63,6 +63,24 @@ struct cg_root_opt {
|
|||||||
|
|
||||||
#define DEFAULT_TIMEOUT 10
|
#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;
|
||||||
|
|
||||||
struct irmap_path_opt {
|
struct irmap_path_opt {
|
||||||
@@ -153,6 +171,9 @@ struct cr_options {
|
|||||||
char *tls_key;
|
char *tls_key;
|
||||||
int tls;
|
int tls;
|
||||||
int tls_no_cn_verify;
|
int tls_no_cn_verify;
|
||||||
|
|
||||||
|
/* This stores which method to use for file validation. */
|
||||||
|
int file_validation_method;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct cr_options opts;
|
extern struct cr_options opts;
|
||||||
|
Reference in New Issue
Block a user