]> git.pld-linux.org Git - packages/util-vserver.git/blob - util-vserver-cpuset.patch
- working
[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,21 @@
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=$2
54 +                       IFS=$old_IFS
55 +                       ;;
56         (--flags)       old_IFS=$IFS
57                         IFS=,
58                         set -- $2
59 @@ -140,7 +166,7 @@
60      local cfgdir=${SETUP_CONFDIR:?}
61      local i
62  
63 -    mkdir -p "$cfgdir"/interfaces "$cfgdir"/apps/init "$cfgdir"/uts
64 +    mkdir -p "$cfgdir"/interfaces "$cfgdir"/apps/init "$cfgdir"/uts "$cfgdir"/cpuset
65  
66      _setup_writeSingleOption "$name"            "$cfgdir"/name
67      _setup_writeSingleOption "$SETUP_CONTEXT"   "$cfgdir"/context
68 @@ -150,6 +176,11 @@
69      _setup_writeSingleOption "$SETUP_NETPREFIX" "$cfgdir"/interfaces/prefix
70      _setup_writeSingleOption "$SETUP_NETBCAST"  "$cfgdir"/interfaces/bcast
71      _setup_writeSingleOption "$SETUP_INITSTYLE" "$cfgdir"/apps/init/style
72 +    _setup_writeSingleOption "$SETUP_CPUSET"    "$cfgdir"/cpuset/name
73 +    _setup_writeSingleOption "$SETUP_CPUSETCPUS"     "$cfgdir"/cpuset/cpus
74 +    _setup_writeSingleOption "$SETUP_CPUSETCPUSEXCL" "$cfgdir"/cpuset/cpus_exclusive
75 +    _setup_writeSingleOption "$SETUP_CPUSETMEMS"     "$cfgdir"/cpuset/mems
76 +    _setup_writeSingleOption "$SETUP_CPUSETMEMSEXCL" "$cfgdir"/cpuset/mem_exclusive
77  
78      local idx=0
79      for i in "${SETUP_INTERFACES[@]}"; do
80 diff -ur util-vserver-0.30.209/scripts/vserver.functions util-vserver-0.30.209.cpuset/scripts/vserver.functions
81 --- util-vserver-0.30.209/scripts/vserver.functions     2005-11-25 14:30:27.665999880 +0100
82 +++ util-vserver-0.30.209.cpuset/scripts/vserver.functions      2005-11-25 15:11:04.593027880 +0100
83 @@ -687,6 +687,54 @@
84      fi
85  }
86  
87 +function addtoCPUSET
88 +{
89 +    local vdir=$1
90 +    local cpuset
91 +    local f="$vdir"/cpuset
92 +    local i
93 +    local v
94 +
95 +    test -d "$f" || return 0
96 +    test -e "$f"/name || return 0
97 +
98 +    read cpuset < "$f"/name
99 +    test -e "$f"/nocreate || {
100 +       test -d /dev/cpuset/"$cpuset" || mkdir /dev/cpuset/"$cpuset"
101 +       for i in cpus mems cpu_exclusive mem_exclusive; do
102 +           if test -e "$f"/"$i"; then
103 +               read v < "$f"/"$i"
104 +               echo $v >/dev/cpuset/"$cpuset"/"$i" || {
105 +                   rmdir /dev/cpuset/"$cpuset"
106 +                   break
107 +               }
108 +       done
109 +    }
110 +
111 +    if [ -e /dev/cpuset/"$cpuset"/tasks ] ; then
112 +       echo $$ >/dev/cpuset/"$cpuset"/tasks
113 +    else
114 +       warning $"\
115 +WARNING: Failed to create or CPUSET \"$cpuset\" does not exist! Not using it!" >&2
116 +       return 0
117 +    fi
118 +}
119 +
120 +function removeCPUSET
121 +{
122 +    local vdir=$1
123 +    local cpuset
124 +    local f="$vdir"/cpuset
125 +
126 +    test -d "$f" || return 0
127 +    test -e "$f"/name || return 0
128 +
129 +    read cpuset < "$f"/name
130 +    test -e "$f"/nocreate || {
131 +       rmdir /dev/cpuset/"$cpuset"
132 +    }
133 +}
134 +
135  function _mountVserverInternal
136  {
137      local fstab="$1"
138 diff -ur util-vserver-0.30.209/scripts/vserver.start util-vserver-0.30.209.cpuset/scripts/vserver.start
139 --- util-vserver-0.30.209/scripts/vserver.start 2005-10-28 20:41:32.000000000 +0200
140 +++ util-vserver-0.30.209.cpuset/scripts/vserver.start  2005-11-25 14:30:14.958931648 +0100
141 @@ -111,6 +111,7 @@
142  
143  mountVserver "$VSERVER_DIR"     && is_mounted=1
144  prepareInit  "$VSERVER_DIR"
145 +addtoCPUSET  "$VSERVER_DIR"
146  
147  pushd "$VSERVER_DIR"/vdir/ >/dev/null
148  execScriptlets   "$VSERVER_DIR" "$VSERVER_NAME" pre-start
149 diff -ur util-vserver-0.30.209/scripts/vserver.stop util-vserver-0.30.209.cpuset/scripts/vserver.stop
150 --- util-vserver-0.30.209/scripts/vserver.stop  2005-10-29 17:35:43.000000000 +0200
151 +++ util-vserver-0.30.209.cpuset/scripts/vserver.stop   2005-11-25 15:12:23.679004984 +0100
152 @@ -99,3 +99,4 @@
153  disableInterfaces "$VSERVER_DIR"
154  
155  execScriptlets    "$VSERVER_DIR" "$VSERVER_NAME" postpost-stop
156 +removeCPUSET      "$VSERVER_DIR"
157 diff -ur util-vserver-0.30.209/scripts/vserver.suexec util-vserver-0.30.209.cpuset/scripts/vserver.suexec
158 --- util-vserver-0.30.209/scripts/vserver.suexec        2005-07-15 21:01:06.000000000 +0200
159 +++ util-vserver-0.30.209.cpuset/scripts/vserver.suexec 2005-11-25 14:30:14.958931648 +0100
160 @@ -22,6 +22,7 @@
161      exit 1
162  }
163  generateOptions  "$VSERVER_DIR"
164 +addtoCPUSET  "$VSERVER_DIR"
165  
166  user=$1
167  shift
This page took 0.077858 seconds and 4 git commands to generate.