Add support for the OOM bias in the configuration.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Sat, 13 Oct 2007 14:17:48 +0000 (14:17 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Sat, 13 Oct 2007 14:17:48 +0000 (14:17 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2620 94cd875c-1c1d-0410-91d2-eb244daf1a30

doc/configuration.xml
scripts/vserver.functions
scripts/vserver.start

index 5702e5c..474b4ce 100644 (file)
@@ -666,6 +666,11 @@ called as <command>chbind &lt;options&gt; mount ...</command>. See
 <optionref>fstab</optionref> also.
       </description>
     </data>
+    <scalar name="badness">
+      <description>
+Contains the bias to be applied to processes in this guest when the OOM-killer strikes.
+      </description>
+    </scalar>
     
     <collection name="apps">
       <collection name="init">
index 776e487..0eab27e 100644 (file)
@@ -45,6 +45,7 @@ declare -a OPTS_VSCHED=()
 declare -a OPTS_ENV=()
 declare -a OPTS_VTAG_CREATE=()
 declare -a OPTS_VTAG_ENTER=()
+declare -a OPTS_VMEMCTRL=()
 
 declare -a STOPCMD_PREPARE=()
 
@@ -606,18 +607,6 @@ function _generateInterfaceOptions
     _HAVE_INTERFACE_OPTIONS=1
 }
 
-function _generateTagOptions
-{
-    local vdir="$1"
-    local tag
-
-    getFileValue tag "$vdir/tag" "$vdir/context"
-    test -n "$tag" || return 0
-
-    OPTS_VTAG_CREATE=( --tag "$tag" )
-    OPTS_VTAG_ENTER=( --tag "$tag" )
-}
-
 function enableInterfaces
 {
     local i=0
@@ -688,6 +677,29 @@ function disableInterfaces
     unlock 1
 }
 
+function _generateTagOptions
+{
+    local vdir="$1"
+    local tag
+
+    getFileValue tag "$vdir/tag" "$vdir/context"
+    test -n "$tag" || return 0
+
+    OPTS_VTAG_CREATE=( --tag "$tag" )
+    OPTS_VTAG_ENTER=( --tag "$tag" )
+}
+
+function _generateMemctrlOptions
+{
+    local vdir="$"
+    local badness
+
+    getFileValue badness "$vdir/badness"
+    test -n "$badness" || return 0
+
+    OPTS_VMEMCTRL=( --badness "$badness" )
+}
+
 ## Usage: prepareInit <vserver-directory>
 function prepareInit
 {
@@ -732,6 +744,7 @@ function generateOptions
     _generateScheduleOptions    "$1"
     _generatePersonalityOptions "$1"
     _generateTagOptions         "$1"
+    _generateMemctrlOptions     "$1"
 
     if test -n "$_IS_FAKEINIT"; then
        CHCONTEXT_INIT_OPTS=( --disconnect --flag fakeinit )
index 1656df0..3d32363 100644 (file)
@@ -142,6 +142,7 @@ if $_VSERVER_INFO - FEATURE migrate; then
     $_VSCHED     --xid self --force "${OPTS_VSCHED[@]}" -- \
     $_VSYSCTL    --xid self --dir "$VSERVER_DIR"/sysctl --missingok -- \
     $_VUNAME     --xid self --dir "$VSERVER_DIR"/uts    --missingok -- \
+    $_VMEMCTRL   --xid self "${OPTS_VMEMCTRL[@]}" -- \
     "${VSERVER_EXTRA_CMDS[@]}" \
     $_VUNAME     --xid self --set -t context="$VSERVER_DIR" -- \
     $_VATTRIBUTE --set "${OPTS_VATTRIBUTE[@]}" -- \