[Devel] [PATCH libvzctl] scripts: vz_ -- Checkpoint and restore clock offsets
Cyrill Gorcunov
gorcunov at virtuozzo.com
Tue Apr 5 02:05:17 PDT 2016
To make transition of containers between nodes shoveless
we provide offsets for monotonic clocks. The kernel
use these values to zap the time difference between nodes
when setups timers. So that we need to save these values
somewhere in images and set them up back on restore procedure.
Ideally this should be implemened via CRIU directly with
custom cgroups properties engine but until done we may
carry the settings with libvzctl directly, just like
we do for coredump patterns.
Thus -- checkpoint @ve.clock_bootbased and @ve.clock_monotonic
properties into image and restore them back.
https://jira.sw.ru/browse/PSBM-41406
https://jira.sw.ru/browse/PSBM-45631
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
scripts/vz-cpt.in | 10 ++++++++++
scripts/vz-rst-action.in | 4 +++-
scripts/vz-rst.in | 6 ++++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/scripts/vz-cpt.in b/scripts/vz-cpt.in
index 44982e1..8ecb33b 100755
--- a/scripts/vz-cpt.in
+++ b/scripts/vz-cpt.in
@@ -45,7 +45,17 @@ done
# simply increase the number of file descriptors allowed.
ulimit -n 8192
+function cg_dump_props {
+ if [ -n "$VEID" ]; then
+ # Save monotonic offsets for next restore
+ cgget -n -v -r ve.clock_bootbased $VEID > $1/vz_clock_bootbased.img
+ cgget -n -v -r ve.clock_monotonic $VEID > $1/vz_clock_monotonic.img
+ fi
+ return 0
+}
+
mkdir -p $dumpdir &&
+cg_dump_props $dumpdir &&
criu dump -vvvv -o dump.log \
--file-locks \
--tcp-established \
diff --git a/scripts/vz-rst-action.in b/scripts/vz-rst-action.in
index 4083b88..8c7f9b2 100755
--- a/scripts/vz-rst-action.in
+++ b/scripts/vz-rst-action.in
@@ -68,7 +68,9 @@ case "$CRTOOLS_SCRIPT_ACTION" in
ln -s /proc/$pid/ns/net $VE_NETNS_FILE
if [ -n "$VEID" ]; then
- cgset -r ve.state="START $pid" $VEID || exit
+ [ -n "$VE_CLOCK_BOOTBASED" ] && cgset -r ve.clock_bootbased="$VE_CLOCK_BOOTBASED" $VEID
+ [ -n "$VE_CLOCK_MONOTONIC" ] && cgset -r ve.clock_monotonic="$VE_CLOCK_MONOTONIC" $VEID
+ cgset -r ve.state="START $pid" $VEID || exit
cgset -r ve.pseudosuper="0" $VEID
fi
;;
diff --git a/scripts/vz-rst.in b/scripts/vz-rst.in
index 78884da..9ef5c56 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_CLOCK_BOOTBASED=`cat $VE_DUMP_DIR/vz_clock_bootbased.img`
+ export VE_CLOCK_MONOTONIC=`cat $VE_DUMP_DIR/vz_clock_monotonic.img`
+fi
+
# Setup default log name if not explicitly specified
[ -z "$VE_RESTORE_LOG_PATH" ] && VE_RESTORE_LOG_PATH="restore.log"
--
2.5.5
More information about the Devel
mailing list