[Devel] [PATCH libvzctl] scripts: Save and restore missing VE properties

Cyrill Gorcunov gorcunov at virtuozzo.com
Fri May 6 02:42:49 PDT 2016


We already carry clock settings and AIO number, but
this is not enough: we've a number of additional
properties which are lost during c/r cycle.

Add them one per image. For this sake also drop
ve.pseudosuper lately, because for example OS
release virtualization feature requires VE
namespace to exist before writting anything
into ve.os_release.

https://jira.sw.ru/browse/PSBM-46811

Reported-by: Pavel Ganyushin <pganyushin at virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 scripts/vz-cpt.in        | 6 ++++++
 scripts/vz-rst-action.in | 7 ++++++-
 scripts/vz-rst.in        | 5 ++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/scripts/vz-cpt.in b/scripts/vz-cpt.in
index f79f665..d2319e8 100755
--- a/scripts/vz-cpt.in
+++ b/scripts/vz-cpt.in
@@ -50,6 +50,12 @@ function cg_dump_props {
 		# 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
+		# Netfilter mask
+		cgget -n -v -r ve.iptables_mask $VEID > $1/vz_iptables_mask.img
+		# OS version virtualization
+		cgget -n -v -r ve.os_release $VEID > $1/vz_os_release.img
+		# Features granted to VE
+		cgget -n -v -r ve.features $VEID > $1/vz_features.img
 		# AIO statistics
 		cgget -n -v -r ve.aio_max_nr $VEID > $1/vz_aio_max_nr.img
 	fi
diff --git a/scripts/vz-rst-action.in b/scripts/vz-rst-action.in
index be1a8d1..43c3142 100755
--- a/scripts/vz-rst-action.in
+++ b/scripts/vz-rst-action.in
@@ -70,13 +70,17 @@ case "$CRTOOLS_SCRIPT_ACTION" in
 	if [ -n "$VEID" ]; then
 		[ -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
+		[ -n "$VE_IPTABLES_MASK" ] && cgset -r ve.iptables_mask="$VE_IPTABLES_MASK" $VEID
+		[ -n "$VE_FEATURES" ] && cgset -r ve.features="$VE_FEATURES" $VEID
 		[ -n "$VE_AIO_MAX_NR" ] && cgset -r ve.aio_max_nr="$VE_AIO_MAX_NR" $VEID
  		cgset -r ve.state="START $pid" $VEID || exit
-		cgset -r ve.pseudosuper="0" $VEID
 	fi
 	;;
 "post-setup-namespaces")
 	restore_devices
+	if [ -n "$VEID" ]; then
+		[ -n "$VE_OS_RELEASE" ] && cgset -r ve.os_release="$VE_OS_RELEASE" $VEID
+	fi
 	;;
 "network-unlock")
 	ret=0
@@ -94,5 +98,6 @@ case "$CRTOOLS_SCRIPT_ACTION" in
 		[ -n "$VEID" ] && { cgexec -g ve:$VEID echo `cat $CRTOOLS_IMAGE_DIR/vz_core_pattern.img` \
 			> /proc/sys/kernel/core_pattern || { echo "Failed to restore core_pattern"; exit 1; } }
 	fi
+	[ -n "$VEID" ] && cgset -r ve.pseudosuper="0" $VEID
 	;;
 esac
diff --git a/scripts/vz-rst.in b/scripts/vz-rst.in
index da0126d..825a7c8 100755
--- a/scripts/vz-rst.in
+++ b/scripts/vz-rst.in
@@ -58,10 +58,13 @@ 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
+# Setup VE specific settings (cgroup interface)
 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`
+        export VE_IPTABLES_MASK=`cat $VE_DUMP_DIR/vz_iptables_mask.img`
+        export VE_OS_RELEASE=`cat $VE_DUMP_DIR/vz_os_release.img`
+        export VE_FEATURES=`cat $VE_DUMP_DIR/vz_features.img`
         export VE_AIO_MAX_NR=`cat $VE_DUMP_DIR/vz_aio_max_nr.img`
 fi
 
-- 
2.5.5



More information about the Devel mailing list