Move space creation/entering out of vc_ctx_{create,migrate}.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Fri, 31 Oct 2008 04:05:53 +0000 (04:05 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Fri, 31 Oct 2008 04:05:53 +0000 (04:05 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2814 94cd875c-1c1d-0410-91d2-eb244daf1a30

lib/syscall_ctxcreate-v21.hc
lib/syscall_ctxmigrate-v21.hc
scripts/chcontext
scripts/vserver.functions
scripts/vserver.suexec

index 3fb2f56..7cfec9f 100644 (file)
@@ -19,7 +19,6 @@
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
-#include <lib_internal/sys_unshare.h>
 
 static inline ALWAYSINLINE xid_t
 vc_ctx_create_v21(xid_t xid, struct vc_ctx_flags *flags)
@@ -36,13 +35,5 @@ vc_ctx_create_v21(xid_t xid, struct vc_ctx_flags *flags)
   res = vserver(VCMD_ctx_create_v1, CTX_USER2KERNEL(xid), &data);
   res = CTX_KERNEL2USER(res);
 
-  if (res != VC_NOCTX) {
-    if (utilvserver_checkCompatConfig() & VC_VCI_SPACES) {
-      uint32_t spaces = vc_get_space_mask() & ~(CLONE_NEWNS|CLONE_FS);
-      sys_unshare(spaces);
-      vc_set_namespace(VC_SAMECTX, spaces);
-    }
-  }
-
   return res;
 }
index 733987e..a972027 100644 (file)
 static inline ALWAYSINLINE int
 vc_ctx_migrate_spaces(xid_t xid, uint_least64_t flags)
 {
-  int ret;
   struct vcmd_ctx_migrate data = { .flagword = flags };
 
-  ret = vc_getXIDType(xid);
-  if (ret == vcTYPE_STATIC || ret == vcTYPE_DYNAMIC) {
-    ret = vc_enter_namespace(xid, vc_get_space_mask() & ~(CLONE_NEWNS|CLONE_FS));
-    if (ret)
-      return ret;
-  }
-
   return vserver(VCMD_ctx_migrate_v1, CTX_USER2KERNEL(xid), &data);
 }
index 60df5fe..fda3e01 100755 (executable)
@@ -101,7 +101,7 @@ the GNU General Public License.  This program has absolutely no warranty."
 
 $_VSERVER_INFO - FEATURE migrate || exec $_CHCONTEXT_COMPAT "$@"
 
-tmp=$(getopt -o + --long cap:,ctx:,xid:,disconnect,domainname:,flag:,hostname:,secure,silent,help,version -n "$0" -- "$@") || exit 1
+tmp=$(getopt -o + --long cap:,ctx:,xid:,disconnect,domainname:,flag:,hostname:,secure,silent,help,version,spaces: -n "$0" -- "$@") || exit 1
 eval set -- "$tmp"
 
 OPT_CAPS=()
@@ -111,6 +111,7 @@ OPT_FLAGS=()
 OPT_SECURE=
 OPT_SILENT=
 OPT_INITPID=
+OPT_SPACES=--default
 
 while true; do
     case "$1" in
@@ -128,6 +129,7 @@ while true; do
            ;;
        --secure)       OPT_SECURE=1;;
        --silent)       OPT_SILENT=1;;
+       --spaces)       OPT_SPACES=$2; shift;;
        --)             shift; break;;
        *)              echo $"chcontext: internal error; arg=='$1'" >&2; exit 1;;
     esac
@@ -135,6 +137,7 @@ while true; do
 done
 
 create_cmd=( ${OPT_CTX:+$_VTAG --create --tag "$OPT_CTX" --silentexist --silent --}
+            $_VSPACE --new $OPT_SPACES --
             $_VCONTEXT --create --silentexist
             ${OPT_SILENT:+--silent}
             ${OPT_CTX:+--xid "$OPT_CTX"} )
@@ -144,6 +147,10 @@ chain_cmd=()
 old_IFS=$IFS
 IFS=,$IFS
 
+chain_cmd=( "${chain_cmd[@]}"
+               --
+               $_VSPACE --set $OPT_SPACES )
+
 test -z "$OPT_DOMAINNAME$OPT_HOSTNAME" || \
     chain_cmd=( "${chain_cmd[@]}"
                --
index a4dc8ed..b394f50 100644 (file)
@@ -47,7 +47,7 @@ declare -a OPTS_ENV=()
 declare -a OPTS_VTAG_CREATE=()
 declare -a OPTS_VTAG_ENTER=()
 declare -a OPTS_VMEMCTRL=()
-declare -a OPTS_VSPACE=()
+declare -a OPTS_VSPACE=( --default )
 
 declare -a STOPCMD_PREPARE=()
 
index 02aeef2..c7dfa04 100644 (file)
@@ -51,7 +51,9 @@ if $_VSERVER_INFO - FEATURE migrate; then
        "${CHBIND_CMD[@]}" \
        $_EXEC_ULIMIT "$VSERVER_DIR/ulimits" \
        $_VTAG --create "${OPTS_VTAG_CREATE[@]}" --silent -- \
+       $_VSPACE --new "${OPTS_VSPACE[@]}" -- \
         $_VCONTEXT --create "${OPTS_VCONTEXT_CREATE[@]}" -- \
+       $_VSPACE --set "${OPTS_VSPACE[@]}" -- \
        $_VUNAME   --xid self --dir "$VSERVER_DIR"/uts     --missingok -- \
        $_VUNAME   --xid self --set -t context="$VSERVER_DIR" -- \
        $_VCONTEXT --migrate-self --endsetup --chroot $SILENT_OPT -- \