From f5d5a2f7636afdb9eb9ae7d5a80b2aaf84d9b7af Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Fri, 31 Oct 2008 04:05:53 +0000 Subject: [PATCH] Move space creation/entering out of vc_ctx_{create,migrate}. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2814 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- lib/syscall_ctxcreate-v21.hc | 9 --------- lib/syscall_ctxmigrate-v21.hc | 8 -------- scripts/chcontext | 9 ++++++++- scripts/vserver.functions | 2 +- scripts/vserver.suexec | 2 ++ 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/lib/syscall_ctxcreate-v21.hc b/lib/syscall_ctxcreate-v21.hc index 3fb2f56..7cfec9f 100644 --- a/lib/syscall_ctxcreate-v21.hc +++ b/lib/syscall_ctxcreate-v21.hc @@ -19,7 +19,6 @@ #ifdef HAVE_CONFIG_H # include #endif -#include 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; } diff --git a/lib/syscall_ctxmigrate-v21.hc b/lib/syscall_ctxmigrate-v21.hc index 733987e..a972027 100644 --- a/lib/syscall_ctxmigrate-v21.hc +++ b/lib/syscall_ctxmigrate-v21.hc @@ -24,15 +24,7 @@ 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); } diff --git a/scripts/chcontext b/scripts/chcontext index 60df5fe..fda3e01 100755 --- a/scripts/chcontext +++ b/scripts/chcontext @@ -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[@]}" -- diff --git a/scripts/vserver.functions b/scripts/vserver.functions index a4dc8ed..b394f50 100644 --- a/scripts/vserver.functions +++ b/scripts/vserver.functions @@ -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=() diff --git a/scripts/vserver.suexec b/scripts/vserver.suexec index 02aeef2..c7dfa04 100644 --- a/scripts/vserver.suexec +++ b/scripts/vserver.suexec @@ -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 -- \ -- 1.8.1.5