diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/xen/APKBUILD | 39 | ||||
-rw-r--r-- | main/xen/xen-consoles.logrotate | 5 | ||||
-rwxr-xr-x | main/xen/xencommons.initd | 99 | ||||
-rw-r--r-- | main/xen/xenconsoled.confd | 2 | ||||
-rw-r--r-- | main/xen/xenconsoled.initd | 25 | ||||
-rw-r--r-- | main/xen/xend.confd | 3 | ||||
-rw-r--r-- | main/xen/xend.initd | 57 | ||||
-rw-r--r-- | main/xen/xendomains.confd | 25 | ||||
-rw-r--r--[-rwxr-xr-x] | main/xen/xendomains.initd | 153 | ||||
-rw-r--r-- | main/xen/xenstored.confd | 5 | ||||
-rw-r--r-- | main/xen/xenstored.initd | 53 |
11 files changed, 254 insertions, 212 deletions
diff --git a/main/xen/APKBUILD b/main/xen/APKBUILD index 4c266449d3..5e6a93ea9d 100644 --- a/main/xen/APKBUILD +++ b/main/xen/APKBUILD @@ -3,7 +3,7 @@ # Maintainer: William Pitcock <nenolod@dereferenced.org> pkgname=xen pkgver=4.1.2 -pkgrel=6 +pkgrel=7 pkgdesc="Xen hypervisor" url="http://www.xen.org/" arch="x86 x86_64" @@ -25,9 +25,17 @@ source="http://bits.xensource.com/oss-xen/release/$pkgver/$pkgname-$pkgver.tar.g librt.patch busybox-sed.patch e1000.patch - xencommons.initd + + xenstored.initd + xenstored.confd + xenconsoled.initd + xenconsoled.confd xend.initd - xendomains.initd" + xend.confd + xendomains.initd + xendomains.confd + xen-consoles.logrotate + " _builddir="$srcdir"/$pkgname-$pkgver prepare() { @@ -77,9 +85,16 @@ package() { make -j1 DESTDIR="$pkgdir" install-xen install-tools install-stubdom \ || return 1 - install -m755 -D "$srcdir"/xencommons.initd "$pkgdir"/etc/init.d/xencommons - install -m755 -D "$srcdir"/xend.initd "$pkgdir"/etc/init.d/xend - install -m755 -D "$srcdir"/xendomains.initd "$pkgdir"/etc/init.d/xendomains + for i in $source; do + case $i in + *.initd) install -Dm755 "$srcdir"/$i \ + "$pkgdir"/etc/init.d/${i%.*};; + *.confd) install -Dm644 "$srcdir"/$i \ + "$pkgdir"/etc/conf.d/${i%.*};; + esac + done + install -Dm644 "$srcdir"/xen-consoles.logrotate \ + "$pkgdir"/etc/xen/xen-consoles.logrotate } md5sums="73561faf3c1b5e36ec5c089b5db848ad xen-4.1.2.tar.gz @@ -93,6 +108,12 @@ a7500c42804abdf68e051dc667e65f93 pygrub_alpine.patch fa06495a175571f4aa3b6cb88937953e librt.patch 1bea3543ddc712330527b62fd9ff6520 busybox-sed.patch c31163a3cd6cf58b4e9cac0e96812d65 e1000.patch -62b3c5a7cff38c12df2de89af5d83fa1 xencommons.initd -b5bfc08b82bc0d21193714719a719798 xend.initd -6c288547faadd4262afd2f86e39e99a3 xendomains.initd" +095b20f33bd0fb3963002722870b1dda xenstored.initd +b017ccdd5e1c27bbf1513e3569d4ff07 xenstored.confd +ed262f15fb880badb53575539468646c xenconsoled.initd +ec2252c72050d7d5870a3a629b873ba6 xenconsoled.confd +89c936ddf327a3a78eaee33835880517 xend.initd +9261ad0f285836c1b0ea07f306e4586e xend.confd +6ce7f3069862ad23e3e1d908bb2b7987 xendomains.initd +f3162b7c261bcaf49a67bd41d987df84 xendomains.confd +9df68ac65dc3f372f5d61183abdc83ff xen-consoles.logrotate" diff --git a/main/xen/xen-consoles.logrotate b/main/xen/xen-consoles.logrotate new file mode 100644 index 0000000000..c6445239b4 --- /dev/null +++ b/main/xen/xen-consoles.logrotate @@ -0,0 +1,5 @@ +/var/log/xen-consoles/*.log { + rotate 7 + missingok + compress +} diff --git a/main/xen/xencommons.initd b/main/xen/xencommons.initd deleted file mode 100755 index 7543cae3a5..0000000000 --- a/main/xen/xencommons.initd +++ /dev/null @@ -1,99 +0,0 @@ -#!/sbin/runscript -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: $ - -if [ -d /etc/sysconfig ]; then - xencommons_config=/etc/sysconfig -else - xencommons_config=/etc/default -fi - -test -f $xencommons_config/xencommons && . $xencommons_config/xencommons - -XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid - -# not running in Xen dom0 or domU -if ! test -d /proc/xen ; then - exit 0 -fi - -depend() { - need udev - before xend -} - -start() { - local time=0 - local timeout=30 - - modprobe xen-evtchn 2>/dev/null - modprobe xen-gntdev 2>/dev/null - modprobe evtchn 2>/dev/null - modprobe gntdev 2>/dev/null - - # mount xenfs in dom0 or domU with a pv_ops kernel - if ! test -f /proc/xen/capabilities && \ - ! grep '^xenfs ' /proc/mounts >/dev/null; - then - mount -t xenfs xenfs /proc/xen - fi - - # assert we are running in the dom0 - if test -f /proc/xen/capabilities && \ - ! grep -q "control_d" /proc/xen/capabilities ; then - exit 0 - fi - - if ! `xenstore-read -s / >/dev/null 2>&1` - then - test -z "$XENSTORED_ROOTDIR" || XENSTORED_ROOTDIR="/var/lib/xenstored" - rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null - test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T /var/log/xen/xenstored-trace.log" - - ebegin "Starting xenstored..." - xenstored --pid-file=/var/run/xenstored.pid $XENSTORED_ARGS - - # Wait for xenstored to actually come up, timing out after 30 seconds - while [ $time -lt $timeout ] && ! `xenstore-read -s / >/dev/null 2>&1` ; do - time=$(($time+1)) - sleep 1 - done - - # Exit if we timed out - if ! [ $time -lt $timeout ] ; then - eend 1 - echo Could not start xenstored - exit 1 - fi - eend 0 - - ebegin "Setting domain 0 name..." - xenstore-write "/local/domain/0/name" "Domain-0" - eend $? - fi - - ebegin "Starting xenconsoled..." - test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" --log=$XENCONSOLED_TRACE" - xenconsoled --pid-file=$XENCONSOLED_PIDFILE $XENCONSOLED_ARGS - eend $? - - test -z "$XENBACKENDD_DEBUG" || XENBACKENDD_ARGS="-d" - test "`uname`" != "NetBSD" || xenbackendd $XENBACKENDD_ARGS -} - -stop() { - ebegin "Stopping xenconsoled" - if read 2>/dev/null <$XENCONSOLED_PIDFILE pid; then - kill $pid - while kill -9 $pid >/dev/null 2>&1; do sleep 0.1; done - rm -f $XENCONSOLED_PIDFILE - fi - eend 0 - - echo WARNING: Not stopping xenstored, as it cannot be restarted. -} - -status() { - xenstore-read -s / >/dev/null 2>&1 -} diff --git a/main/xen/xenconsoled.confd b/main/xen/xenconsoled.confd new file mode 100644 index 0000000000..b2e194bde4 --- /dev/null +++ b/main/xen/xenconsoled.confd @@ -0,0 +1,2 @@ +# /etc/conf.d/xenstored +XENCONSOLED_OPTS="" diff --git a/main/xen/xenconsoled.initd b/main/xen/xenconsoled.initd new file mode 100644 index 0000000000..d4583226b4 --- /dev/null +++ b/main/xen/xenconsoled.initd @@ -0,0 +1,25 @@ +#!/sbin/runscript +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-emulation/xen-tools/files/xenconsoled.initd,v 1.1 2011/04/05 19:23:05 alexxy Exp $ + +depend() { + need xenstored +} + +start() { + ebegin "Starting xenconsoled daemon" + start-stop-daemon --start --exec /usr/sbin/xenconsoled \ + --pidfile /var/run/xenconsoled.pid \ + -- --pid-file=/var/run/xenconsoled.pid \ + ${XENCONSOLED_OPTS} + eend $? +} + +stop() { + ebegin "Stoping xenconsoled daemon" + start-stop-daemon --stop --exec /usr/sbin/xenconsoled \ + --pidfile /var/run/xenconsoled.pid + eend $? +} + diff --git a/main/xen/xend.confd b/main/xen/xend.confd new file mode 100644 index 0000000000..65deada105 --- /dev/null +++ b/main/xen/xend.confd @@ -0,0 +1,3 @@ +# xend.conf + +# XEND_START_TIMEOUT=5 diff --git a/main/xen/xend.initd b/main/xen/xend.initd index 398ecd86b9..1c667e8312 100644 --- a/main/xen/xend.initd +++ b/main/xen/xend.initd @@ -1,53 +1,52 @@ #!/sbin/runscript +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-emulation/xen-tools/files/xend.initd-r2,v 1.2 2011/09/10 17:22:46 alexxy Exp $ depend() { - need xencommons - before xendomains + need net xenconsoled xenstored + after firewall + before xendomains sshd } await_daemons_up() { - i=1 - rets=10 - /usr/sbin/xend status - while [ $? -ne 0 -a $i -lt $rets ]; do + local i=1 rets=10 + while [ $i -lt $rets ]; do + /usr/sbin/xend status && return 0 sleep 1 - i=$(($i + 1)) - /usr/sbin/xend status done + return 1 +} + +is_privileged_domain() { + grep -qsE '^control_d$' /proc/xen/capabilities + return $? } start() { - ebegin "Starting Xen daemons" - if [ -z "`ps xenconsoled -o pid=`" ]; then - eend 1 - echo "xencommons should be started first." - exit 1 - fi - mkdir -p /var/lock - if [ -d /var/lock/subsys ]; then - touch /var/lock/subsys/xend - else - touch /var/lock/xend + if ! is_privileged_domain ; then + eerror "Can't start xend - this is not a privileged domain." + return 1 fi + + ebegin "Starting Xen control daemon" /usr/sbin/xend start - await_daemons_up + /usr/sbin/xend status || await_daemons_up eend $? } stop() { + if [ "$(xm list | wc -l)" -gt 2 ]; then + ebegin " Stopping all domains" + /usr/sbin/xl shutdown -a -w >/dev/null + eend $? + fi + ebegin "Stopping Xen control daemon" /usr/sbin/xend stop - rm -f /var/lock/subsys/xend /var/lock/xend - eend $? -} - -restart() { - ebegin "Restarting Xen control daemon" - /usr/sbin/xend restart - await_daemons_up eend $? } status() { - /usr/sbin/xend status + is_privileged_domain && /usr/sbin/xend status } diff --git a/main/xen/xendomains.confd b/main/xen/xendomains.confd new file mode 100644 index 0000000000..a180c13d85 --- /dev/null +++ b/main/xen/xendomains.confd @@ -0,0 +1,25 @@ +# /etc/conf.d/xendomains + +# Directory of domains to boot. AUTODIR should contain one or more symlinks +# to domain config files in /etc/xen +AUTODIR=/etc/xen/auto + +# Send shutdown commands to all domains in parallel instead of waiting for +# each to shutdown individually +PARALLEL_SHUTDOWN=yes + +# When SCREEN="yes", domains in AUTODIR have their consoles connected to a +# screen session named SCREEN_NAME, with output logged to individual files +# named after each domain and written to /var/log/xen-consoles/ . These files +# are rotated (using app-admin/logrotate) every time xendomains is started. + +SCREEN="yes" +SCREEN_NAME="xen" + +# Number of seconds between writes to screen's logfiles. +# +# Lower values mean more disk activity and hence a possible performance +# impact, but higher values mean a greater chance of loosing some output +# in the event of a crash. + +SCREEN_LOG_INTERVAL="1" diff --git a/main/xen/xendomains.initd b/main/xen/xendomains.initd index 5077d82e03..63d35fc714 100755..100644 --- a/main/xen/xendomains.initd +++ b/main/xen/xendomains.initd @@ -1,114 +1,117 @@ #!/sbin/runscript +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-emulation/xen-tools/files/xendomains.initd-r2,v 1.4 2012/01/12 13:40:01 alexxy Exp $ -# See docs/misc/distro_mapping.txt -if [ -d /var/lock/subsys ]; then - LOCKFILE=/var/lock/subsys/xendomains -else - LOCKFILE=/var/lock/xendomains -fi - -if [ -d /etc/sysconfig ]; then - XENDOM_CONFIG=/etc/sysconfig/xendomains -else - XENDOM_CONFIG=/etc/default/xendomains -fi - -if ! [ -r $XENDOM_CONFIG ]; then - eend 1; - echo "$XENDOM_CONFIG not existing"; - return 1; -fi - -. $XENDOM_CONFIG +extra_commands="status" depend() { - need xencommons - after net xend + need xenstored + after dhcp xend xenconsoled } get_domname() { local name_from_file=$(sed -rn 's/^name\W*=\W*\"?([[:alnum:]_\.-]+)\"?\W*;?/\1/p' "${1}" | tail -n 1) - if [[ -z ${name_from_file} ]] ; then + if [ -z ${name_from_file} ]; then basename "${1}" else - echo ${name_from_file} + echo ${name_from_file} fi } is_running() { - /usr/sbin/$CMD list "${1}" >/dev/null 2>&1 + /usr/sbin/xl list "${1}" >/dev/null 2>&1 } -check_xen() { - CMD=xm - /usr/sbin/$CMD list &> /dev/null - if test $? -ne 0 - then - CMD=xl - fi - - /usr/sbin/$CMD list &> /dev/null - if test $? -ne 0 - then - eend 1; - echo "Could not find xl or xm"; - return 1; - fi +using_screen() { + yesno "${SCREEN}" +} - # Correct exit code would probably be 5, but it's enough - # if xend complains if we're not running as privileged domain - if ! [ -e /proc/xen/privcmd ]; then - eend 1; - echo "Could not find /proc/xen/privcmd"; - return 1; - fi +set_screen_cmd() { + screen_cmd="screen -c ${SCREENRC:-/dev/null} -q -r ${SCREEN_NAME:=xen} -X" } start() { - einfo "Starting Xen domains in ${AUTODIR:=/etc/xen/auto}" - - check_xen - + set_screen_cmd + + einfo "Starting Xen domains from ${AUTODIR:=/etc/xen/auto}" + if using_screen ; then + ebegin "Creating screen session to hold domain consoles" + ( screen -c ${SCREENRC:-/dev/null} -d -m -S ${SCREEN_NAME} -t dom0 \ + && ${screen_cmd} zombie dr \ + && logrotate -f /etc/xen/xen-consoles.logrotate \ + && ${screen_cmd} logfile /var/log/xen-consoles/%t.log \ + && ${screen_cmd} logfile flush ${SCREEN_LOG_INTERVAL:-1} \ + && ${screen_cmd} log on \ + && ${screen_cmd} deflog on ) >/dev/null + if [ $? -ne 0 ] ; then + eend 1 + return 1 + else + eend + fi + fi + # Create all domains with config files in AUTODIR. for dom in $(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort); do name=$(get_domname ${dom}) if ! is_running ${name} ; then ebegin " Starting domain ${name}" - /usr/sbin/$CMD create --quiet --defconfig ${dom} >/dev/null 2>&1 + if using_screen ; then + ${screen_cmd} screen -t ${name} xl create ${dom} -c + else + xl create --quiet ${dom} + fi eend $? else - einfo " Not starting ${name} - already running." + einfo " Not starting domain ${name} - already running" fi done } stop() { - einfo "Stopping Xen domains in ${AUTODIR:=/etc/xen/auto}" - - check_xen - - for dom in $(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort); do - name=$(get_domname ${dom}) - if is_running ${name} ; then - ebegin " Sending shutdown signal to ${name}" - /usr/sbin/$CMD shutdown ${name} >/dev/null 2>&1 - eend $? - fi - done - - for dom in $(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort); do - name=$(get_domname ${dom}) - if is_running ${name} ; then - ebegin " Waiting for domain ${name} to shutdown" - /usr/sbin/$CMD shutdown --wait ${name} >/dev/null 2>&1 + set_screen_cmd + + einfo "Shutting down Xen domains from ${AUTODIR:=/etc/xen/auto}" + # Stop all domains with config files in AUTODIR. + DOMAINS="$(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort -r)" + + if yesno "$PARALLEL_SHUTDOWN"; then + for dom in $DOMAINS ; do + name=$(get_domname ${dom}) + if is_running ${name} ; then + ebegin " Asking domain ${name} to shutdown in the background..." + xl shutdown -w ${name} >/dev/null & + else + einfo " Not stopping domain ${name} - not running" + fi + done + einfo " Waiting for shutdown of domains that are still running" + wait + eend $? + else + for dom in $DOMAINS ; do + name=$(get_domname ${dom}) + if is_running ${name} ; then + ebegin " Waiting for domain ${name} to shutdown" + xl shutdown -w ${name} >/dev/null + eend $? + else + einfo " Not stopping domain ${name} - not running" + fi + done + fi + if using_screen ; then + if ${screen_cmd} sleep 0 >/dev/null 2>&1 ; then + ebegin "Closing screen session ${SCREEN_NAME}" + ${screen_cmd} quit eend $? else - einfo " Not stopping ${name} - not running." + eend 0 fi - done + fi } status() { - check_xen - /usr/sbin/$CMD list + /usr/sbin/xl list } diff --git a/main/xen/xenstored.confd b/main/xen/xenstored.confd new file mode 100644 index 0000000000..13363b3943 --- /dev/null +++ b/main/xen/xenstored.confd @@ -0,0 +1,5 @@ +# /etc/conf.d/xenstored +XENSTORED_OPTS="" + +# Uncomment for enabling tracing +# XENSTORED_TRACE=yes diff --git a/main/xen/xenstored.initd b/main/xen/xenstored.initd new file mode 100644 index 0000000000..bbb4efb0ce --- /dev/null +++ b/main/xen/xenstored.initd @@ -0,0 +1,53 @@ +#!/sbin/runscript +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-emulation/xen-tools/files/xenstored.initd,v 1.2 2011/04/05 21:25:03 alexxy Exp $ + +depend() { + need net + before xendomains xend sshd ntp-client ntpd nfs nfsmount rsyncd portmap dhcp +} + +wait_xenstored_up() { + local time=0 timeout=30 + while ! xenstore-read -s / >/dev/null 2>&1; do + time=$(($time+1)) + if [ $time -gt $timeout ]; then + return 1 + fi + sleep 1 + done + return 0 +} + +start() { + local _traceopt= + ebegin "Starting xenstored daemon" + modprobe xen-evtchn 2>/dev/null + modprobe xen-gntdev 2>/dev/null + modprobe evtchn 2>/dev/null + modprobe gntdev 2>/dev/null + + if yesno "$XENSTORED_TRACE"; then + _traceopt="-T /var/log/xen/xenstored-trace.log" + fi + + start-stop-daemon --start --exec /usr/sbin/xenstored \ + --pidfile /var/run/xenstored.pid \ + -- --pid-file=/var/run/xenstored.pid \ + $XENSTORED_OPTS $_traceopt + wait_xenstored_up + eend $? || return 1 + + einfo "Setting domain0 name record" + /usr/bin/xenstore-write "/local/domain/0/name" "Domain-0" + eend $* +} + +stop() { + ebegin "Stopping xenstored daemon" + start-stop-daemon --stop --exec /usr/sbin/xenstored \ + --pidfile /var/run/xenstored.pid + eend $? +} + |