Permalink
Browse files

FL-564: vzctl update, maskedd for testing

  • Loading branch information...
angryvincent committed Jun 27, 2013
1 parent 0c7779d commit 36538068dbf90fd90a2ee7fda0c5ec2eb32f020a
@@ -1,6 +1,10 @@
# Keep the most recent masks in a reverse chrono order
# newest on top
+# Oleg Vinichenko (27 Jun 2013)
+# vzctl update, masked, require newer ploop and openvz kernel FL-564
+=sys-cluster/vzctl-4.3.1
+
# Oleg Vinichenko (25 Jun 2013)
# new networkmanager ebuild, masked for testing, policykit
# use flag removed, in favor of explicit polkit dep. FL-595
@@ -1,3 +1,4 @@
DIST vzctl-3.0.28.3-funtoo.tar.gz 213655 SHA256 5230bb5951d181363e1981aab3400d2bc39a795593b709e2ff06010432c83be6
DIST vzctl-3.0.30.2-funtoo.tar.gz 218789 SHA256 fe8d87c8e70f588e6636673e422928032914a9caa4b39aaed4b60a3ce305f384 SHA512 7c29afdbfd3dbcff0881e2ccea877e895da5bd7c00815bafa67fbae7e33f698907de1b50fe34440f973c66280147e5657843bc7e2e24517d641e67f3dd260a78 WHIRLPOOL ec3b3fd5c579a24226969eb3080e5fd55b79e37d9fd3965cbc2f6e80c5ccfc7606c1302fe6475f6c24e154ffc2869d698015478440beaa8a8e5f4066870fbb1f
DIST vzctl-3.3-r3-funtoo.tar.gz 238691 SHA256 1c2136edfb4437a186af9da671afad0089aed86dfaebfcf289e9668c70cbd033 SHA512 30801a8face605ae574976475f214ad2f108c10478a21dd2289a40f9176f7c95d9451935d5b1a963ade91207146436414058c2c6a1a5fb55e831250a222086f4 WHIRLPOOL 38184e4f250c5a820217ee154ad3ee018ec479f4e6ed068c0968d534f4a773e8915d1c4e1fb9b91073e7eb0ce2ac4073bc1fc160eece6e4358ee54ebbc90f18e
+DIST vzctl-4.3.1-funtoo.tar.gz 284308 SHA256 c5674299fc7d5ec07fe43318786dd76cb32f9a3925140d2d205aace7d3cfd5ca SHA512 d804c53ec8d5dc1dd58b89dae4b061cd3bc574d9083beade07be4a3b9f3492c3d906162b6adb79a47d261e60815b2e4ae128284a1b48486adec48552159e7fba WHIRLPOOL 3403fa31315a7de88e2f1c04662e7cc3fe9f4374630298ba3d6d0470d2cbb3beb587ae04afd89e76c94f46927b89f09a0682014dbffd94d5f13915e4a090de37
@@ -0,0 +1,335 @@
+#!/sbin/runscript
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/sys-cluster/vzctl/files/vz-3.0.10.initd,v 1.2 2006/07/09 10:29:24 phreak Exp $
+
+depend() {
+ after net
+ need vzeventd
+}
+
+check_config() {
+ # if we don't want openvz running, say so
+ [ "${VIRTUOZZO}" = "yes" ] || return 1
+
+ # set default values
+ : ${VZCTL:=/usr/sbin/vzctl}
+ : ${VZQUOTA:=/usr/sbin/vzquota}
+ : ${VZVEINFO:=/proc/vz/veinfo}
+ : ${VESTAT:=/proc/vz/vestat}
+ : ${VPSCONFDIR:=/etc/vz/conf}
+ : ${VZDEV:=venet0}
+ : ${VZCONF:=/etc/vz/vz.conf}
+
+ if [ "${MODULES_DISABLED}" != "yes" ]; then
+ : ${IPTABLES_MODULES:="${IPTABLES}"}
+ IPTABLES_MODULES="ip_tables ${IPTABLES_MODULES} xt_tcpudp"
+ : ${PRELOAD_MODULES:="af_packet"}
+ : ${MODULES:="vzmon vzdquota vzdev"}
+ : ${MIGRATE_MODULES:="vzcpt vzrst"}
+ : ${NET_MODULES="vznetdev vznet vzethdev"}
+
+ # check if you should load vzwdog module
+ [ "${VZWDOG}" = "yes" ] && MODULES="${MODULES} vzwdog"
+ fi
+
+ # we need a working vzctl
+ if [ ! -x "${VZCTL}" ]; then
+ eerror "vzctl missing (${VZCTL})"
+ return 1
+ fi
+
+ if [ -z "${VE0CPUUNITS}" ]; then
+ ewarn "VE0CPUUNITS is not set in /etc/conf.d/vz; using default value of 1000"
+ VE0CPUUNITS=1000
+ fi
+ return 0
+}
+
+mount_cgroups()
+{
+ local g
+ for g in beancounter container fairsched ; do
+ if [ -d /proc/vz/$g ]; then
+ mount -t cgroup $g /proc/vz/$g -o name=$g 2>/dev/null
+ fi
+ done
+}
+
+umount_cgroups()
+{
+ local g
+ for g in beancounter container fairsched ; do
+ umount /proc/vz/$g 2>/dev/null
+ done
+}
+
+setup_ve0() {
+ local msg ve0conf="${VPSCONFDIR}/0.conf"
+
+ mount_cgroups
+
+ msg=$(${VZCTL} set 0 --cpuunits ${VE0CPUUNITS} 2>&1)
+ [ $? -ne 0 ] && ewarn "vzctl set 0 --cpuunits ${VE0CPUUNITS} failed: ${msg}"
+
+ test -f ${ve0conf} || return
+ egrep -q '^ONBOOT=yes\|^ONBOOT=\"yes\"' ${ve0conf} || return
+
+ ebegin "Configuring hardware node UB resources: "
+ msg=$(${VZCTL} set 0 --reset_ub 2>&1)
+ eend $? ${msg}
+}
+
+start_net() {
+ local mod
+
+ # load necessary modules
+ for mod in ${NET_MODULES}; do
+ /sbin/modprobe ${mod} 2>/dev/null
+ done
+
+ if [ ! -f ${VZVEINFO} ]; then
+ return 0
+ fi
+
+ # we don't operate on a running interface
+ if /sbin/ip addr list | grep -q "venet0:.*UP" 2>/dev/null; then
+ return 0
+ fi
+
+ # configure the device
+ ebegin "Bringing up interface ${VZDEV}"
+ /sbin/ip link set ${VZDEV} up
+ eend $?
+
+ /sbin/ip addr add 0.0.0.0/0 dev ${VZDEV}
+
+ ebegin "Configuring interface ${VZDEV}"
+ /sbin/sysctl -q -w net.ipv4.conf.${VZDEV}.send_redirects=0
+ eend $?
+
+ if [ "x$(/sbin/sysctl -n -e net.ipv4.ip_forward)" != "x1" ]; then
+ ewarn "It looks like you have ip forwarding disabled. To make networking"
+ ewarn "available for containers, please, run sysctl -w net.ipv4.ip_forward=1"
+ fi
+}
+
+stop_net() {
+ local mod
+
+ if /sbin/ip addr list | grep -q "venet0:.*UP" 2>/dev/null; then
+ ebegin "Bringing down interface ${VZDEV}"
+ /sbin/ip link set ${VZDEV} down 2>/dev/null
+ eend $?
+ fi
+
+ # remove all modules we probably loaded on start_net
+ for mod in ${NET_MODULES}; do
+ /sbin/modprobe -r ${mod} > /dev/null 2>&1
+ done
+}
+
+start_ve() {
+ local veid velist msg need_restart=""
+
+ # get all containers we should start on boot
+ velist=$(vzlist -aH -octid,onboot -s-bootorder |
+ awk '$2 == "yes" {print $1}')
+
+ /sbin/sysctl -q -w net.ipv4.route.src_check=0
+
+ for veid in ${velist}; do
+ ebegin "Starting CT ${veid}"
+ if [ "${VZFASTBOOT}" = "yes" -a "${DISK_QUOTA}" = "yes" ]; then
+ ${VZQUOTA} stat ${veid} >/dev/null 2>&1
+ if [ $? -eq 6 ]; then
+ if ${VZQUOTA} show ${veid} 2>&1 | grep "vzquota : (warning) Quota is running" >/dev/null 2>&1; then
+ ${VZQUOTA} on ${veid} --nocheck >/dev/null 2>&1
+ need_restart="${need_restart} ${veid}"
+ fi
+ fi
+ fi
+ msg=$(${VZCTL} start ${veid} 2>&1)
+ eend $? "${msg}"
+ done
+
+ for veid in ${need_restart}; do
+ ebegin "Stopping CT ${veid}"
+ msg=$(${VZCTL} stop ${veid})
+ eend $? "${msg}"
+
+ ebegin "Starting CT ${veid}"
+ msg=$($VZCTL start ${veid} 2>&1)
+ eend $? "${msg}"
+ done
+
+ # we're ok even if some CTs failed to start
+ return 0
+}
+
+get_parallel()
+{
+ [ -n "${PARALLEL}" ] && return
+ PARALLEL=`awk '
+BEGIN { num=0; }
+$1 == "processor" { num++; }
+END { print num * 4; }' /proc/cpuinfo`
+}
+
+stop_ve() {
+ local veid velist msg m mounts fail i iter pid pids quota
+
+ if [ -f ${VESTAT} ]; then
+ get_parallel
+ for ((i = 0; i <= 2; i++)); do
+ iter=0
+ pids=
+ velist=$(awk '$1 != "VEID" && $1 != "Version:" {print $1}' ${VESTAT})
+ for veid in ${velist}; do
+ ebegin "Shutting down CT $veid"
+ # Set fairsched parameters to maximum so
+ # CT will stop fast
+ ${VZCTL} set ${veid} --cpuunits 2000 --cpulimit 0 >/dev/null 2>&1
+ ${VZCTL} --skiplock stop ${veid} >/dev/null 2>&1 &
+ pids="${pids} $!"
+ let iter++
+ if [ ${iter} -gt ${PARALLEL} ]; then
+ for pid in ${pids}; do
+ wait ${pid}
+ done
+ pids=
+ iter=0
+ fi
+ done
+
+ for pid in ${pids}; do
+ wait ${pid}
+ done
+ done
+ fi
+
+ iter=0
+ fail=1
+
+ while [ ${iter} -lt 5 -a ${fail} -ne 0 ]; do
+ fail=0
+ mounts=$(awk '{if ($3=="simfs") print $2}' /proc/mounts)
+
+ for m in ${mounts}; do
+ ebegin "Unmounting CT area ${m}"
+ msg=$(umount ${m} 2>&1)
+ eend $? "${msg}"
+ if [ $? -ne 0 ]; then
+ let fail++
+ fuser -k -m ${m} > /dev/null 2>&1
+ fi
+ done
+
+ let iter++
+ done
+
+ # turn quota off
+ quota=$(awk -F: '/^[0-9]+:/{print $1}' /proc/vz/vzquota 2>/dev/null)
+
+ for m in ${quota}; do
+ ebegin "Turning quota off for CT ${m}"
+ msg=$(vzquota off ${m} 2>&1)
+ eend $? "${msg}"
+ done
+}
+
+modify_vzconf()
+{
+ # For vswap-enabled kernel (like RHEL6 042test or greater),
+ # use vswap config for CT. Don't do it if CONFIGFILE= is modified
+
+ egrep -q 'test|stab' /proc/vz/version 2>/dev/null || return 0
+
+ local cfg_old='^CONFIGFILE="basic"$'
+ local cfg_new='CONFIGFILE="vswap-256m"'
+ local kv=$(cat /proc/vz/version | sed 's/\(test\|stab\).*$//')
+ if test $kv -ge 42; then
+ if grep -q $cfg_old $VZCONF; then
+ sed -i "s/${cfg_old}/${cfg_new}/" $VZCONF
+ ewarn "Set $cfg_new in $VZCONF"
+ fi
+ fi
+}
+
+
+start() {
+ check_config || return
+
+ local mod rc
+
+ ebegin "Loading OpenVZ modules"
+ for mod in ${IPTABLES_MODULES}; do
+ /sbin/modprobe ${mod} >/dev/null 2>&1
+ done
+
+ for mod in ${PRELOAD_MODULES}; do
+ /sbin/modprobe -r ${mod} >/dev/null 2>&1
+ /sbin/modprobe ${mod} >/dev/null 2>&1
+ done
+
+ for mod in ${MODULES}; do
+ /sbin/modprobe ${mod} >/dev/null 2>&1
+ rc=$?
+ if [ ${rc} -ne 0 ]; then
+ eend ${rc} "failed to load module ${mod}"
+ return ${rc}
+ fi
+ done
+
+ for mod in ${MIGRATE_MODULES}; do
+ /sbin/modprobe ${mod} >/dev/null 2>&1
+ done
+ eend
+
+ if [ ! -e /dev/vzctl ]; then
+ eerror "Missing device node /dev/vzctl"
+ einfo
+ einfo "Please create the vzctl device node using the following command:"
+ einfo " /bin/mknod /dev/vzctl c 126 0"
+ einfo
+ return 1
+ fi
+
+ start_net
+ setup_ve0
+ modify_vzconf
+ start_ve
+}
+
+stop() {
+ check_config || return
+
+ # Avoid stop action inside a CT, check we are in CT0
+ if ! egrep -q '^[[:space:]]*0:[[:space:]]' \
+ /proc/user_beancounters; then
+ eerror "Looks like we are inside a container!"
+ return 1
+ fi
+
+ local mod
+
+ stop_ve
+ umount_cgroups
+ stop_net
+
+ for mod in ${MIGRATE_MODULES}; do
+ /sbin/modprobe -r ${mod} > /dev/null 2>&1
+ done
+
+ for mod in ${MODULES}; do
+ /sbin/modprobe -r ${mod} > /dev/null 2>&1
+ done
+
+ for mod in ${PRELOAD_MODULES}; do
+ /sbin/modprobe -r ${mod} > /dev/null 2>&1
+ done
+
+ # Even if some modules failed to unload (say they were not loaded)
+ # we return 0 for the service to be marked as stopped.
+ return 0
+}
Oops, something went wrong.

0 comments on commit 3653806

Please sign in to comment.