Commit ba0d5fb2 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

dump: handle overmounted devices (v2)

"init" in LXC opens /dev/null and then mounts devtmpfs in /dev,
so crtools can not resolve the path to the origin /dev/null.

crtools with the option --evasive-devices will check the origin
device and a new device are the same and if it's true, crtools will
dump a new path.

v2: add a description for the option
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8de04347
...@@ -88,6 +88,7 @@ int main(int argc, char *argv[]) ...@@ -88,6 +88,7 @@ int main(int argc, char *argv[])
{ "close", required_argument, 0, 43 }, { "close", required_argument, 0, 43 },
{ "log-pid", no_argument, 0, 44}, { "log-pid", no_argument, 0, 44},
{ "version", no_argument, 0, 'V'}, { "version", no_argument, 0, 'V'},
{ "evasive-devices", no_argument, 0, 45},
{ }, { },
}; };
...@@ -165,6 +166,9 @@ int main(int argc, char *argv[]) ...@@ -165,6 +166,9 @@ int main(int argc, char *argv[])
case 44: case 44:
opts.log_file_per_pid = 1; opts.log_file_per_pid = 1;
break; break;
case 45:
opts.evasive_devices = true;
break;
case 'V': case 'V':
pr_msg("Version: %d.%d\n", CRIU_VERSION_MAJOR, CRIU_VERSION_MINOR); pr_msg("Version: %d.%d\n", CRIU_VERSION_MAJOR, CRIU_VERSION_MINOR);
return 0; return 0;
...@@ -252,6 +256,7 @@ usage: ...@@ -252,6 +256,7 @@ usage:
pr_msg(" -x|--ext-unix-sk allow external unix connections\n"); pr_msg(" -x|--ext-unix-sk allow external unix connections\n");
pr_msg(" --%s checkpoint/restore established TCP connections\n", SK_EST_PARAM); pr_msg(" --%s checkpoint/restore established TCP connections\n", SK_EST_PARAM);
pr_msg(" -r|--root [PATH] change the root filesystem (when run in mount namespace)\n"); pr_msg(" -r|--root [PATH] change the root filesystem (when run in mount namespace)\n");
pr_msg(" --evasive-devices use any path to a device file if the original one is inaccessible\n");
pr_msg("\n* Logging:\n"); pr_msg("\n* Logging:\n");
pr_msg(" -o|--log-file [NAME] log file name (relative path is relative to --images-dir)\n"); pr_msg(" -o|--log-file [NAME] log file name (relative path is relative to --images-dir)\n");
......
...@@ -285,6 +285,10 @@ static int check_path_remap(char *rpath, const struct stat *ost, int lfd, u32 id ...@@ -285,6 +285,10 @@ static int check_path_remap(char *rpath, const struct stat *ost, int lfd, u32 id
} }
if ((pst.st_ino != ost->st_ino) || (pst.st_dev != ost->st_dev)) { if ((pst.st_ino != ost->st_ino) || (pst.st_dev != ost->st_dev)) {
if (opts.evasive_devices &&
(S_ISCHR(ost->st_mode) || S_ISBLK(ost->st_mode)) &&
pst.st_rdev == ost->st_rdev)
return 0;
/* /*
* FIXME linked file, but the name we see it by is reused * FIXME linked file, but the name we see it by is reused
* by somebody else. * by somebody else.
......
...@@ -84,6 +84,7 @@ struct cr_options { ...@@ -84,6 +84,7 @@ struct cr_options {
bool restore_detach; bool restore_detach;
bool ext_unix_sk; bool ext_unix_sk;
bool tcp_established_ok; bool tcp_established_ok;
bool evasive_devices;
unsigned int namespaces_flags; unsigned int namespaces_flags;
bool log_file_per_pid; bool log_file_per_pid;
char *output; char *output;
......
...@@ -174,7 +174,7 @@ run_test() ...@@ -174,7 +174,7 @@ run_test()
echo Dump $PID echo Dump $PID
mkdir -p $ddump mkdir -p $ddump
save_fds $PID $ddump/dump.fd save_fds $PID $ddump/dump.fd
setsid $CRTOOLS dump -D $ddump -o dump.log -v 4 -t $PID $args $ARGS || { setsid $CRTOOLS dump --evasive-devices -D $ddump -o dump.log -v 4 -t $PID $args $ARGS || {
echo WARNING: process $tname is left running for your debugging needs echo WARNING: process $tname is left running for your debugging needs
return 1 return 1
} }
......
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