]> git.pld-linux.org Git - packages/util-vserver.git/blob - util-vserver-cpuset.patch
- more features
[packages/util-vserver.git] / util-vserver-cpuset.patch
1 diff -ur util-vserver-0.30.209/scripts/vserver-setup.functions util-vserver-0.30.209.cpuset/scripts/vserver-setup.functions
2 --- util-vserver-0.30.209/scripts/vserver-setup.functions       2005-02-26 00:32:02.000000000 +0100
3 +++ util-vserver-0.30.209.cpuset/scripts/vserver-setup.functions        2005-11-25 15:11:30.224131360 +0100
4 @@ -24,11 +24,14 @@
5  SETUP_CONFDIR=
6  SETUP_CONTEXT=
7  SETUP_INITSTYLE=
8 +SETUP_CPUSET=
9 +SETUP_CPUSETCPUS=
10 +SETUP_CPUSETMEMS=
11  
12  declare -a SETUP_INTERFACES=()
13  declare -a SETUP_FLAGS=()
14  
15 -declare -r SETUP_OPTIONS="confdir:,lockfile:,hostname:,netdev:,netmask:,netprefix:,netbcast:,interface:,flags:,context:,initstyle:"
16 +declare -r SETUP_OPTIONS="confdir:,lockfile:,hostname:,netdev:,netmask:,netprefix:,netbcast:,interface:,flags:,context:,initstyle:,cpuset,cpusetcpus,cpusetmems:"
17  declare -r SETUP_HELPMSG=$"
18      --context   ...  the static context of the vserver [default: none; a dynamic
19                       context will be assumed]
20 @@ -55,6 +58,16 @@
21                             this becomes a per vserver limit)
22                      private: No other process can join this security context.
23                             Even root
24 +    --cpuset <name>
25 +               ...  declares the CPUSET this vserver will run in [default: none]
26 +    --cpusetcpus <number[-number][:<exclusive>]>
27 +               ...  sets which cpus belong to the CPUSET,
28 +                    exclusive is a flag (0|1) prohibiting any other cpuset from
29 +                    using those cpus
30 +    --cpusetmems <number[-number][:<exclusive>]>
31 +               ...  sets which memory pools belong to the CPUSET,
32 +                    exclusive is a flag (0|1) prohibiting any other cpuset from
33 +                    using those memory pools
34      --initstyle <style>
35                  ...  configures the initstyle (e.g. minit,sysv,plain)
36  "
37 @@ -72,6 +85,19 @@
38         (--netbcast)    SETUP_NETBCAST=$2;;
39         (--interface)   SETUP_INTERFACES=( "${SETUP_INTERFACES[@]}" "$2" );;
40         (--initstyle)   SETUP_INITSTYLE=$2;;
41 +       (--cpuset)      SETUP_CPUSET=$2;;
42 +       (--cpusetcpus)  old_IFS=$IFS
43 +                       IFS=:
44 +                       set -- $2
45 +                       SETUP_CPUSETCPUS=$1
46 +                       SETUP_CPUSETCPUSEXCL=$2
47 +                       IFS=$old_IFS
48 +                       ;;
49 +       (--cpusetmems)  old_IFS=$IFS
50 +                       IFS=:
51 +                       set -- $2
52 +                       SETUP_CPUSETMEMS=$1;;
53 +                       SETUP_CPUSETMEMSEXCL=$1;;
54         (--flags)       old_IFS=$IFS
55                         IFS=,
56                         set -- $2
57 @@ -140,7 +166,7 @@
58      local cfgdir=${SETUP_CONFDIR:?}
59      local i
60  
61 -    mkdir -p "$cfgdir"/interfaces "$cfgdir"/apps/init "$cfgdir"/uts
62 +    mkdir -p "$cfgdir"/interfaces "$cfgdir"/apps/init "$cfgdir"/uts "$cfgdir"/cpuset
63  
64      _setup_writeSingleOption "$name"            "$cfgdir"/name
65      _setup_writeSingleOption "$SETUP_CONTEXT"   "$cfgdir"/context
66 @@ -150,6 +176,11 @@
67      _setup_writeSingleOption "$SETUP_NETPREFIX" "$cfgdir"/interfaces/prefix
68      _setup_writeSingleOption "$SETUP_NETBCAST"  "$cfgdir"/interfaces/bcast
69      _setup_writeSingleOption "$SETUP_INITSTYLE" "$cfgdir"/apps/init/style
70 +    _setup_writeSingleOption "$SETUP_CPUSET"    "$cfgdir"/cpuset/name
71 +    _setup_writeSingleOption "$SETUP_CPUSETCPUS"     "$cfgdir"/cpuset/cpus
72 +    _setup_writeSingleOption "$SETUP_CPUSETCPUSEXCL" "$cfgdir"/cpuset/cpus_exclusive
73 +    _setup_writeSingleOption "$SETUP_CPUSETMEMS"     "$cfgdir"/cpuset/mems
74 +    _setup_writeSingleOption "$SETUP_CPUSETMEMSEXCL" "$cfgdir"/cpuset/mem_exclusive
75  
76      local idx=0
77      for i in "${SETUP_INTERFACES[@]}"; do
78 diff -ur util-vserver-0.30.209/scripts/vserver.functions util-vserver-0.30.209.cpuset/scripts/vserver.functions
79 --- util-vserver-0.30.209/scripts/vserver.functions     2005-11-25 14:30:27.665999880 +0100
80 +++ util-vserver-0.30.209.cpuset/scripts/vserver.functions      2005-11-25 15:11:04.593027880 +0100
81 @@ -687,6 +687,48 @@
82      fi
83  }
84  
85 +function addtoCPUSET
86 +{
87 +    local vdir=$1
88 +    local cpuset
89 +    local f="$vdir"/cpuset
90 +    local i
91 +
92 +    test -d "$f" || return 0
93 +    test -e "$f"/name || return 0
94 +
95 +    read cpuset < "$f"/name
96 +    test -e "$f"/nocreate || {
97 +       test -d /dev/cpuset/"$cpuset" || mkdir /dev/cpuset/"$cpuset"
98 +       for i in cpus mems cpu_exclusive mem_exclusive; do
99 +           test -e "$f"/"$i" && cat "$f"/"$i" > /dev/cpuset/"$cpuset"/"$i"
100 +       done
101 +    }
102 +
103 +    if [ -e /dev/cpuset/"$cpuset"/tasks ] ; then
104 +       echo $$ >/dev/cpuset/"$cpuset"/tasks
105 +    else
106 +       warning $"\
107 +WARNING: Failed to create or CPUSET \"$cpuset\" does not exist! Not using it!" >&2
108 +       return 0
109 +    fi
110 +}
111 +
112 +function removeCPUSET
113 +{
114 +    local vdir=$1
115 +    local cpuset
116 +    local f="$vdir"/cpuset
117 +
118 +    test -d "$f" || return 0
119 +    test -e "$f"/name || return 0
120 +
121 +    read cpuset < "$f"/name
122 +    test -e "$f"/nocreate || {
123 +       rmdir /dev/cpuset/"$cpuset"
124 +    }
125 +}
126 +
127  function _mountVserverInternal
128  {
129      local fstab="$1"
130 diff -ur util-vserver-0.30.209/scripts/vserver.start util-vserver-0.30.209.cpuset/scripts/vserver.start
131 --- util-vserver-0.30.209/scripts/vserver.start 2005-10-28 20:41:32.000000000 +0200
132 +++ util-vserver-0.30.209.cpuset/scripts/vserver.start  2005-11-25 14:30:14.958931648 +0100
133 @@ -111,6 +111,7 @@
134  
135  mountVserver "$VSERVER_DIR"     && is_mounted=1
136  prepareInit  "$VSERVER_DIR"
137 +addtoCPUSET  "$VSERVER_DIR"
138  
139  pushd "$VSERVER_DIR"/vdir/ >/dev/null
140  execScriptlets   "$VSERVER_DIR" "$VSERVER_NAME" pre-start
141 diff -ur util-vserver-0.30.209/scripts/vserver.stop util-vserver-0.30.209.cpuset/scripts/vserver.stop
142 --- util-vserver-0.30.209/scripts/vserver.stop  2005-10-29 17:35:43.000000000 +0200
143 +++ util-vserver-0.30.209.cpuset/scripts/vserver.stop   2005-11-25 15:12:23.679004984 +0100
144 @@ -99,3 +99,4 @@
145  disableInterfaces "$VSERVER_DIR"
146  
147  execScriptlets    "$VSERVER_DIR" "$VSERVER_NAME" postpost-stop
148 +removeCPUSET      "$VSERVER_DIR"
149 diff -ur util-vserver-0.30.209/scripts/vserver.suexec util-vserver-0.30.209.cpuset/scripts/vserver.suexec
150 --- util-vserver-0.30.209/scripts/vserver.suexec        2005-07-15 21:01:06.000000000 +0200
151 +++ util-vserver-0.30.209.cpuset/scripts/vserver.suexec 2005-11-25 14:30:14.958931648 +0100
152 @@ -22,6 +22,7 @@
153      exit 1
154  }
155  generateOptions  "$VSERVER_DIR"
156 +addtoCPUSET  "$VSERVER_DIR"
157  
158  user=$1
159  shift
This page took 0.115223 seconds and 4 git commands to generate.