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