summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app-emulation/xen-tools/files/xencommons.initd')
-rw-r--r--app-emulation/xen-tools/files/xencommons.initd80
1 files changed, 80 insertions, 0 deletions
diff --git a/app-emulation/xen-tools/files/xencommons.initd b/app-emulation/xen-tools/files/xencommons.initd
new file mode 100644
index 000000000000..0ce192fae927
--- /dev/null
+++ b/app-emulation/xen-tools/files/xencommons.initd
@@ -0,0 +1,80 @@
+#!/sbin/runscript
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ before xenstored
+}
+
+is_privileged_domain() {
+ grep -qsE '^control_d$' /proc/xen/capabilities
+ return $?
+}
+
+handle_kernel_modules() {
+ local XEN_DEFAULT_KERNEL_MODULES="
+ xen-evtchn
+ xen-gntdev
+ xen-gntalloc
+ xen-blkback
+ xen-netback
+ xen-pciback
+ gntdev
+ netbk
+ blkbk
+ xen-scsibk
+ usbbk
+ pciback
+ xen-acpi-processor
+ blktap2
+ blktap
+ "
+
+ [ "$1" = "remove" ] && OPTS="-r"
+
+ XEN_KERNEL_MODULES="${XEN_KERNEL_MODULES:-${XEN_DEFAULT_KERNEL_MODULES}}"
+ for i in ${XEN_KERNEL_MODULES}; do
+ modprobe ${OPTS} $i 2>/dev/null
+ done
+ return 0
+}
+
+start() {
+ ebegin "Starting xencommons daemon"
+
+ # not running in Xen dom0 or domU
+ if [ ! -d /proc/xen ]; then
+ eend 1 "Not running in Xen mode"
+ return 1
+ fi
+
+ # 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
+
+ if ! is_privileged_domain; then
+ eend 1 "Not running on a privileged domain. xencommons not started"
+ return 1
+ fi
+
+ handle_kernel_modules
+
+ eend $? "Failed to start xencommons"
+}
+
+stop () {
+ ebegin "Stopping xencommons"
+ if ! is_privileged_domain; then
+ eend 1 "Not running on a privileged domain. xencommons not started"
+ return 1
+ fi
+
+ handle_kernel_modules remove
+
+ eend $? "Failed to stop xencommons"
+}
+