aboutsummaryrefslogtreecommitdiffstats
path: root/main/xen
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-11-24 14:53:40 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2014-11-24 14:53:40 +0000
commit164c06ca578241499e1c0badeef98ab41569d98b (patch)
tree7cded29abfde62c4871cbf86b4434d4f16481a81 /main/xen
parenta2bfcd03d9990b858fcb2e108fec6e1bad923a8f (diff)
downloadaports-164c06ca578241499e1c0badeef98ab41569d98b.tar.bz2
aports-164c06ca578241499e1c0badeef98ab41569d98b.tar.xz
main/xen: fix race in xendomains init.d script
the gnu screen would show files in SCREENDIR before its ready to accept connections. so starting domains failed
Diffstat (limited to 'main/xen')
-rw-r--r--main/xen/APKBUILD8
-rw-r--r--main/xen/xendomains.initd90
2 files changed, 59 insertions, 39 deletions
diff --git a/main/xen/APKBUILD b/main/xen/APKBUILD
index bb21130ad4..4e1d28efc3 100644
--- a/main/xen/APKBUILD
+++ b/main/xen/APKBUILD
@@ -3,7 +3,7 @@
# Maintainer: William Pitcock <nenolod@dereferenced.org>
pkgname=xen
pkgver=4.4.1
-pkgrel=4
+pkgrel=5
pkgdesc="Xen hypervisor"
url="http://www.xen.org/"
arch="x86_64"
@@ -230,7 +230,7 @@ c13f954d041a6fa78d0d241ad1780c0b elf_local.h
d86504e12f05deca6b3eeeb90157160e xenstored.confd
ed262f15fb880badb53575539468646c xenconsoled.initd
ec2252c72050d7d5870a3a629b873ba6 xenconsoled.confd
-10f3ab45a6d0a241b9c7e9757ad59ad8 xendomains.initd
+03858ab5dda5b95ef344ddeb7340fcc9 xendomains.initd
2c80e442cec6dd2a025b61852641834d xendomains.confd
9df68ac65dc3f372f5d61183abdc83ff xen-consoles.logrotate
6a2f777c16678d84039acf670d86fff6 xenqemu.confd
@@ -253,7 +253,7 @@ d0b3e5f282a07878341c38f40d01041ed37623757a99d6e0a420ca64d1f4ef2a xen-fd-is-file
991bb7c9da02941556e29714bd96b26e39e57e0a5b514eadd78d9bfa3fa5a9dc xenstored.confd
93bea2eb90ea1b4628854c8141dd351bbd1fbc5959b12795447ea933ad025f01 xenconsoled.initd
2a74be03eb74f6013242a4a5d721df6cb9b959b43c405de1e32813f52d749060 xenconsoled.confd
-c304a6353ba1daebd0547bb57e9ffffc2c90465d6abe7469cfdacf61c5108eab xendomains.initd
+15c380c86e1980a3d6ee13c43a419567f359a2a5f2ccc5d1cded10dadc984a9e xendomains.initd
2360b1fa1f102ac1b1a6cd0d161a94d13139dfc21d9a2227d35d557b4f04a63e xendomains.confd
0da87a4b9094f934e3de937e8ef8d3afc752e76793aa3d730182d0241e118b19 xen-consoles.logrotate
4cfcddcade5d055422ab4543e8caa6e5c5eee7625c41880a9000b7a87c7c424e xenqemu.confd
@@ -276,7 +276,7 @@ e76816c6ad0e91dc5f81947f266da3429b20e6d976c3e8c41202c6179532eec878a3f0913921ef3a
093f7fbd43faf0a16a226486a0776bade5dc1681d281c5946a3191c32d74f9699c6bf5d0ab8de9d1195a2461165d1660788e92a3156c9b3c7054d7b2d52d7ff0 xenstored.confd
12f981b2459c65d66e67ec0b32d0d19b95a029bc54c2a79138cfe488d3524a22e51860f755abfe25ddcdaf1b27f2ded59b6e350b9d5f8791193d00e2d3673137 xenconsoled.initd
30df69cc38d0bed26bc4d6e08a2b62cbdc654d5f663009a05cb3b83b3e3dc5e206362d3fd59abbb753ceb8d6d79eaa6e15d079bb8f4f35dc74667103faf4e85d xenconsoled.confd
-d1008996e486bc8243abd0c3f50755da0f414009ba81eebe943514e29c7e2440af3e4aa0bc46258f05a502a7876783e834756b02dc72161be1ab3808e6abe67b xendomains.initd
+21f41fb6480cc1cd14796f24225da70946f2a2be13cd28465a235aa3462c6190d2d32dd696611e161e166b379931c9eb94169c87411f4079cb6003c488caf859 xendomains.initd
7c1e32d07aefbde1904ca2d98f9a415543cea7ab8e039b05e0b111e37e78c07c40b540e439b3656d5840dfd76e35e07cf1d6ddea431163d975b1ddf5ddac50d3 xendomains.confd
ab2105c75cfe01768aecd5bcbb56269d63666e8a44e42b6a83aee87df6c84ee2f9ab249171c21b2e09f8fec2cae8318f6e87d160989398a3e7dd68db8d52c426 xen-consoles.logrotate
bdbe15c924071cdc2d0f23e53ba8e3f837d4b5369bfb218abd3405f9bef25d105269aaf0784baeb69c073a5786b8c82ffdfd414e86874da34293cfdc2c497928 xenqemu.confd
diff --git a/main/xen/xendomains.initd b/main/xen/xendomains.initd
index e6751eeeaa..dd5a924f66 100644
--- a/main/xen/xendomains.initd
+++ b/main/xen/xendomains.initd
@@ -37,26 +37,16 @@ set_screen_cmd() {
screen_cmd="screen -c ${SCREENRC:-/dev/null} -q -r ${SCREEN_NAME:=xen} -X"
}
-dir_is_empty() {
- local dir=$1
- set -- "$dir"/*
- test "$1" = "$dir/*"
-}
-
wait_screen() {
- while dir_is_empty "$SCREENDIR"; do
+ while ! ${screen_cmd} dettach; do
sleep 0.1
done
}
-start() {
+init_screen() {
set_screen_cmd
- checkpath --directory --mode 755 /var/run/xen
-
- 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 \
+ ebegin "Creating screen session to hold domain consoles"
+ ( screen -c ${SCREENRC:-/dev/null} -d -m -S ${SCREEN_NAME} -t dom0 \
&& wait_screen \
&& ${screen_cmd} zombie dr \
&& logrotate -f /etc/xen/xen-consoles.logrotate \
@@ -64,13 +54,54 @@ start() {
&& ${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
+ eend $?
+}
+
+startdom_screen() {
+ ${screen_cmd} screen -t ${1} xl create ${2} -c
+}
+
+close_screen() {
+ set_screen_cmd
+ if ${screen_cmd} sleep 0 >/dev/null 2>&1 ; then
+ ebegin "Closing screen session ${SCREEN_NAME}"
+ ${screen_cmd} quit
+ eend $?
+ else
+ eend 0
fi
+}
+
+startdom_noconsole() {
+ xl create --quiet ${2}
+}
+
+
+set_dom_cmd() {
+ if using_screen; then
+ : ${XENDOMAINS_CONSOLE:=screen}
+ fi
+ case "$XENDOMAINS_CONSOLE" in
+ screen)
+ initconsole=init_screen
+ startdom=startdom_screen
+ closeconsole=close_screen
+ ;;
+ *)
+ initconsole=
+ startdom=startdom_noconsole
+ closeconsole=
+ esac
+}
+
+start() {
+ set_dom_cmd
+ checkpath --directory --mode 755 /var/run/xen
+
+ einfo "Starting Xen domains from ${AUTODIR:=/etc/xen/auto}"
+
+ $initconsole
+
# Create all domains with config files in AUTODIR.
want_usleep=
for dom in $(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort); do
@@ -82,11 +113,7 @@ start() {
want_usleep=1
fi
ebegin " Starting domain ${name}"
- if using_screen ; then
- ${screen_cmd} screen -t ${name} xl create ${dom} -c
- else
- xl create --quiet ${dom}
- fi
+ $startdom ${name} ${dom}
eend $?
else
einfo " Not starting domain ${name} - already running"
@@ -95,7 +122,7 @@ start() {
}
stop() {
- set_screen_cmd
+ set_dom_cmd
einfo "Shutting down Xen domains from ${AUTODIR:=/etc/xen/auto}"
# Stop all domains with config files in AUTODIR.
@@ -126,15 +153,8 @@ stop() {
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
- eend 0
- fi
- fi
+
+ $closeconsole
}
status() {