[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] systemd: add support initial systemd service files



From: "Luis R. Rodriguez" <mcgrof@xxxxxxxx>

I've tested these on an OpenSUSE Tumbleweed source install.
They are based on the ones from OpenSUSE but slightly modified.
In particular the xencommons systemd service file was changed
to not require the capability file to exist prior to
initialization as the xencommons service is the one that
provides it by mounting xenfs for you.

If you don't specify a prefix you will end up with the services
files under /usr/local/lib/systemd/system/ by default, which
systemd does look for. Distributions are expected to provide their
/usr/ prefix to end up in the more generic location upon distribution
install at /usr/lib/systemd/system/.

Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxx>
---
 Config.mk                                |  3 ++-
 Makefile                                 |  5 ++++-
 config/StdGNU.mk                         |  1 +
 tools/hotplug/Linux/Makefile             | 16 +++++++++++++++-
 tools/hotplug/Linux/xen-watchdog.service | 12 ++++++++++++
 tools/hotplug/Linux/xencommons.service   | 12 ++++++++++++
 tools/hotplug/Linux/xend.service         | 14 ++++++++++++++
 tools/hotplug/Linux/xendomains.service   | 14 ++++++++++++++
 8 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 tools/hotplug/Linux/xen-watchdog.service
 create mode 100644 tools/hotplug/Linux/xencommons.service
 create mode 100644 tools/hotplug/Linux/xend.service
 create mode 100644 tools/hotplug/Linux/xendomains.service

diff --git a/Config.mk b/Config.mk
index 84c558b..1affbde 100644
--- a/Config.mk
+++ b/Config.mk
@@ -153,6 +153,7 @@ endef
 define buildmakevars2shellvars
     export PREFIX="$(PREFIX)";                                            \
     export XEN_SCRIPT_DIR="$(XEN_SCRIPT_DIR)";                            \
+    export XEN_SYSTEMD_DIR="$(XEN_SYSTEMD_DIR)";                          \
     export XEN_ROOT="$(XEN_ROOT)"
 endef
 
@@ -174,7 +175,7 @@ define buildmakevars2file-closure
        $(foreach var,                                                      \
                  SBINDIR BINDIR LIBEXEC LIBDIR SHAREDIR PRIVATE_BINDIR     \
                  XENFIRMWAREDIR XEN_CONFIG_DIR XEN_SCRIPT_DIR XEN_LOCK_DIR \
-                 XEN_RUN_DIR XEN_PAGING_DIR,                               \
+                 XEN_SYSTEMD_DIR XEN_RUN_DIR XEN_PAGING_DIR,               \
                  echo "$(var)=\"$($(var))\"" >>$(1).tmp;)        \
        $(call move-if-changed,$(1).tmp,$(1))
 endef
diff --git a/Makefile b/Makefile
index 4e48457..9b5568a 100644
--- a/Makefile
+++ b/Makefile
@@ -243,7 +243,10 @@ uninstall:
        rm -f  $(D)$(CONFIG_DIR)/udev/rules.d/xen-backend.rules
        rm -f  $(D)$(CONFIG_DIR)/udev/rules.d/xend.rules
        rm -f  $(D)$(SYSCONFIG_DIR)/xendomains
-       rm -f  $(D)$(SYSCONFIG_DIR)/xencommons
+       rm -f  $(D)$(XEN_SYSTEMD_DIR)/xencommons.service
+       rm -f  $(D)$(XEN_SYSTEMD_DIR)/xend.service
+       rm -f  $(D)$(XEN_SYSTEMD_DIR)/xendomains.service
+       rm -f  $(D)$(XEN_SYSTEMD_DIR)/xen-watchdog.service
        rm -rf $(D)/var/run/xen* $(D)/var/lib/xen*
        make -C tools uninstall
        rm -rf $(D)/boot/tboot*
diff --git a/config/StdGNU.mk b/config/StdGNU.mk
index 25fc594..14b432d 100644
--- a/config/StdGNU.mk
+++ b/config/StdGNU.mk
@@ -50,6 +50,7 @@ SYSCONFIG_DIR = $(CONFIG_DIR)/$(CONFIG_LEAF_DIR)
 
 XEN_CONFIG_DIR = $(CONFIG_DIR)/xen
 XEN_SCRIPT_DIR = $(XEN_CONFIG_DIR)/scripts
+XEN_SYSTEMD_DIR = $(PREFIX)/lib/systemd/system/
 
 SOCKET_LIBS =
 UTIL_LIBS = -lutil
diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile
index 47655f6..b2fcc2e 100644
--- a/tools/hotplug/Linux/Makefile
+++ b/tools/hotplug/Linux/Makefile
@@ -25,6 +25,11 @@ XEN_SCRIPTS += vscsi
 XEN_SCRIPTS += block-iscsi
 XEN_SCRIPTS += $(XEN_SCRIPTS-y)
 
+XEN_SYSTEMD_FILES = xend.service
+XEN_SYSTEMD_FILES += xencommons.service
+XEN_SYSTEMD_FILES += xendomains.service
+XEN_SYSTEMD_FILES += xen-watchdog.service
+
 XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh
 XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh
 XEN_SCRIPT_DATA += block-common.sh
@@ -40,7 +45,7 @@ all:
 build:
 
 .PHONY: install
-install: all install-initd install-scripts install-udev
+install: all install-initd install-scripts install-udev install-systemd
 
 # See docs/misc/distro_mapping.txt for INITD_DIR location
 .PHONY: install-initd
@@ -69,6 +74,15 @@ install-scripts:
            $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
        done
 
+.PHONY: install-systemd
+install-systemd:
+       [ -d $(DESTDIR)$(XEN_SYSTEMD_DIR) ] || \
+               $(INSTALL_DIR) $(DESTDIR)$(XEN_SYSTEMD_DIR)
+       set -e; for i in $(XEN_SYSTEMD_FILES); \
+           do \
+           $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SYSTEMD_DIR); \
+       done
+
 .PHONY: install-udev
 install-udev:
        [ -d $(DESTDIR)$(UDEV_RULES_DIR) ] || \
diff --git a/tools/hotplug/Linux/xen-watchdog.service 
b/tools/hotplug/Linux/xen-watchdog.service
new file mode 100644
index 0000000..964a399
--- /dev/null
+++ b/tools/hotplug/Linux/xen-watchdog.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Xen-watchdog - run xen watchdog daemon
+After=xencommons.service
+ConditionPathIsDirectory=/proc/xen
+
+[Service]
+Type=forking
+ExecStart=/usr/local/sbin/xenwatchdogd 30 15
+KillSignal=USR1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tools/hotplug/Linux/xencommons.service 
b/tools/hotplug/Linux/xencommons.service
new file mode 100644
index 0000000..8042b24
--- /dev/null
+++ b/tools/hotplug/Linux/xencommons.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Xencommons - Script to start and stop xenstored and xenconsoled
+ConditionPathIsDirectory=/proc/xen
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+ExecStart=-/etc/init.d/xencommons start
+ExecStop=/etc/init.d/xencommons stop
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tools/hotplug/Linux/xend.service b/tools/hotplug/Linux/xend.service
new file mode 100644
index 0000000..97cee20
--- /dev/null
+++ b/tools/hotplug/Linux/xend.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Xend - Starts and stops the Xen management daemon
+Before=libvirtd.service libvirt-guests.service
+ConditionPathIsDirectory=/proc/xen
+
+[Service]
+Type=forking
+PIDFile=/var/run/xend.pid
+Environment=HOME=/root
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStart=/usr/sbin/xend start
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tools/hotplug/Linux/xendomains.service 
b/tools/hotplug/Linux/xendomains.service
new file mode 100644
index 0000000..03158bd
--- /dev/null
+++ b/tools/hotplug/Linux/xendomains.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Xendomains - start and stop Xen VMs on boot and shutdown
+After=xencommons.service network.target
+ConditionPathIsDirectory=/proc/xen
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStart=-/etc/init.d/xendomains start
+ExecStop=/etc/init.d/xendomains stop
+
+[Install]
+WantedBy=multi-user.target
-- 
1.9.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.