From 93b6ce372f2e185af3cbb19d9c7620486f433496 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Mon, 15 Oct 2007 11:31:52 +0000 Subject: [PATCH 1/1] Add support for per-guest device maps. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2624 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- doc/configuration.xml | 29 ++++++++++++++++++++++++++++- gentoo/util-vserver | 2 +- scripts/vserver.functions | 10 ++++++---- scripts/vserver.start | 8 +++++--- scripts/vserver.stop | 4 +++- sysv/util-vserver | 2 +- 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/doc/configuration.xml b/doc/configuration.xml index 56a21ae..4e998be 100644 --- a/doc/configuration.xml +++ b/doc/configuration.xml @@ -785,7 +785,34 @@ pair per line. - + + + + 'x' is an arbitrary name, replace it with e.g. device names + + When this file exists, the device can be opened + + + When this file exists, the device can be created (if the guest has CAP_MKNOD) + + + +When this file exists, target will +have to exist as well and opening the device will in fact open the target device + + + + This file will let you specify unimplemented flags manually + + + Contains the name of a device node + + + Contains the device node of the target node to open instead of the device when remap is set + + + + 30 diff --git a/gentoo/util-vserver b/gentoo/util-vserver index c7ff359..94903cc 100644 --- a/gentoo/util-vserver +++ b/gentoo/util-vserver @@ -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 $? } diff --git a/scripts/vserver.functions b/scripts/vserver.functions index 0eab27e..e75c768 100644 --- a/scripts/vserver.functions +++ b/scripts/vserver.functions @@ -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 } diff --git a/scripts/vserver.start b/scripts/vserver.start index 3d32363..c47ac51 100644 --- a/scripts/vserver.start +++ b/scripts/vserver.start @@ -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 diff --git a/scripts/vserver.stop b/scripts/vserver.stop index 8ccea59..7f6cf2b 100644 --- a/scripts/vserver.stop +++ b/scripts/vserver.stop @@ -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" diff --git a/sysv/util-vserver b/sysv/util-vserver index fe0be29..957e12d 100755 --- a/sysv/util-vserver +++ b/sysv/util-vserver @@ -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 -- 1.8.1.5