]> git.pld-linux.org Git - packages/util-vserver.git/blob - util-vserver-cpuset.patch
- info about virtualization availability
[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,15 @@
5  SETUP_CONFDIR=
6  SETUP_CONTEXT=
7  SETUP_INITSTYLE=
8 +SETUP_CPUSET=
9 +SETUP_CPUSETCPUS=
10 +SETUP_CPUSETMEMS=
11 +SETUP_CPUSETVIRT=
12  
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:"
17 +declare -r SETUP_OPTIONS="confdir:,lockfile:,hostname:,netdev:,netmask:,netprefix:,netbcast:,interface:,flags:,context:,initstyle:,cpuset:,cpusetcpus:,cpusetmems:,cpusetvirt"
18  declare -r SETUP_HELPMSG=$"
19      --context   ...  the static context of the vserver [default: none; a dynamic
20                       context will be assumed]
21 @@ -55,6 +58,19 @@
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]
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
35 +    --cpusetvirt
36 +               ...  virtualize cpuset (guest will see only CPUs defined in cpuset)
37 +                    Requires kernel patch from http://www.bullopensource.org/cpuset/
38      --initstyle <style>
39                  ...  configures the initstyle (e.g. minit,sysv,plain)
40  "
41 @@ -72,6 +85,22 @@
42         (--netbcast)    SETUP_NETBCAST=$2;;
43         (--interface)   SETUP_INTERFACES=( "${SETUP_INTERFACES[@]}" "$2" );;
44         (--initstyle)   SETUP_INITSTYLE=$2;;
45 +       (--cpuset)      SETUP_CPUSET=$2;;
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
56 +                       SETUP_CPUSETMEMS=$1
57 +                       SETUP_CPUSETMEMSEXCL=$2
58 +                       IFS=$old_IFS
59 +                       ;;
60 +       (--cpusetvirt)  SETUP_CPUSETVIRT=1;;
61         (--flags)       old_IFS=$IFS
62                         IFS=,
63                         set -- $2
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
73 @@ -150,6 +176,12 @@
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
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
82 +    _setup_writeSingleOption "$SETUP_CPUSETVIRT"     "$cfgdir"/cpuset/virtualized
83  
84      local idx=0
85      for i in "${SETUP_INTERFACES[@]}"; do
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
89 @@ -687,6 +687,54 @@
90      fi
91  }
92  
93 +function addtoCPUSET
94 +{
95 +    local vdir=$1
96 +    local cpuset
97 +    local f="$vdir"/cpuset
98 +    local i
99 +    local configured=0
100 +
101 +    test -d "$f" || return 0
102 +    test -e "$f"/name || return 0
103 +
104 +    read cpuset < "$f"/name
105 +    test -e "$f"/nocreate || {
106 +       test -d /dev/cpuset/"$cpuset" || mkdir /dev/cpuset/"$cpuset" || configured=1
107 +       for i in cpus mems cpu_exclusive mem_exclusive virtualized; do
108 +           if test -e "$f"/"$i"; then
109 +               cat "$f"/"$i" >/dev/cpuset/"$cpuset"/"$i" 2>/dev/null || {
110 +                   configured=1
111 +                   break
112 +               }
113 +           fi
114 +       done
115 +    }
116 +
117 +    echo $$ >/dev/cpuset/"$cpuset"/tasks || configured=1
118 +    if [ "$configured" -ne 0 ]; then
119 +       warning $"\
120 +WARNING: Failed to create or CPUSET \"$cpuset\" does not exist! Not using it!" >&2
121 +       rmdir /dev/cpuset/"$cpuset" 2>/dev/null || :
122 +       return 0
123 +    fi
124 +}
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 || {
137 +       rmdir /dev/cpuset/"$cpuset" 2>/dev/null || :
138 +    }
139 +}
140 +
141  function _mountVserverInternal
142  {
143      local fstab="$1"
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 @@
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
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
166 @@ -22,6 +22,7 @@
167      exit 1
168  }
169  generateOptions  "$VSERVER_DIR"
170 +addtoCPUSET  "$VSERVER_DIR"
171  
172  user=$1
173  shift
This page took 0.04175 seconds and 4 git commands to generate.