Move dynamic context generation to userspace.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Sat, 27 Jan 2007 11:10:09 +0000 (11:10 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Sat, 27 Jan 2007 11:10:09 +0000 (11:10 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2478 94cd875c-1c1d-0410-91d2-eb244daf1a30

contrib/manifest.dat.pathsubst
distrib/Makefile.am
distrib/misc/context.start [new file with mode: 0644]
doc/configuration.xml
scripts/vserver-setup.functions

index 4cb2b6c..78c5ee1 100644 (file)
@@ -45,6 +45,7 @@ base   @PKGLIBDIR@/defaults/vprocunhide-files
 base   @PKGLIBDIR@/defaults/environment
 build  @PKGLIBDIR@/defaults/fstab
 build  @PKGLIBDIR@/defaults/debootstrap.uri
+build  @PKGLIBDIR@/defaults/context.start
 @ENSC_HAVE_C99_COMPILER_TRUE@build  @PKGLIBDIR@/defaults/vunify-exclude
 base   @PKGLIBDIR@/capchroot
 base   @PKGLIBDIR@/chain-echo
index 8efb767..627c696 100644 (file)
@@ -26,7 +26,8 @@ defaults_DATA =               misc/debootstrap.uri \
                        misc/mtab \
                        misc/vprocunhide-files \
                        misc/vunify-exclude \
-                       misc/environment
+                       misc/environment \
+                       misc/context.start
 
 nobase_distrib_SCRIPTS =  redhat/initpost \
                           redhat/initpre \
diff --git a/distrib/misc/context.start b/distrib/misc/context.start
new file mode 100644 (file)
index 0000000..c5da56a
--- /dev/null
@@ -0,0 +1 @@
+40000
index 967e233..aad5b5e 100644 (file)
@@ -76,6 +76,20 @@ Contains the pathname of the shell which will be used by the "vserver
 The default fstab file to put in newly built guests.
       </description>
     </data>
+
+    <boolean name="context.dynamic">
+      <description>
+If this file exists, kernel-side dynamic contexts will be used by the "vserver
+... build" command. Otherwise a context will be generated, based on the
+contents of <optionref>context.next</optionref>.
+      </description>
+    </boolean>
+
+    <scalar id="context.next" name="context.next">
+      <description>
+The context id to use for the next guest created by "vserver ... build".
+      </description>
+    </scalar>
     
     <collection name="apps">
       <collection name="pkgmgmt">
index 3ff48f0..3996d68 100644 (file)
@@ -169,6 +169,18 @@ function setup_setDefaults
     findFile SETUP_FSTAB "$__CONFDIR"/.defaults/fstab "$__PKGLIBDEFAULTDIR"/fstab
 }
 
+function _setup_generateContext
+{
+    if test -z "$SETUP_CONTEXT" && test ! -e "$__CONFDIR/.defaults/context.dynamic"; then
+       if test -e "$__CONFDIR/.defaults/context.next"; then
+           SETUP_CONTEXT=`$_CAT "$__CONFDIR/.defaults/context.next"`
+       else
+           SETUP_CONTEXT=`$_CAT "$__PKGLIBDEFAULTDIR/context.start"`
+       fi
+       expr "$SETUP_CONTEXT" + 1 > "$__CONFDIR/.defaults/context.next"
+    fi
+}
+
 function setup_writeOption
 {
     local name=$1
@@ -177,6 +189,8 @@ function setup_writeOption
 
     mkdir -p "$cfgdir"/interfaces "$cfgdir"/apps/init "$cfgdir"/uts "$cfgdir"/cpuset
 
+    _setup_generateContext
+
     _setup_writeSingleOption "$name"            "$cfgdir"/name
     _setup_writeSingleOption "$SETUP_CONTEXT"   "$cfgdir"/context
     _setup_writeSingleOption "$SETUP_HOSTNAME"  "$cfgdir"/uts/nodename