Changeset 2771
- Timestamp:
- 08/24/08 22:12:08 (3 months ago)
- Files:
-
- trunk/doc/configuration.xml (modified) (2 diffs)
- trunk/scripts/vserver.functions (modified) (3 diffs)
- trunk/scripts/vserver.start (modified) (1 diff)
- trunk/scripts/vserver.stop (modified) (1 diff)
- trunk/sysv/util-vserver (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/doc/configuration.xml
r2740 r2771 305 305 <description>The default /etc/resolv.conf file.</description> 306 306 </data> 307 </collection> 308 309 <collection name="cgroup" use="optional" since="0.30.216" id="global-cgroup"> 310 <description> 311 This directory contains cgroup settings which should be applied to all guests. 312 See your kernel documentation for what settings are valid with your 313 configuration. 314 </description> 315 <scalar name="mnt"> 316 <description> 317 The directory to mount the cgroup hierarchy at. The default is /dev/cgroup. 318 </description> 319 </scalar> 320 <scalar name="subsys"> 321 <description> 322 Comma-separated list of subsystems to enable on the cgroup mount point. 323 The default is "all". 324 </description> 325 </scalar> 326 <list name="inherit"> 327 <description> 328 Some subsystems start out with clean slates, making it impossible to use the 329 cgroup before certain things have been set. This is true for e.g. the cpuset 330 subsystem. This file contains a list of filenames which should be explicitly 331 inherited from the parent (root) cgroup, if not overridden elsewhere. 332 The default is cpuset.cpus and cpuset.mems. 333 </description> 334 </list> 335 <scalar name="name" id="global-cgroup-name"> 336 <description> 337 If this file exists, all guests will be put in one cgroup named after the 338 contents of this file. The default is to put each guest in a cgroup named the 339 same thing as the guest. 340 </description> 341 </scalar> 307 342 </collection> 308 343 </collection> … … 1620 1655 </scalar> 1621 1656 </collection> 1657 1658 <collection name="cgroup" use="optional" since="0.30.216" id="guest-cgroup"> 1659 <description> 1660 This directory contains cgroup settings to be applied to this guest. 1661 See your kernel documentation for what settings are valid with your 1662 configuration. 1663 </description> 1664 <scalar name="name"> 1665 <description> 1666 If this file exists, the guest will be put in a cgroup named after the 1667 contents of this file. The default is to name the cgroup the same thing as the 1668 guest, unless 1669 <optionref ref="global-cgroup-name">.defaults/cgroup/name</optionref> says 1670 otherwise. 1671 </description> 1672 </scalar> 1673 </collection> 1674 <scalar name="nocgroup" since="0.30.216"> 1675 <description> 1676 If this file exists, 1677 <optionref ref="global-cgroup">.defaults/cgroup</optionref> will be ignored 1678 for this guest. 1679 </description> 1680 </scalar> 1622 1681 </collection> 1623 1682 </database> trunk/scripts/vserver.functions
r2744 r2771 71 71 72 72 SILENT_OPT= 73 74 CGROUP_MNT=/dev/cgroup 75 CGROUP_SUBSYS=all 76 declare -a CGROUP_INHERIT=( cpuset.cpus cpuset.mems ) 73 77 74 78 : ${VSERVER_NAME:=$(basename "$VSERVER_DIR")} … … 832 836 _generateMemctrlOptions "$1" 833 837 _generateSpaceOptions "$1" 838 _generateCgroupOptions 834 839 835 840 if test -n "$_IS_FAKEINIT"; then … … 1396 1401 done 1397 1402 } 1403 1404 function hasCgroup 1405 { 1406 $_GREP -q "cgroup" /proc/filesystems 1407 } 1408 1409 function _generateCgroupOptions 1410 { 1411 local file 1412 1413 hasCgroup || return 0 1414 1415 findFile file "$__CONFDIR/.defaults/cgroup/mnt" "" 1416 if test -n "$file"; then 1417 read CGROUP_MNT < "$file" 1418 fi 1419 findFile file "$__CONFDIR/.defaults/cgroup/subsys" "" 1420 if test -n "$file"; then 1421 read CGROUP_SUBSYS < "$file" 1422 fi 1423 findFile file "$__CONFDIR/.defaults/cgroup/inherit" "" 1424 if test -n "$file"; then 1425 _readFileToArray CGROUP_INHERIT "$file" "" 1426 fi 1427 1428 return 0 1429 } 1430 1431 function useCgroup 1432 { 1433 hasCgroup || return 1 1434 test -d "$CGROUP_MNT" || return 1 1435 test -d "$1/cgroup" -o \ 1436 \( -d "$__CONFDIR/.defaults/cgroup" -a \ 1437 ! -e "$1/nocgroup" \) 1438 } 1439 1440 function _handleCgroup 1441 { 1442 local action="$1" 1443 local vdir="$2" 1444 local dir 1445 local name 1446 local i 1447 local parent 1448 1449 useCgroup "$vdir" || return 0 1450 1451 findDir dir "$vdir/cgroup" "$__CONFDIR/.defaults/cgroup" "" 1452 test -d "$dir" || return 0 1453 1454 if test -r "$dir"/name; then 1455 read name < "$dir"/name 1456 else 1457 read name < "$vdir"/name 1458 fi 1459 1460 if test "$action" = "attach"; then 1461 if mkdir "$CGROUP_MNT/$name" 2>/dev/null; then 1462 parent="$CGROUP_MNT/$name" 1463 parent="${parent%/*}" 1464 for i in "${CGROUP_INHERIT[@]}"; do 1465 test -f "$parent/$i" || continue 1466 cat "$parent/$i" > "$CGROUP_MNT/$name/$i" 1467 done 1468 1469 shopt -s nullglob 1470 for i in "$dir"/*; do 1471 cat "$i" > "$CGROUP_MNT/$name/${i##*/}" 1472 done 1473 fi 1474 echo "$$" > "$CGROUP_MNT/$name/tasks" 1475 elif test "$action" = "destroy"; then 1476 rmdir "$CGROUP_MNT/$name" 2>/dev/null || : 1477 fi 1478 1479 return 0 1480 } 1481 1482 function attachToCgroup 1483 { 1484 _handleCgroup attach "$@" 1485 } 1486 1487 function destroyCgroup 1488 { 1489 _handleCgroup destroy "$@" 1490 } trunk/scripts/vserver.start
r2736 r2771 122 122 prepareInit "$VSERVER_DIR" 123 123 addtoCPUSET "$VSERVER_DIR" 124 attachToCgroup "$VSERVER_DIR" 124 125 125 126 handleDeviceMap --set "$S_CONTEXT" "$VSERVER_DIR/apps/vdevmap" trunk/scripts/vserver.stop
r2736 r2771 127 127 execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" postpost-stop 128 128 removeCPUSET "$VSERVER_DIR" 129 destroyCgroup "$VSERVER_DIR" trunk/sysv/util-vserver
r2749 r2771 53 53 } 54 54 55 function mount_cgroup() 56 { 57 _generateCgroupOptions 58 test -n "$CGROUP_MNT" || return 0 59 $_MKDIR -p "$CGROUP_MNT" 60 $_MOUNT -t cgroup -o "$CGROUP_SUBSYS" vserver "$CGROUP_MNT" 61 } 62 55 63 function start() 56 64 { … … 65 73 handleDeviceMap --set 0 "$__CONFDIR/.defaults/apps/vdevmap" 66 74 _endResult $? 75 if hasCgroup; then 76 _beginResult $"Mounting cgroup-hierarchy" 77 mount_cgroup 78 _endResult $? 79 fi 67 80 test "$retval" -ne 0 || touch "$lockfile" 68 81 return $retval
