blob: c96d314858ce69e3f626d2bc2eedeafda4e8c658 (
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/sbin/openrc-run
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
depend() {
need xencommons xenstored xenconsoled
}
is_privileged_domain() {
grep -qsE '^control_d$' /proc/xen/capabilities
return $?
}
xen_setvars() {
. /etc/xen/scripts/hotplugpath.sh
XENQEMUDEV_PIDFILE=/run/xenqemudev.pid
# xen-4.5 change the path
XEN_QEMU="${LIBEXEC}/qemu-system-i386"
[ -e ${XEN_QEMU} ] && return
XEN_QEMU="${LIBEXEC_BIN}/qemu-system-i386"
}
xen_qemu_start() {
if [ -z "${XENQEMUDEV_FILE_BACKEND_ENABLE}" ]; then
ewarn " QEMU disk backend not enabled"
ewarn " enable XENQEMUDEV_FILE_BACKEND_ENABLE in /etc/conf.d/xenqemudev"
return 1
fi
xen_setvars
if [ ! -c /dev/xen/gntdev ]; then
einfo " Xen gntdev driver not loaded"
return 1
fi
if [ -e "${XEN_QEMU}" ]; then
einfo " Starting QEMU as disk backend for dom0"
XENQEMUDEV_DEFAULT_OPTS="-xen-domid 0 -xen-attach -name dom0 \
-nographic -M xenpv -daemonize \
-monitor /dev/null -serial /dev/null -parallel /dev/null"
XENQEMUDEV_OPTS=${XENQEMUDEV_OPTS:-${XENQEMUDEV_DEFAULT_OPTS}}
start-stop-daemon --start --exec ${XEN_QEMU} \
--pidfile ${XENQEMUDEV_PIDFILE} \
-- -pidfile ${XENQEMUDEV_PIDFILE} \
${XENQEMUDEV_OPTS}
return $?
fi
}
start() {
ebegin "Starting xenqemudev daemon"
# not running in Xen dom0 or domU
if [ ! -d /proc/xen ]; then
eend 1 "Not running in Xen mode"
return 1
fi
if ! is_privileged_domain; then
eend 1 "Not running on a privileged domain. xenqemudev not started"
return 1
fi
xen_qemu_start
eend $? "Failed to start xenqemudev"
}
stop () {
ebegin "Stopping xenqemudev"
xen_setvars
start-stop-daemon --stop --exec ${XEN_QEMU} \
--pidfile ${XENQEMUDEV_PIDFILE}
eend $? "Stopping xenqemudev, as it cannot be restarted."
}
|