Allow searching for guests not with a specific mark.
[util-vserver.git] / scripts / vserver.functions
index b905968..228c70b 100644 (file)
@@ -112,7 +112,7 @@ function _generateChbindOptions
 
     test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$vdir"
 
-    if test -e "$vdir"/noncontext -o
+    if test -e "$vdir"/noncontext -o \
            \( -e "$vdir"/spaces/net -a ! -e "$vdir"/ncontext \); then
        _HAVE_CHBIND_OPTIONS=1
        return 0
@@ -804,7 +804,7 @@ function _generateSpaceOptions
            if test -z "$shared"; then
                OPTS_VSPACE=( "${OPTS_VSPACE[@]}" --$space )
            elif test "$shared" = "0"; then
-               # Do nothing
+               : # Do nothing
            else
                OPTS_VSPACE_SHARED=( "${OPTS_VSPACE_SHARED[@]}" --$space )
                VSPACE_SHARED_CMD=( "${VSPACE_SHARED_CMD[@]}" $_VSPACE --enter "$shared" --$space -- )
@@ -1475,8 +1475,12 @@ function useCgroup
 {
     hasCgroup || return 1
     test -d "$CGROUP_MNT" || return 1
+    memcg=""
+    if $_VSERVER_INFO - FEATURE memcg; then
+       memcg=1
+    fi
     test -d "$1/cgroup" -o \
-       \( -d "$__CONFDIR/.defaults/cgroup" -a \
+       \( \( -d "$__CONFDIR/.defaults/cgroup" -o -n "$memcg" \) -a \
           ! -e "$1/nocgroup" \)
 }
 
@@ -1492,9 +1496,8 @@ function _handleCgroup
     useCgroup "$vdir" || return 0
 
     findDir dir "$vdir/cgroup" "$__CONFDIR/.defaults/cgroup" ""
-    test -d "$dir" || return 0
 
-    if test -r "$dir"/name; then
+    if test -n "$dir" -a -r "$dir"/name; then
        read name < "$dir"/name
     else
        name="$VSERVER_NAME"
@@ -1509,13 +1512,15 @@ function _handleCgroup
                cat "$parent/$i" > "$CGROUP_MNT/$name/$i"
            done
 
-           shopt -s nullglob
-           for i in "$dir"/*; do
-               f="${i##*/}"
-               test "$f" != mnt -a "$f" != subsys -a \
-                   "$f" != inherit -a "$f" != name || continue
-               cat "$i" > "$CGROUP_MNT/$name/$f"
-           done
+           if test -n "$dir"; then
+               shopt -s nullglob
+               for i in "$dir"/*; do
+                   f="${i##*/}"
+                   test "$f" != mnt -a "$f" != subsys -a \
+                       "$f" != inherit -a "$f" != name || continue
+                   cat "$i" > "$CGROUP_MNT/$name/$f"
+               done
+           fi
        fi
        echo "$$" > "$CGROUP_MNT/$name/tasks"
     elif test "$action" = "destroy"; then