Add new 0x00020303 API, using pid namespaces.
[util-vserver.git] / scripts / vserver.functions
index a11cd90..238c4b8 100644 (file)
@@ -20,6 +20,7 @@
 #  $VSERVER_NAME  ... name of vserver
 
 declare -a NICE_CMD=()
+declare -a IONICE_CMD=()
 declare -a CHBIND_CMD=()
 declare -a CAP_OPTS=()
 declare -a CHCONTEXT_INIT_OPTS=()
@@ -135,6 +136,17 @@ function _generateNiceCommand
     NICE_CMD=( $_NICE -n $nice )
 }
 
+function _generateIONiceCommand
+{
+    local vdir=$1
+    local ionice_class=2
+    local ionice_priority=0
+
+    test -r "$vdir/ionice/class" && read ionice_class <"$vdir"/ionice/class
+    test -r "$vdir/ionice/priority" && read ionice_priority <"$vdir"/ionice/priority
+
+    IONICE_CMD=( $_IONICE -c$ionice_class -n$ionice_priority )
+}
 
 function _generatePersonalityOptions
 {
@@ -757,8 +769,7 @@ function _generateSpaceOptions
     local vdir="$1"
     local d="$vdir"/spaces
 
-    ( test ! -e "$d"/pid &&
-      ! $_VSERVER_INFO PIDSPACE FEATURE ) || \
+    ( test ! -e "$d"/pid ) || \
        OPTS_VSPACE=( "${OPTS_VSPACE[@]}" --pid )
 
     test ! -e "$d"/net || {
@@ -812,6 +823,7 @@ function generateOptions
     _generateInterfaceOptions   "$1"
     test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1" 
     _generateNiceCommand        "$1"
+    _generateIONiceCommand     "$1"
     _generateInitOptions        "$1"
     _generateChcontextOptions   "$1"
     _generateScheduleOptions    "$1"
@@ -1352,7 +1364,7 @@ function _namespaceCleanup
     done < /proc/mounts
     # separate loop to avoid races while reading /proc/mounts
     for i in "${list_umount[@]}"; do
-       $_UMOUNT -l -n "$i"
+       $_UMOUNT -l -n -i "$i"
     done
 }