summaryrefslogtreecommitdiffstats
path: root/main/xen/xenstored.initd
blob: 94237e35f16f7af15e8aaa284186625effda87c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/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() {
	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() {
	if xenstore-read -s / >/dev/null 2>&1; then
		ewarn "Xenstore can only be started once"
		return 0
	fi
	local _traceopt=

	checkpath --directory /var/run/xen
	ebegin "Starting xenstored daemon"

	if ! test -f /proc/xen/capabilities && \
	   ! grep '^xenfs ' /proc/mounts >/dev/null;
	then
		mount -t xenfs xenfs /proc/xen
	fi

	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

	if yesno "$XENSTORED_STUBDOM"; then
		/usr/bin/init-xenstore-domain /usr/lib/xen/boot/xenstore-stubdom.gz \
			$XENSTORED_STUBDOM_MEMORY \
			$XENSTORED_FLASK_LABEL
		wait_xenstored_up
	else
		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
	fi
	eend $? || return 1

	ebegin "Setting domain0 name record"
	/usr/bin/xenstore-write "/local/domain/0/name" "Domain-0"
	eend $*
}

stop() {
	ewarn "Xenstore can not be stopped"
}