[Devel] [RFC libvzctl] Add ability to restore @real_start_timespec and @start_timespec
Cyrill Gorcunov
gorcunov at virtuozzo.com
Mon Feb 8 01:34:34 PST 2016
Guys, here is a problem I would like to discuss. For containers transparent
transition we've to make monotonic clocks to consider the delta the container
has been offline thus userspace applications won't notice the transition.
For this sake there is an interface via ve cgroup introduced (see
[PATCH rh7] ve: Add interface for @start_timespec and @real_start_timespec adjustmen).
The values must be saved somewhere and the written back on restore procedure.
So I read them and write then via scripts called by CRIU.
Would it be more-less convenient? Or there other options?
Cyrill
-------------- next part --------------
>From 86723e8d967a43662056005341da06a0864be0a1 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Thu, 4 Feb 2016 18:09:16 +0300
Subject: [PATCH] Add ability to restore @real_start_timespec and
@start_timespec
These two members of VE cgroup are PCS7 specific so instead of
squashing such change into CRIU (actually we've had a development
series of custom cgroup values dump/restore but it hasn't been
merged) we carry this setting inside ve.start_timespec and
ve.real_start_timespec files in $VE_DUMP_DIR.
On checkpoint time we read and save them, on restore -- write
them back.
https://jira.sw.ru/browse/PSBM-41406
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
lib/cr_criu.c | 4 +++-
scripts/vz-cpt.in | 5 +++++
scripts/vz-rst-action.in | 2 ++
scripts/vz-rst.in | 6 ++++++
4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/lib/cr_criu.c b/lib/cr_criu.c
index ed565b1..16bf036 100644
--- a/lib/cr_criu.c
+++ b/lib/cr_criu.c
@@ -73,7 +73,7 @@ static int do_dump(struct vzctl_env_handle *h, int cmd,
char buf[PATH_MAX];
char script[PATH_MAX];
char *arg[2];
- char *env[9];
+ char *env[10];
int ret, i = 0;
pid_t pid;
@@ -88,6 +88,8 @@ static int do_dump(struct vzctl_env_handle *h, int cmd,
get_dumpfile(h, param, path, sizeof(path));
logger(2, 0, "Store dump at %s", path);
+ snprintf(buf, sizeof(buf), "VEID=%s", EID(h));
+ env[i++] = strdup(buf);
snprintf(buf, sizeof(buf), "VE_DUMP_DIR=%s", path);
env[i++] = strdup(buf);
snprintf(buf, sizeof(buf), "VE_ROOT=%s", h->env_param->fs->ve_root);
diff --git a/scripts/vz-cpt.in b/scripts/vz-cpt.in
index dba290f..a060d03 100755
--- a/scripts/vz-cpt.in
+++ b/scripts/vz-cpt.in
@@ -60,5 +60,10 @@ if [ $? -ne 0 ]; then
exit 1
else
mv $dumpdir $VE_DUMP_DIR
+ if [ -n "$VEID" ]; then
+ # Save monotonic offsets for next restore
+ cgget -v -r ve.real_start_timespec $VEID | tail -n1 > $VE_DUMP_DIR/ve.real_start_timespec
+ cgget -v -r ve.start_timespec $VEID | tail -n1 > $VE_DUMP_DIR/ve.start_timespec
+ fi
echo Checkpointing finished successfully
fi
diff --git a/scripts/vz-rst-action.in b/scripts/vz-rst-action.in
index 56f60a9..cc60b2b 100755
--- a/scripts/vz-rst-action.in
+++ b/scripts/vz-rst-action.in
@@ -68,6 +68,8 @@ case "$CRTOOLS_SCRIPT_ACTION" in
ln -s /proc/$pid/ns/net $VE_NETNS_FILE
if [ -n "$VEID" ]; then
+ cgset -r ve.real_start_timespec="$VE_REAL_START_TIMESPEC" $VEID
+ cgset -r ve.start_timespec="$VE_START_TIMESPEC" $VEID
cgset -r ve.pseudosuper="0" $VEID
cgset -r ve.state="START $pid" $VEID || exit
fi
diff --git a/scripts/vz-rst.in b/scripts/vz-rst.in
index 78884da..1768042 100755
--- a/scripts/vz-rst.in
+++ b/scripts/vz-rst.in
@@ -57,6 +57,12 @@ extra_args_path="$VE_DUMP_DIR/restore-extra-args"
# Setup default work directory if not explicitly specified
[ -z "$VE_WORK_DIR" ] && VE_WORK_DIR="$VE_DUMP_DIR"
+# Setup monotonic offsets for clock adjustments
+if [ -n "$VEID" ]; then
+ export VE_REAL_START_TIMESPEC=`cat $VE_DUMP_DIR/ve.real_start_timespec`
+ export VE_START_TIMESPEC=`cat $VE_DUMP_DIR/ve.start_timespec`
+fi
+
# Setup default log name if not explicitly specified
[ -z "$VE_RESTORE_LOG_PATH" ] && VE_RESTORE_LOG_PATH="restore.log"
--
2.5.0
More information about the Devel
mailing list