mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
mem-snap: Redefine CLI options for mem snapshot
They are not documented, thus OK for now. Two options -- * one to specify where the parent images are * one to reset dirty memory tracking Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
13
crtools.c
13
crtools.c
@@ -113,8 +113,9 @@ int main(int argc, char *argv[])
|
||||
{ "page-server", no_argument, 0, 50},
|
||||
{ "address", required_argument, 0, 51},
|
||||
{ "port", required_argument, 0, 52},
|
||||
{ "snapshot", optional_argument, 0, 53},
|
||||
{ "prev-images-dir", required_argument, 0, 53},
|
||||
{ "ms", no_argument, 0, 54},
|
||||
{ "track-mem", no_argument, 0, 55},
|
||||
{ },
|
||||
};
|
||||
|
||||
@@ -262,8 +263,10 @@ int main(int argc, char *argv[])
|
||||
opts.handle_file_locks = true;
|
||||
break;
|
||||
case 53:
|
||||
opts.mem_snapshot = true;
|
||||
opts.snap_parent = optarg;
|
||||
opts.img_parent = optarg;
|
||||
break;
|
||||
case 55:
|
||||
opts.track_mem = true;
|
||||
break;
|
||||
case 54:
|
||||
opts.check_ms_kernel = true;
|
||||
@@ -287,8 +290,8 @@ int main(int argc, char *argv[])
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (opts.mem_snapshot)
|
||||
pr_info("Will do snapshot from %s\n", opts.snap_parent);
|
||||
if (opts.img_parent)
|
||||
pr_info("Will do snapshot from %s\n", opts.img_parent);
|
||||
|
||||
ret = open_image_dir();
|
||||
if (ret < 0) {
|
||||
|
4
image.c
4
image.c
@@ -332,8 +332,8 @@ int open_image_dir(void)
|
||||
|
||||
close(fd);
|
||||
|
||||
if (opts.snap_parent) {
|
||||
ret = symlink(opts.snap_parent, CR_PARENT_LINK);
|
||||
if (opts.img_parent) {
|
||||
ret = symlink(opts.img_parent, CR_PARENT_LINK);
|
||||
if (ret < 0) {
|
||||
pr_perror("Can't link parent snapshot.");
|
||||
goto err;
|
||||
|
@@ -119,8 +119,8 @@ struct cr_options {
|
||||
struct list_head scripts;
|
||||
bool use_page_server;
|
||||
struct sockaddr_in ps_addr;
|
||||
bool mem_snapshot;
|
||||
char *snap_parent;
|
||||
bool track_mem;
|
||||
char *img_parent;
|
||||
};
|
||||
|
||||
extern struct cr_options opts;
|
||||
|
17
mem.c
17
mem.c
@@ -45,9 +45,15 @@ static int task_reset_dirty_track(int pid)
|
||||
int fd, ret;
|
||||
char cmd[] = "4";
|
||||
|
||||
if (!opts.mem_snapshot)
|
||||
if (!opts.track_mem)
|
||||
return 0;
|
||||
|
||||
if (!kerndat_has_dirty_track) {
|
||||
pr_err("Kernel doesn't support dirty tracking. "
|
||||
"No snapshot available.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pr_info("Reset %d's dirty tracking\n", pid);
|
||||
fd = open_proc_rw(pid, "clear_refs");
|
||||
if (fd < 0)
|
||||
@@ -71,15 +77,6 @@ static struct mem_snap_ctx *mem_snap_init(struct parasite_ctl *ctl)
|
||||
int p_fd, pm_fd;
|
||||
PagemapHead *h;
|
||||
|
||||
if (!opts.mem_snapshot)
|
||||
return NULL;
|
||||
|
||||
if (!kerndat_has_dirty_track) {
|
||||
pr_err("Kernel doesn't support dirty tracking. "
|
||||
"No snapshot available.\n");
|
||||
return ERR_PTR(-1);
|
||||
}
|
||||
|
||||
p_fd = get_service_fd(PARENT_FD_OFF);
|
||||
if (p_fd < 0) {
|
||||
pr_debug("Will do full memory dump\n");
|
||||
|
@@ -40,13 +40,13 @@ for SNAP in $(seq 1 $NRSNAP); do
|
||||
mkdir "$IMGDIR/$SNAP/"
|
||||
if [ $SNAP -eq 1 ] ; then
|
||||
# First snapshot -- no parent, keep running
|
||||
args="--snapshot -R"
|
||||
args="--track-mem -R"
|
||||
elif [ $SNAP -eq $NRSNAP ]; then
|
||||
# Last snapshot -- has parent, kill afterwards
|
||||
args="--snapshot=../$((SNAP - 1))/"
|
||||
args="--prev-images-dir=../$((SNAP - 1))/"
|
||||
else
|
||||
# Other snapshots -- have parent, keep running
|
||||
args="--snapshot=../$((SNAP - 1))/ -R"
|
||||
args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R"
|
||||
fi
|
||||
|
||||
if [ $USEPS -eq 1 ]; then
|
||||
|
Reference in New Issue
Block a user