]> git.pld-linux.org Git - packages/xen.git/commitdiff
- added POSIX-sh compatible init scripts
authorJan Rękorajski <baggins@pld-linux.org>
Wed, 29 Feb 2012 13:44:23 +0000 (13:44 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
- added systemd services and configs
- drop hvm bcond, we have bcc on all relevant archs
- updated files
- merged udev into main package (there is no point splitting this on modern systems)
- build stubdom in build not in install
- stubdom must be built separately (no prefix and no CFLAGS redefining)

Changed files:
    blktapctrl.service -> 1.1
    blktapctrl.sysconfig -> 1.1
    proc-xen.mount -> 1.1
    var-lib-xenstored.mount -> 1.1
    xen-watchdog.init -> 1.1
    xen-watchdog.service -> 1.1
    xen.logrotate -> 1.1
    xen.spec -> 1.96
    xenconsoled.init -> 1.1
    xenconsoled.service -> 1.1
    xenconsoled.sysconfig -> 1.1
    xend.init -> 1.1
    xend.service -> 1.1
    xend.tmpfiles -> 1.1
    xendomains.init -> 1.1
    xenstored.init -> 1.1
    xenstored.service -> 1.1
    xenstored.sysconfig -> 1.1
    xenstored.tmpfiles -> 1.1

19 files changed:
blktapctrl.service [new file with mode: 0644]
blktapctrl.sysconfig [new file with mode: 0644]
proc-xen.mount [new file with mode: 0644]
var-lib-xenstored.mount [new file with mode: 0644]
xen-watchdog.init [new file with mode: 0644]
xen-watchdog.service [new file with mode: 0644]
xen.logrotate [new file with mode: 0644]
xen.spec
xenconsoled.init [new file with mode: 0644]
xenconsoled.service [new file with mode: 0644]
xenconsoled.sysconfig [new file with mode: 0644]
xend.init [new file with mode: 0644]
xend.service [new file with mode: 0644]
xend.tmpfiles [new file with mode: 0644]
xendomains.init [new file with mode: 0644]
xenstored.init [new file with mode: 0644]
xenstored.service [new file with mode: 0644]
xenstored.sysconfig [new file with mode: 0644]
xenstored.tmpfiles [new file with mode: 0644]

diff --git a/blktapctrl.service b/blktapctrl.service
new file mode 100644 (file)
index 0000000..787053c
--- /dev/null
@@ -0,0 +1,15 @@
+[Unit]
+Description=blktapctrl daemon
+Requires=proc-xen.mount
+After=proc-xen.mount
+RefuseManualStop=true
+
+[Service]
+Type=forking
+Environment=BLKTAPCTRL_ARGS=
+EnvironmentFile=-/etc/sysconfig/blktapctrl
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStart=/usr/sbin/blktapctrl $BLKTAPCTRL_ARGS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/blktapctrl.sysconfig b/blktapctrl.sysconfig
new file mode 100644 (file)
index 0000000..bb6c09d
--- /dev/null
@@ -0,0 +1 @@
+#BLKTAPCTRL_ARGS=
diff --git a/proc-xen.mount b/proc-xen.mount
new file mode 100644 (file)
index 0000000..0eaa59c
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=Mount /proc/xen files
+ConditionPathExists=/proc/xen
+RefuseManualStop=true
+
+[Mount]
+What=xenfs
+Where=/proc/xen
+Type=xenfs
diff --git a/var-lib-xenstored.mount b/var-lib-xenstored.mount
new file mode 100644 (file)
index 0000000..9f59ebe
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=mount xenstore file system
+ConditionPathExists=/proc/xen
+RefuseManualStop=true
+
+[Mount]
+What=xenstore
+Where=/var/lib/xenstored
+Type=tmpfs
diff --git a/xen-watchdog.init b/xen-watchdog.init
new file mode 100644 (file)
index 0000000..1acb6c3
--- /dev/null
@@ -0,0 +1,77 @@
+#!/bin/sh
+#
+# xen-watchdog         Run XEN domain watchdog daemon
+#
+# chkconfig:           2345 21 79
+# description:         Run XEN domain watchdog daemon
+# processname:         xenwatchdogd
+#
+### BEGIN INIT INFO
+# Provides:          xen-watchdog
+# Required-Start:    $syslog $remote_fs
+# Should-Start:      xend
+# Required-Stop:     $syslog $remote_fs
+# Should-Stop:       xend
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start/stop xen-watchdog
+# Description:       Run XEN domain watchdog daemon.
+### END INIT INFO
+#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+start() {
+       if [ -f /var/lock/subsys/xen-watchdog ]; then
+               msg_already_running "XEN domain watchdog daemon"
+               return
+       fi
+       msg_starting "XEN domain watchdog daemon"
+
+       /usr/sbin/xenwatchdogd 30 15
+       RETVAL=$?
+       if [ $RETVAL -ne 0 ]; then
+               return 7
+       fi
+       touch /var/lock/subsys/xen-watchdog
+}
+
+stop() {
+       if [ ! -f /var/lock/subsys/xen-watchdog ]; then
+               msg_not_running "XEN domain watchdog daemon"
+               return
+       fi
+       msg_stopping "XEN domain watchdog daemon"
+
+       killproc xenwatchdogd -USR1
+       RETVAL=$?
+       rm -f /var/lock/subsys/xen-watchdog
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart)
+       stop
+       start
+       ;;
+  status)
+       status xenwatchdogd
+       ;;
+  condrestart)
+       stop
+       start
+       ;;
+  *)
+       msg_usage "$0 {start|stop|status|restart|condrestart}"
+       exit 3
+esac
+
+exit $RETVAL
diff --git a/xen-watchdog.service b/xen-watchdog.service
new file mode 100644 (file)
index 0000000..9d0674c
--- /dev/null
@@ -0,0 +1,12 @@
+[Unit]
+Description=Xen-watchdog - run xen watchdog daemon
+Requires=proc-xen.mount
+After=proc-xen.mount xend.service
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/xenwatchdogd 30 15
+KillSignal=USR1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/xen.logrotate b/xen.logrotate
new file mode 100644 (file)
index 0000000..9bcb186
--- /dev/null
@@ -0,0 +1,8 @@
+/var/log/xen/xend-debug.log
+/var/log/xen/xen-hotplug.log
+/var/log/xen/domain-builder-ng.log {
+       notifempty
+       missingok
+       copytruncate
+}
+
index 580df59c8368903da952b189aad50d5bbdb30ead..8f926afe531ffcb04ffa7c566a2b2f7441f9df6c 100644 (file)
--- a/xen.spec
+++ b/xen.spec
@@ -3,9 +3,6 @@
 #  - most of the qemu config options aren't detected (curses, NPTL, vde, fdt)
 #  - package the ocaml stuff
 #
-# Conditional build:
-%bcond_without hvm             # build with hvm (full virtualization) support
-
 %define        xen_extfiles_url        http://xenbits.xensource.com/xen-extfiles
 Summary:       Xen - a virtual machine monitor
 Summary(pl.UTF-8):     Xen - monitor maszyny wirtualnej
@@ -29,6 +26,25 @@ Source14: %{xen_extfiles_url}/grub-0.97.tar.gz
 # Source14-md5:        cd3f3eb54446be6003156158d51f4884
 Source15: %{xen_extfiles_url}/ipxe-git-v1.0.0.tar.gz
 # Source15-md5:        fb7df96781d337899066d82059346885
+Source30:      proc-xen.mount
+Source31:      var-lib-xenstored.mount
+Source32:      blktapctrl.service
+Source33:      blktapctrl.sysconfig
+Source34:      xenconsoled.service
+Source35:      xenconsoled.sysconfig
+Source36:      xenstored.service
+Source37:      xenstored.sysconfig
+Source38:      xenstored.tmpfiles
+Source39:      xend.service
+Source40:      xend.tmpfiles
+Source41:      xen-watchdog.service
+# sysvinit scripts
+Source50:      xend.init
+Source51:      xenconsoled.init
+Source52:      xenstored.init
+Source53:      xen-watchdog.init
+Source54:      xendomains.init
+Source55:      xen.logrotate
 Patch0:                %{name}-python_scripts.patch
 Patch1:                %{name}-symbols.patch
 Patch2:                %{name}-curses.patch
@@ -37,7 +53,7 @@ Patch4:               %{name}-xz.patch
 URL:           http://www.cl.cam.ac.uk/Research/SRG/netos/xen/index.html
 BuildRequires: SDL-devel
 BuildRequires: acpica
-%{?with_hvm:BuildRequires:     bcc}
+BuildRequires: bcc
 BuildRequires: curl-devel
 BuildRequires: e2fsprogs-devel
 BuildRequires: gcc >= 5:3.4
@@ -72,6 +88,7 @@ Requires:     sed
 Requires:      util-linux
 Requires:      which
 Obsoletes:     xen-doc
+Obsoletes:     xen-udev
 ExclusiveArch: %{ix86} %{x8664}
 BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
@@ -139,17 +156,6 @@ Static xen libraries.
 %description static -l pl.UTF-8
 Statyczne biblioteki xena.
 
-%package udev
-Summary:       xen udev scripts
-Summary(pl.UTF-8):     Skrypty udev dla xena
-Group:         Applications/System
-
-%description udev
-xen udev scripts.
-
-%description udev -l pl.UTF-8
-Skrypty udev dla xena.
-
 %package xend
 Summary:       xend daemon
 Summary(pl.UTF-8):     Demon xend
@@ -198,21 +204,50 @@ ln -s %{PATCH23} stubdom/grub.patches/99grub-ext4-support.patch
 ln -s %{SOURCE15} tools/firmware/etherboot/ipxe.tar.gz
 
 %build
-CFLAGS="%{rpmcflags} -I/usr/include/ncurses" \
-CXXFLAGS="%{rpmcflags} -I/usr/include/ncurses" \
-%{__make} -j1 xen tools \
+export CFLAGS="%{rpmcflags} -I/usr/include/ncurses"
+export CXXFLAGS="%{rpmcflags} -I/usr/include/ncurses"
+
+%{__make} dist-xen dist-tools dist-docs \
+       prefix=%{_prefix} \
+       CC="%{__cc}" \
+       CXX="%{__cxx}"
+
+unset CFLAGS
+unset CXXFLAGS
+%{__make} -j1 dist-stubdom \
        CC="%{__cc}" \
        CXX="%{__cxx}"
 
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT/etc/xen/examples
+install -d $RPM_BUILD_ROOT/etc/xen/examples \
+       $RPM_BUILD_ROOT{/usr/lib/tmpfiles.d,%{systemdunitdir}}
 
-%{__make} install-xen install-tools install-stubdom install-docs \
-       CC="%{__cc}" \
-       CXX="%{__cxx}" \
+%{__make} -j1 install-xen install-tools install-stubdom install-docs \
+       prefix=%{_prefix} \
        DESTDIR=$RPM_BUILD_ROOT
 
+install %{SOURCE30} $RPM_BUILD_ROOT%{systemdunitdir}/proc-xen.mount
+install %{SOURCE31} $RPM_BUILD_ROOT%{systemdunitdir}/var-lib-xenstored.mount
+install %{SOURCE32} $RPM_BUILD_ROOT%{systemdunitdir}/blktapctrl.service
+install %{SOURCE33} $RPM_BUILD_ROOT/etc/sysconfig/blktapctrl.sysconfig
+install %{SOURCE34} $RPM_BUILD_ROOT%{systemdunitdir}/xenconsoled.service
+install %{SOURCE35} $RPM_BUILD_ROOT/etc/sysconfig/xenconsoled.sysconfig
+install %{SOURCE36} $RPM_BUILD_ROOT%{systemdunitdir}/xenstored.service
+install %{SOURCE37} $RPM_BUILD_ROOT/etc/sysconfig/xenstored.sysconfig
+install %{SOURCE38} $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/xenstored.conf
+install %{SOURCE39} $RPM_BUILD_ROOT%{systemdunitdir}/xend.service
+install %{SOURCE40} $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/xend.conf
+install %{SOURCE41} $RPM_BUILD_ROOT%{systemdunitdir}/xen-watchdog.service
+# sysvinit scripts
+%{__rm} $RPM_BUILD_ROOT/etc/rc.d/init.d/*
+install %{SOURCE50} $RPM_BUILD_ROOT/etc/rc.d/init.d/xend
+install %{SOURCE51} $RPM_BUILD_ROOT/etc/rc.d/init.d/xenconsoled
+install %{SOURCE52} $RPM_BUILD_ROOT/etc/rc.d/init.d/xenstored
+install %{SOURCE53} $RPM_BUILD_ROOT/etc/rc.d/init.d/xen-watchdog
+install %{SOURCE54} $RPM_BUILD_ROOT/etc/rc.d/init.d/xendomains
+#install %{SOURCE55} $RPM_BUILD_ROOT/etc/logrotate.d/xen
+
 mv $RPM_BUILD_ROOT/etc/xen/{xmexample*,examples}
 
 cp -p tools/blktap/README{,.blktap}
@@ -234,7 +269,8 @@ rm -rf $RPM_BUILD_ROOT
 
 %post
 /sbin/chkconfig --add xen-watchdog
-/sbin/chkconfig --add xencommons
+/sbin/chkconfig --add xenconsoled
+/sbin/chkconfig --add xenstored
 /sbin/chkconfig --add xendomains
 
 %preun
@@ -242,8 +278,11 @@ if [ "$1" = "0" ]; then
        %service xendomains stop
        /sbin/chkconfig --del xendomains
 
-       %service xencommons stop
-       /sbin/chkconfig --del xencommons
+       %service xenconsoled stop
+       /sbin/chkconfig --del xenconsoled
+
+       %service xenstored stop
+       /sbin/chkconfig --del xenstored
 
        %service xen-watchdog stop
        /sbin/chkconfig --del xen-watchdog
@@ -270,10 +309,17 @@ fi
 /boot/%{name}-syms-%{version}
 /boot/%{name}-%{version}.gz
 /boot/%{name}.gz
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/*
 %attr(754,root,root) /etc/rc.d/init.d/xen-watchdog
-%attr(754,root,root) /etc/rc.d/init.d/xencommons
+%attr(754,root,root) /etc/rc.d/init.d/xenconsoled
+%attr(754,root,root) /etc/rc.d/init.d/xenstored
 %attr(754,root,root) /etc/rc.d/init.d/xendomains
-%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/*
+%{systemdunitdir}/proc-xen.mount
+%{systemdunitdir}/var-lib-xenstored.mount
+%{systemdunitdir}/blktapctrl.service
+%{systemdunitdir}/xen-watchdog.service
+%{systemdunitdir}/xenconsoled.service
+%{systemdunitdir}/xenstored.service
 %dir %{_sysconfdir}/xen
 %dir %{_sysconfdir}/xen/auto
 %dir %{_sysconfdir}/xen/examples
@@ -283,6 +329,7 @@ fi
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/xen/README*
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/xen/cpupool
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/xen/xl.conf
+%config(noreplace) %verify(not md5 mtime size) /etc/udev/*
 %attr(755,root,root) %{_bindir}/*
 %attr(755,root,root) %{_sbindir}/[bfgikloqtv]*
 %attr(755,root,root) %{_sbindir}/xen??*
@@ -293,14 +340,22 @@ fi
 %attr(744,root,root) %{_libdir}/%{name}/bin/*
 %if "%{_lib}" != "lib"
 %dir %{_prefix}/lib/%{name}
+%dir %{_prefix}/lib/%{name}/bin
+%attr(755,root,root) %{_prefix}/lib/%{name}/bin/qemu-dm
+%attr(755,root,root) %{_prefix}/lib/%{name}/bin/stubdom-dm
+%attr(755,root,root) %{_prefix}/lib/%{name}/bin/stubdompath.sh
 %endif
 %dir %{_prefix}/lib/%{name}/boot
-%{?with_hvm:%attr(744,root,root) %{_prefix}/lib/%{name}/boot/hvmloader}
+%{_prefix}/lib/%{name}/boot/ioemu-stubdom.gz
+%{_prefix}/lib/%{name}/boot/pv-grub-x86_32.gz
+%{_prefix}/lib/%{name}/boot/pv-grub-x86_64.gz
+%attr(744,root,root) %{_prefix}/lib/%{name}/boot/hvmloader
 %{_datadir}/xen
 %{_mandir}/man?/*
 %{_sharedstatedir}/xen
 %{_sharedstatedir}/xenstored
 %dir /var/run/xenstored
+%{systemdtmpfilesdir}/xenstored.conf
 
 %files libs
 %defattr(644,root,root,755)
@@ -323,18 +378,16 @@ fi
 %defattr(644,root,root,755)
 %{_libdir}/lib*.a
 
-%files udev
-%defattr(644,root,root,755)
-%config(noreplace) %verify(not md5 mtime size) /etc/udev/*
-
 %files xend
 %defattr(644,root,root,755)
 %attr(754,root,root) %{_sysconfdir}/rc.d/init.d/xend
+%{systemdunitdir}/xend.service
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/xen/xm*
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/xen/xend*
 %attr(755,root,root) %{_sbindir}/xend
 %attr(755,root,root) %{_sbindir}/xm
 %dir %attr(700,root,root) /var/run/xend
+%{systemdtmpfilesdir}/xend.conf
 
 %files -n python-xen
 %defattr(644,root,root,755)
diff --git a/xenconsoled.init b/xenconsoled.init
new file mode 100644 (file)
index 0000000..23db81d
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/sh
+#
+# xenconsoled  Script to start and stop xenconsoled
+#
+# chkconfig:   2345 70 10
+# description: Starts and stops xenconsoled
+### BEGIN INIT INFO
+# Provides:          xenconsoled
+# Required-Start:    $syslog $remote_fs
+# Should-Start:
+# Required-Stop:     $syslog $remote_fs
+# Should-Stop:
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start/stop xenconsoled
+# Description:       Starts and stops the daemons neeeded for xl/xend
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Read in configuration options.
+XENCONSOLED_ARGS=
+XENCONSOLED_LOG=none
+XENCONSOLED_LOG_DIR=/var/log/xen/console
+[ -f /etc/sysconfig/xenconsoled ] && . /etc/sysconfig/xenconsoled
+
+if [ "$1" = "start" -a -d /proc/xen -a ! -f /proc/xen/capabilities ] && \
+               ! grep -qs '^xenfs ' /proc/mounts >/dev/null; then
+       mount -t xenfs xenfs /proc/xen
+fi
+
+grep -qs "control_d" /proc/xen/capabilities || exit 0
+
+start() {
+       if [ -f /var/lock/subsys/xenconsoled ]; then
+               msg_already_running xenconsoled
+               return
+       fi
+       msg_starting xenconsoled
+       daemon /usr/sbin/xenconsoled --pidfile=/var/run/xenconsoled.pid --log=${XENCONSOLED_LOG} --log-dir=${XENCONSOLED_LOG_DIR} $XENCONSOLED_ARGS
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xenconsoled
+}
+
+stop() {
+       if [ ! -f /var/lock/subsys/xenconsoled ]; then
+               msg_not_running xenconsoled
+               return
+       fi
+       msg_stopping xenconsoled
+       killproc --pidfile /var/run/xenconsoled.pid xenconsoled
+       RETVAL=$?
+       rm -f /var/run/xenconsoled.pid >/dev/null 2>&1
+       rm -f /var/lock/subsys/xenconsoled >/dev/null 2>&1
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  status)
+        status xenconsoled
+       ;;
+  stop)
+       stop
+       ;;
+  force-reload|restart)
+        stop
+       start
+       ;;
+  *)
+       msg_usage "$0 {start|stop|status|restart|force-reload}"
+       exit 3
+esac
+
+exit $RETVAL
diff --git a/xenconsoled.service b/xenconsoled.service
new file mode 100644 (file)
index 0000000..cd3482a
--- /dev/null
@@ -0,0 +1,17 @@
+[Unit]
+Description=Xenconsoled - handles logging from guest consoles and hypervisor
+Requires=proc-xen.mount
+After=proc-xen.mount xenstored.service
+
+[Service]
+Type=simple
+Environment=XENCONSOLED_ARGS=
+Environment=XENCONSOLED_LOG=none
+Environment=XENCONSOLED_LOG_DIR=/var/log/xen/console
+EnvironmentFile=-/etc/sysconfig/xenconsoled
+PIDFile=/var/run/xenconsoled.pid
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStart=/usr/sbin/xenconsoled --log=${XENCONSOLED_LOG} --log-dir=${XENCONSOLED_LOG_DIR} $XENCONSOLED_ARGS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/xenconsoled.sysconfig b/xenconsoled.sysconfig
new file mode 100644 (file)
index 0000000..f4f2191
--- /dev/null
@@ -0,0 +1,7 @@
+# Log xenconsoled messages (none|guest console only|hypervisor messages only|both)
+#XENCONSOLED_LOG=[none|guest|hv|all]
+
+# Location to store guest & hypervisor logs
+#XENCONSOLED_LOG_DIR=/var/log/xen/console
+
+#XENCONSOLED_ARGS=
diff --git a/xend.init b/xend.init
new file mode 100644 (file)
index 0000000..eabc399
--- /dev/null
+++ b/xend.init
@@ -0,0 +1,117 @@
+#!/bin/sh
+#
+# xend         Script to start and stop the Xen control daemon.
+#
+# chkconfig:   2345 98 01
+# description: Starts and stops the Xen control daemon.
+#
+### BEGIN INIT INFO
+# Provides:          xend
+# Required-Start:    $syslog $remote_fs xenstored xenconsoled 
+# Should-Start:
+# Required-Stop:     $syslog $remote_fs xenstored xenconsoled 
+# Should-Stop:
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start/stop xend
+# Description:       Starts and stops the Xen control daemon.
+### END INIT INFO
+
+waitfordaemon() {
+       i=1
+       rets=10
+       /usr/sbin/xend status
+       while [ $? -ne 0 -a $i -lt $rets ]; do
+               sleep 1
+               i=$(($i + 1))
+               /usr/sbin/xend status
+       done
+       return $?
+}
+
+start() {
+       if [ -f /var/lock/subsys/xend ]; then
+               msg_already_running "Xen control daemon"
+               return
+       fi
+       if [ ! -f /var/lock/subsys/xenconsoled -o ! -f /var/lock/subsys/xenstored ]; then
+               echo "xenconsoled and xenstored must be started first"
+               return
+       fi
+       show "Starting Xen control daemon"
+       busy
+       /usr/sbin/xend start
+       waitfordaemon
+       RETVAL=$?
+       if [ $RETVAL -eq 0 ]; then
+               touch /var/lock/subsys/xend
+               ok
+       else
+               fail
+       fi
+}
+
+stop() {
+       if [ ! -f /var/lock/subsys/xend ]; then
+               msg_not_running "Xen control daemon"
+               return
+       fi
+       show "Stopping Xen control daemon"
+       busy
+       /usr/sbin/xend stop
+       ok
+       rm -f /var/lock/subsys/xend
+}
+
+reload() {
+       if [ ! -f /var/lock/subsys/xend ]; then
+               msg_not_running "Xen control daemon"
+               return
+       fi
+       show "Reloading Xen control daemon"
+       busy
+       /usr/sbin/xend reload
+       ok
+}
+
+restartp() {
+       if [ ! -f /var/lock/subsys/xend ]; then
+               msg_not_running "Xen control daemon"
+               return
+       fi
+       show "Restarting Xen control daemon"
+       busy
+       /usr/sbin/xend restart
+       waitfordaemon
+       RETVAL=$?
+       if [ $RETVAL -eq 0 ]; then
+               ok
+       else
+               fail
+       fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  status)
+       /usr/sbin/xend status
+       ;;
+  reload)
+        reload
+        ;;
+  restart|force-reload)
+       restart
+       ;;
+  *)
+       msg_usage "$0 {start|stop|status|restart|reload|force-reload}"
+       exit 3
+esac
+
+exit $RETVAL
diff --git a/xend.service b/xend.service
new file mode 100644 (file)
index 0000000..b6b462d
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=Xend - interface between hypervisor and some applications
+Requires=proc-xen.mount
+After=proc-xen.mount
+Before=libvirtd.service libvirt-guests.service
+
+[Service]
+Type=forking
+PIDFile=/var/run/xend.pid
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStart=/usr/sbin/xend
+
+[Install]
+WantedBy=multi-user.target
diff --git a/xend.tmpfiles b/xend.tmpfiles
new file mode 100644 (file)
index 0000000..84048e6
--- /dev/null
@@ -0,0 +1,2 @@
+d /var/run/xend 0700 root root -
+d /var/run/xend/boot 0700 root root -
diff --git a/xendomains.init b/xendomains.init
new file mode 100644 (file)
index 0000000..3a6d34a
--- /dev/null
@@ -0,0 +1,401 @@
+#!/bin/sh
+#
+# xendomains           Start / stop domains automatically when domain 0 boots / shuts down.
+#
+# chkconfig:           345 99 00
+# description:         Start / stop Xen domains.
+#
+# This script offers fairly basic functionality.  It should work on Redhat
+# but also on LSB-compliant SuSE releases and on Debian with the LSB package
+# installed.  (LSB is the Linux Standard Base)
+#
+# Based on the example in the "Designing High Quality Integrated Linux
+# Applications HOWTO" by Avi Alkalay
+# <http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/>
+#
+### BEGIN INIT INFO
+# Provides:          xendomains
+# Required-Start:    $syslog $remote_fs xenstored xenconsoled
+# Should-Start:      xend
+# Required-Stop:     $syslog $remote_fs xenstored xenconsoled
+# Should-Stop:       xend
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start/stop secondary xen domains
+# Description:       Start / stop domains automatically when domain 0 
+#                    boots / shuts down.
+### END INIT INFO
+
+. /etc/rc.d/init.d/functions
+
+CMD=xm
+$CMD list >/dev/null 2>/dev/null || CMD=xl
+$CMD list >/dev/null 2>/dev/null || exit 0
+
+[ -e /proc/xen/privcmd ] || exit 0
+
+if [ -r /etc/sysconfig/xendomains ]; then
+       . /etc/sysconfig/xendomains
+else
+       echo "/etc/sysconfig/xendomains does not exist"
+       if [ "$1" = "stop" ]; then
+               exit 0
+       else
+               exit 6
+       fi
+fi
+
+##
+# Returns 0 (success) if the given parameter names a directory, and that
+# directory is not empty.
+#
+contains_something() {
+  if [ -d "$1" ] && [ `/bin/ls $1 | wc -l` -gt 0 ]; then
+       return 0
+  else
+       return 1
+  fi
+}
+
+# read name from xen config file
+rdname() {
+       NM=$($CMD create --quiet --dryrun --defconfig "$1" | sed -n 's/^.*(name \(.*\))$/\1/p')
+}
+
+rdnames() {
+    NAMES=
+    if ! contains_something "$XENDOMAINS_AUTO"; then 
+       return
+    fi
+    for dom in $XENDOMAINS_AUTO/*; do
+       rdname $dom
+       if test -z $NAMES; then 
+           NAMES=$NM; 
+       else
+           NAMES="$NAMES|$NM"
+       fi
+    done
+}
+
+parseln() {
+    if [[ "$1" =~ '(domain' ]]; then
+        name=;id=
+    else if [[ "$1" =~ '(name' ]]; then
+        name=$(echo $1 | sed -e 's/^.*(name \(.*\))$/\1/')
+    else if [[ "$1" =~ '(domid' ]]; then
+        id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/')
+    fi; fi; fi
+
+    [ -n "$name" -a -n "$id" ] && return 0 || return 1
+}
+
+is_running() {
+    rdname $1
+    RC=1
+    name=;id=
+    while read LN; do
+       parseln "$LN" || continue
+       [ $id = 0 ] && continue
+       case $name in 
+           ($NM)
+               RC=0
+               ;;
+       esac
+    done < <($CMD list -l | grep '(\(domain\|domid\|name\)')
+    return $RC
+}
+
+start() {
+    if [ -f /var/lock/subsys/xendomains ]; then 
+       echo -e "xendomains already running (lockfile exists)"
+       return 
+    fi
+
+    saved_domains=" "
+    if [ "$XENDOMAINS_RESTORE" = "true" ] && contains_something "$XENDOMAINS_SAVE"; then
+       mkdir -p $(dirname "/var/lock/subsys/xendomains")
+       touch /var/lock/subsys/xendomains
+       echo -n "Restoring Xen domains:"
+       saved_domains=`ls $XENDOMAINS_SAVE`
+        for dom in $XENDOMAINS_SAVE/*; do
+            if [ -f $dom ] ; then
+                HEADER=`head -c 16 $dom | head -n 1 2> /dev/null`
+                if [ $HEADER = "LinuxGuestRecord" ]; then
+                    echo -n " ${dom##*/}"
+                    XMR=`$CMD restore $dom 2>&1 1>/dev/null`
+                    #$CMD restore $dom
+                    if [ $? -ne 0 ]; then
+                        echo -e "\nAn error occurred while restoring domain ${dom##*/}:\n$XMR"
+                        echo -e '!'
+                    else
+                        # mv $dom ${dom%/*}/.${dom##*/}
+                        rm $dom
+                    fi
+                fi
+            fi
+        done
+       echo -e
+    fi
+
+    if contains_something "$XENDOMAINS_AUTO" ; then
+       touch /var/lock/subsys/xendomains
+       echo -n "Starting auto Xen domains:"
+       # We expect config scripts for auto starting domains to be in
+       # XENDOMAINS_AUTO - they could just be symlinks to files elsewhere
+
+       # Create all domains with config files in XENDOMAINS_AUTO.
+       # TODO: We should record which domain name belongs 
+       # so we have the option to selectively shut down / migrate later
+       # If a domain statefile from $XENDOMAINS_SAVE matches a domain name
+       # in $XENDOMAINS_AUTO, do not try to start that domain; if it didn't 
+       # restore correctly it requires administrative attention.
+       for dom in $XENDOMAINS_AUTO/*; do
+           echo -n " ${dom##*/}"
+           shortdom=$(echo $dom | sed -n 's/^.*\/\(.*\)$/\1/p')
+           echo $saved_domains | grep -w $shortdom > /dev/null
+           if [ $? -eq 0 ] || is_running $dom; then
+               echo -n "(skip)"
+           else
+               XMC=`$CMD create --quiet --defconfig $dom`
+               if [ $? -ne 0 ]; then
+                   echo -e "\nAn error occurred while creating domain ${dom##*/}: $XMC\n"
+                   echo -e '!'
+               else
+                   usleep $XENDOMAINS_CREATE_USLEEP
+               fi
+           fi
+       done
+    fi
+}
+
+all_zombies() {
+    name=;id=
+    while read LN; do
+       parseln "$LN" || continue
+       if test $id = 0; then continue; fi
+       if test "$state" != "-b---d" -a "$state" != "-----d"; then
+           return 1;
+       fi
+    done < <($CMD list -l | grep '(\(domain\|domid\|name\)')
+    return 0
+}
+
+# Wait for max $XENDOMAINS_STOP_MAXWAIT for $CMD $1 to finish;
+# if it has not exited by that time kill it, so the init script will
+# succeed within a finite amount of time; if $2 is nonnull, it will
+# kill the command as well as soon as no domain (except for zombies)
+# are left (used for shutdown --all). Third parameter, if any, suppresses
+# output of dots per working state (formatting issues)
+watchdog_xencmd() {
+    if test -z "$XENDOMAINS_STOP_MAXWAIT" -o "$XENDOMAINS_STOP_MAXWAIT" = "0"; then
+       exit
+    fi
+
+    usleep 20000
+    for no in `seq 0 $XENDOMAINS_STOP_MAXWAIT`; do
+       # exit if $CMD save/migrate/shutdown is finished
+       PSAX=`ps axlw | grep "$CMD $1" | grep -v grep`
+       if test -z "$PSAX"; then exit; fi
+       if ! test -n "$3"; then echo -n '.'; fi
+       sleep 1
+       # go to kill immediately if there's only zombies left
+       if all_zombies && test -n "$2"; then break; fi
+    done
+    sleep 1
+    read PSF PSUID PSPID PSPPID < <(echo "$PSAX")
+    # kill $CMD $1
+    kill $PSPID >/dev/null 2>&1
+    
+    echo -e .
+}
+
+stop() {
+    # Collect list of domains to shut down
+    if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
+       rdnames
+    fi
+    echo -n "Shutting down Xen domains:"
+    name=;id=
+    while read LN; do
+       parseln "$LN" || continue
+       if test $id = 0; then continue; fi
+       echo -n " $name"
+       if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
+           eval "
+           case \"\$name\" in
+               ($NAMES)
+                   # nothing
+                   ;;
+               (*)
+                   echo -e '(skip)'
+                   continue
+                   ;;
+           esac
+           "
+       fi
+       # XENDOMAINS_SYSRQ chould be something like just "s" 
+       # or "s e i u" or even "s e s i u o"
+       # for the latter, you should set XENDOMAINS_USLEEP to 1200000 or so
+       if test -n "$XENDOMAINS_SYSRQ"; then
+           for sysrq in $XENDOMAINS_SYSRQ; do
+               echo -n "(SR-$sysrq)"
+               XMR=`$CMD sysrq $id $sysrq 2>&1 1>/dev/null`
+               if test $? -ne 0; then
+                   echo -e "\nAn error occurred while doing sysrq on domain:\n$XMR\n"
+                   echo -n '!'
+               fi
+               # usleep just ignores empty arg
+               usleep $XENDOMAINS_USLEEP
+           done
+       fi
+       if test "$state" = "-b---d" -o "$state" = "-----d"; then
+           echo -n "(zomb)"
+           continue
+       fi
+       if test -n "$XENDOMAINS_MIGRATE"; then
+           echo -n "(migr)"
+           watchdog_xencmd migrate &
+           WDOG_PID=$!
+           XMR=`$CMD migrate $id $XENDOMAINS_MIGRATE 2>&1 1>/dev/null`
+           if test $? -ne 0; then
+               echo -e "\nAn error occurred while migrating domain:\n$XMR\n"
+               echo -e '!'
+
+               kill $WDOG_PID >/dev/null 2>&1
+           else
+               kill $WDOG_PID >/dev/null 2>&1
+               
+               echo -e .
+               usleep 1000
+               continue
+           fi
+       fi
+       if test -n "$XENDOMAINS_SAVE"; then
+           echo -n "(save)"
+           watchdog_xencmd save &
+           WDOG_PID=$!
+           mkdir -p "$XENDOMAINS_SAVE"
+           XMR=`$CMD save $id $XENDOMAINS_SAVE/$name 2>&1 1>/dev/null`
+           if test $? -ne 0; then
+               echo -e "\nAn error occurred while saving domain:\n$XMR\n"
+               echo -e '!'
+               kill $WDOG_PID >/dev/null 2>&1
+           else
+               kill $WDOG_PID >/dev/null 2>&1
+               echo -e .
+               usleep 1000
+               continue
+           fi
+       fi
+       if test -n "$XENDOMAINS_SHUTDOWN"; then
+           # XENDOMAINS_SHUTDOWN should be "--halt --wait"
+           echo -n "(shut)"
+           watchdog_xencmd shutdown &
+           WDOG_PID=$!
+           XMR=`$CMD shutdown $id $XENDOMAINS_SHUTDOWN 2>&1 1>/dev/null`
+           if test $? -ne 0; then
+               echo -e "\nAn error occurred while shutting down domain:\n$XMR\n"
+               echo -e '!'
+           fi
+           kill $WDOG_PID >/dev/null 2>&1
+       fi
+    done < <($CMD list -l | grep '(\(domain\|domid\|name\)')
+
+    # NB. this shuts down ALL Xen domains (politely), not just the ones in
+    # AUTODIR/*
+    # This is because it's easier to do ;-) but arguably if this script is run
+    # on system shutdown then it's also the right thing to do.
+    if ! all_zombies && test -n "$XENDOMAINS_SHUTDOWN_ALL"; then
+       # XENDOMAINS_SHUTDOWN_ALL should be "--all --halt --wait"
+       echo -n " SHUTDOWN_ALL "
+       watchdog_xencmd shutdown 1 false &
+       WDOG_PID=$!
+       XMR=`$CMD shutdown $XENDOMAINS_SHUTDOWN_ALL 2>&1 1>/dev/null`
+       if test $? -ne 0; then
+           echo -e "\nAn error occurred while shutting down all domains: $XMR\n"
+           echo -e '!'
+       fi
+       kill $WDOG_PID >/dev/null 2>&1
+    fi
+
+    # Unconditionally delete lock file
+    rm -f /var/lock/subsys/xendomains
+}
+
+check_domain_up()
+{
+    name=;id=
+    while read LN; do
+       parseln "$LN" || continue
+       if test $id = 0; then continue; fi
+       case $name in 
+           ($1)
+               return 0
+               ;;
+       esac
+    done < <($CMD list -l | grep '(\(domain\|domid\|name\)')
+    return 1
+}
+
+check_all_auto_domains_up()
+{
+    if ! contains_something "$XENDOMAINS_AUTO"; then
+      return 0
+    fi
+    missing=
+    for nm in $XENDOMAINS_AUTO/*; do
+       rdname $nm
+       found=0
+       if check_domain_up "$NM"; then 
+           echo -n " $name"
+       else 
+           missing="$missing $NM"
+       fi
+    done
+    if test -n "$missing"; then
+       echo -n " MISS AUTO:$missing"
+       return 1
+    fi
+    return 0
+}
+
+check_all_saved_domains_up()
+{
+    if ! contains_something "$XENDOMAINS_SAVE"; then
+      return 0
+    fi
+    missing=`/bin/ls $XENDOMAINS_SAVE`
+    echo -n " MISS SAVED: " $missing
+    return 1
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+    start)
+       start
+       ;;
+    stop)
+       stop
+       ;;
+    restart|reload)
+# This does NOT necessarily restart all running domains: instead it
+# stops all running domains and then boots all the domains specified in
+# AUTODIR.  If other domains have been started manually then they will
+# not get restarted.
+    stop
+    start
+       ;;
+    status)
+       if [ -f /var/lock/subsys/xendomains; then
+           echo -n "Checking for xendomains:" 
+           check_all_auto_domains_up
+           check_all_saved_domains_up
+       fi
+       ;;
+    *)
+       msg_usage "$0 {start|stop|restart|reload|status}"
+       ;;
+esac
+
+exit $RETVAL
diff --git a/xenstored.init b/xenstored.init
new file mode 100644 (file)
index 0000000..b65b939
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/sh
+#
+# xenstored    Script to start and stop xenstored
+#
+# chkconfig:   2345 70 10
+# description: Starts and stops xenstored
+#
+### BEGIN INIT INFO
+# Provides:          xenstored
+# Required-Start:    $syslog $remote_fs
+# Should-Start:
+# Required-Stop:     $syslog $remote_fs
+# Should-Stop:
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start/stop xenstored
+# Description:       Starts and stops the daemons neeeded for xl/xend
+### END INIT INFO
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Read in configuration options.
+[ /etc/sysconfig/xenstored ] && . /etc/sysconfig/xenstored
+
+if [ "$1" = "start" -a -d /proc/xen -a ! -f /proc/xen/capabilities ] && \
+               ! grep -qs '^xenfs ' /proc/mounts >/dev/null; then
+       mount -t xenfs xenfs /proc/xen
+fi
+
+grep -qs "control_d" /proc/xen/capabilities || exit 0
+
+start () {
+       if [ -f /var/lock/subsys/xenstored ]; then
+               msg_already_running xenstored
+               return
+       fi
+       xenstore-read -s / >/dev/null 2>/dev/null && return
+
+       [ -z "$XENSTORED_ROOTDIR" ] || XENSTORED_ROOTDIR="/var/lib/xenstored"
+       rm -f "$XENSTORED_ROOTDIR"/tdb* >/dev/null 2>/dev/null
+
+       show "Starting xenstored"
+       busy
+       /usr/sbin/xenstored --pid-file=/var/run/xenstored.pid $XENSTORED_ARGS
+
+       # Wait for xenstored to actually come up, timing out after 30 seconds
+        time=0
+       timeout=30
+        while [ $time -lt $timeout ] && ! xenstore-read -s / >/dev/null 2>/dev/null ; do
+           time=$(($time+1))
+            sleep 1
+        done
+
+       if [ $time -ge $timeout ]; then
+               fail
+               RETVAL=1
+               return
+       fi
+       ok
+
+       show "Setting domain 0 name"
+       busy
+       xenstore-write "/local/domain/0/name" "Domain-0"
+       ok
+       touch /var/lock/subsys/xenstored
+}
+
+stop() {
+       if [ -f /var/lock/subsys/xenstored ]; then
+               echo WARNING: Not stopping xenstored, as it cannot be restarted.
+       fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  status)
+       status xenstored
+        xenstore-read -s /
+       ;;
+  stop)
+       stop
+       ;;
+  force-reload|restart)
+        stop
+       start
+       ;;
+  *)
+       msg_usage "$0 {start|stop|status|restart|force-reload}"
+       exit 3
+esac
+
+exit $RETVAL
diff --git a/xenstored.service b/xenstored.service
new file mode 100644 (file)
index 0000000..3b0efb6
--- /dev/null
@@ -0,0 +1,19 @@
+[Unit]
+Description=Xenstored - daemon managing xenstore file system
+Requires=proc-xen.mount var-lib-xenstored.mount
+After=proc-xen.mount var-lib-xenstored.mount
+Before=libvirtd.service libvirt-guests.service
+RefuseManualStop=true
+
+[Service]
+Type=forking
+Environment=XENSTORED_ARGS=
+Environment=XENSTORED_ROOTDIR=/var/lib/xenstored
+EnvironmentFile=-/etc/sysconfig/xenstored
+PIDFile=/var/run/xenstored.pid
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStartPre=-/bin/rm -f "$XENSTORED_ROOTDIR"/tdb*
+ExecStart=/usr/sbin/xenstored --pid-file /var/run/xenstored.pid $XENSTORED_ARGS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/xenstored.sysconfig b/xenstored.sysconfig
new file mode 100644 (file)
index 0000000..46e8609
--- /dev/null
@@ -0,0 +1,5 @@
+# Running xenstored on XENSTORED_ROOTDIR
+#XENSTORED_ROOTDIR=/var/lib/xenstored
+
+# Log xenstored messages
+#XENSTORED_ARGS="-T /var/log/xen/xenstored-trace.log"
diff --git a/xenstored.tmpfiles b/xenstored.tmpfiles
new file mode 100644 (file)
index 0000000..3475bd9
--- /dev/null
@@ -0,0 +1 @@
+d /var/run/xenstored 0755 root root -
This page took 0.173752 seconds and 4 git commands to generate.