Add support for per-guest device maps.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Mon, 15 Oct 2007 11:31:52 +0000 (11:31 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Mon, 15 Oct 2007 11:31:52 +0000 (11:31 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2624 94cd875c-1c1d-0410-91d2-eb244daf1a30

doc/configuration.xml
gentoo/util-vserver
scripts/vserver.functions
scripts/vserver.start
scripts/vserver.stop
sysv/util-vserver

index 56a21ae..4e998be 100644 (file)
@@ -785,7 +785,34 @@ pair per line.
          </description>
        </hash>
       </collection>
-      
+
+      <collection name="vdevmap">
+        <collection name="x" type="sybmolic">
+          <description>'x' is an arbitrary name, replace it with e.g. device names</description>
+          <boolean name="open">
+            <description>When this file exists, the device can be opened</description>
+          </boolean>
+          <boolean name="create">
+            <description>When this file exists, the device can be created (if the guest has <optionref ref="bcapabilities">CAP_MKNOD</optionref>)</description>
+          </boolean>
+          <boolean id="guest-vdevmap-remap" name="remap">
+            <description>
+When this file exists, <optionref ref="guest-vdevmap-target">target</optionref> will
+have to exist as well and opening the device will in fact open the target device
+            </description>
+          </boolean>
+          <scalar name="flags">
+            <description>This file will let you specify unimplemented flags manually</description>
+          </scalar>
+          <scalar name="device">
+            <description>Contains the name of a device node</description>
+          </scalar>
+          <scalar id="guest-vdevmap-target" name="target">
+            <description>Contains the device node of the target node to open instead of the device when <optionref ref="guest-vdevmap-remap">remap</optionref> is set</description>
+          </scalar>
+        </collection>
+      </collection>
+  
       <collection name="vshelper">
        <scalar name="sync-timeout">
          <default>30</default>
index c7ff359..94903cc 100644 (file)
@@ -42,7 +42,7 @@ start() {
        eend $?
 
        ebegin "Loading default device map"
-       $__PKGLIBDIR/bash-wrapper 'loadDeviceMap 0 "$__CONFDIR/.defaults/apps/vdevmap"'
+       $__PKGLIBDIR/bash-wrapper 'handleDeviceMap --set 0 "$__CONFDIR/.defaults/apps/vdevmap"'
        eend $?
 }
 
index 0eab27e..e75c768 100644 (file)
@@ -1282,13 +1282,15 @@ function _namespaceCleanup
     done
 }
 
-function loadDeviceMap
+function handleDeviceMap
 {
-    local xid="$1"
-    local dir="$2"
+    local op="$1"
+    local xid="$2"
+    local dir="$3"
     local flags device target
 
     test -d "$dir" || return 0
+    test -n "$xid" || return 0
 
     for i in "$dir"/*; do
        test -d "$i" || continue
@@ -1304,6 +1306,6 @@ function loadDeviceMap
        vdevmap_opts=(  "${vdevmap_opts[@]}" ${flags:+--flags "$flags"} \
                        ${device:+--device "$device"} ${target:+--target "$target"} )
 
-       $_VDEVMAP --xid "$xid" --set "${vdevmap_opts[@]}" || return $?
+       $_VDEVMAP --xid "$xid" "$op" "${vdevmap_opts[@]}" || return $?
     done
 }
index 3d32363..c47ac51 100644 (file)
@@ -118,9 +118,11 @@ setDiskLimits    "$VSERVER_DIR"
 
 enableInterfaces "$VSERVER_DIR" && have_interfaces=1
 
-mountVserver "$VSERVER_DIR"     && is_mounted=1
-prepareInit  "$VSERVER_DIR"
-addtoCPUSET  "$VSERVER_DIR"
+mountVserver     "$VSERVER_DIR" && is_mounted=1
+prepareInit      "$VSERVER_DIR"
+addtoCPUSET      "$VSERVER_DIR"
+
+handleDeviceMap --set "$S_CONTEXT" "$VSERVER_DIR/apps/vdevmap"
 
 pushd "$VSERVER_DIR"/vdir/ >/dev/null
 execScriptlets   "$VSERVER_DIR" "$VSERVER_NAME" pre-start
index 8ccea59..7f6cf2b 100644 (file)
@@ -103,7 +103,9 @@ sendKillSequence   "$S_CONTEXT" "${INITKILL_SEQ[@]}"
     echo $"Vserver '$VSERVER_DIR' still running unexpectedly; please investigate it manually..." >&2
 
 execScriptlets    "$VSERVER_DIR" "$VSERVER_NAME" post-stop
-    
+
+handleDeviceMap --unset "$S_CONTEXT" "$VSERVER_DIR/apps/vdevmap"
+
 umountVserver     "$VSERVER_DIR" || :
 disableInterfaces "$VSERVER_DIR"
 
index fe0be29..957e12d 100755 (executable)
@@ -62,7 +62,7 @@ function start()
     _endResult $?
     local retval=$?
     _beginResult $"Loading default device map"
-    loadDeviceMap 0 "$__CONFDIR/.defaults/apps/vdevmap"
+    handleDeviceMap --set 0 "$__CONFDIR/.defaults/apps/vdevmap"
     _endResult $?
     test "$retval" -ne 0 || touch "$lockfile"
     return $retval