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

[Xen-devel] [PATCH v5 14/14] systemd: add xen systemd service and module files



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

This adds the systemd xen service / module files. All of this
is disabled for now, and won't install / build until we hook
up proper support for systemd into the build system.

This goes in with AX_AVAILABLE_SYSTEMD() which will enable
systemd if development libraries have been found on your
build system. If you don't have systemd on target systems
things should still work as we use the dynamic linker
loader through dlopen() and dlsym(). Only systems that
have booted into systemd as its init system are expected
to have systemd libraries present at run time. Binaries
built with systemd support enabled do not need systemd
libaries present unless they actually booted with
systemd as their init.

These are originally based on the Fedora systemd files.

Changes made from Fedora's systemd files:

  * enables systemd socket activation for C xenstored and Ocaml
    oxenstored, this uses the dynamic link loader to enable support
    for one binary under both systemd and non systemd systems.
  * use sd_notify(), so change the service to Type=notify, because of
    this we remove the PIDFile spefification as we don't care, and let
    systemd do its magic for us, this also means we don't have to fork
    so we use --no-fork
  * defines a modules-load.d, its original source file will be shared
    between systemd and old init systems
  * simplify service files with ConditionVirtualization=xen which uses
    the built in systemd virtualization backend detection, these
    service files will not be available to start on systems that do not
    boot with xen as a hypervisor
  * use autoconf to replace @variable@ paths for us which piggy
    backs on top of the latest autoconf changes to xen
  * removes oxenstored service file in favor of a system variable which
    controls which which xentored to use at run time, we avoid multiple
    service files this way. It is technically possible to support
    multiple service files to the two different xenstored's but this is
    rather pointless right now specially since we cannot stop [co]xenstored.
    We instead strive for simplicity with one direct target build
    service file.
  * simplifies startup to not require polling on the sockets
    as initial socket management is handled by systemd, we just
    take on the socket later once anything pokes at it, a simple nc -U
    (as root) on the socket files can activate the service for example.
    Anything queued up will be sent to us once we start. Socket activation
    should in theory also let us dynamically switch between xenstores but more
    importantly we could upgrade xenstored while keeping all active
    socket communication queued up, but in order to take advantage of
    this we eventually would need to remove the requirement of not being
    able to bring down the xenstored. Even though active sockets are
    supported since most libxl communication doesn't triggger a check
    on the unix socket first administrators are encouraged to enable
    the xenstored.service to triggger an initialization of the xenstored
    upon bring up. Some systems also never use unix sockets for
    communication with the xenstored and as such active sockets will
    not be used there.
  * allow for xenstored configuration through *either* of these
    configuration files:
        - /etc/sysconfig/xenstored
        - /etc/default/xenstored
    The /etc/default/xenstored will let debian based systems do
    the same, while SUSE/OpenSUSE/Fedora/RedHat can keep on chugging
    with sysconfig
  * ensures we create the run directory as most systems will likely
    be using a tmpfs for run dirs for the pid files
  * Some systems define the selinux context in the systemd Option for the
    /var/lib/xenstored tmpfs:
        Options=mode=755,context="system_u:object_r:xenstored_var_lib_t:s0"
    For the upstream version we remove that and let systems specify the
    context on their system /etc/default/xenstored or /etc/sysconfig/xenstored
    $XENSTORED_MOUNT_CTX variable, with a default to none.
  * takes advantage of the shared xendomains helper for the xendomains
    service
  * Add the new dom0 that gets kicked off for disk backend access into
    its own systemd service associated to xen

We end up with these systemd files:

General requirements:

  * proc-xen.mount
  * var-lib-xenstored.mount

xenstored:

  * xenstored.service
  * xenstored.socket
  * xenconsoled.service
  * xen-qemu-dom0-disk-backend.service.in

Optional:

  * xendomains.service
  * xen-watchdog.service

As for integration with xen, we house keep all the systemd files
under a new directory tools/hotplug/Linux/systemd/ and will be targetted
by default when building on Linux systems if systemd enabled at
build time, which is only required on the build box, not the user
system.

The systemd files will be sanitized for meta @VARIABLES@ upon
configuration and installed upon the install target. Systems that
do not use systemd can still get systemd service unit files installed
if the build system enabled systemd support, this however does not
mandate a requirement of having systemd libraries present. Old init
scripts are always installed.

If you don't specify a prefix you will end up with the services
files under /usr/local/lib/systemd/system/ by default, and systemd
modules-load.d conf files under /usr/local/lib/modules-load.d/ which
systemd does look for (although it seems this is not documented).

Distributions are expected to provide their /usr/ prefix to end up in
the more generic location upon distribution install at
/usr/lib/systemd/system/ and /usr/lib/modules-load.d/ respectively.

Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Jan RÄkorajski <baggins@xxxxxxxxxxxxx>
Cc: M A Young <m.a.young@xxxxxxxxxxxx>
Cc: Jacek Konieczny <jajcus@xxxxxxxxxx>
Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxx>
---

Please run ./autgen.sh after this patch is applied.

 .gitignore                                         |   5 +
 Makefile                                           |   6 +-
 README                                             |  28 +++++
 config/Tools.mk.in                                 |   6 ++
 m4/README.source                                   |   7 ++
 m4/systemd.m4                                      | 120 +++++++++++++++++++++
 tools/configure.ac                                 |  14 ++-
 tools/hotplug/Linux/Makefile                       |   8 +-
 tools/hotplug/Linux/systemd/Makefile               |  70 ++++++++++++
 tools/hotplug/Linux/systemd/proc-xen.mount.in      |   9 ++
 .../Linux/systemd/var-lib-xenstored.mount.in       |  13 +++
 .../systemd/xen-qemu-dom0-disk-backend.service.in  |  22 ++++
 .../hotplug/Linux/systemd/xen-watchdog.service.in  |  13 +++
 tools/hotplug/Linux/systemd/xenconsoled.service.in |  20 ++++
 tools/hotplug/Linux/systemd/xendomains.service.in  |  16 +++
 tools/hotplug/Linux/systemd/xenstored.service.in   |  27 +++++
 tools/hotplug/Linux/systemd/xenstored.socket.in    |  11 ++
 17 files changed, 390 insertions(+), 5 deletions(-)
 create mode 100644 m4/systemd.m4
 create mode 100644 tools/hotplug/Linux/systemd/Makefile
 create mode 100644 tools/hotplug/Linux/systemd/proc-xen.mount.in
 create mode 100644 tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in
 create mode 100644 
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in
 create mode 100644 tools/hotplug/Linux/systemd/xen-watchdog.service.in
 create mode 100644 tools/hotplug/Linux/systemd/xenconsoled.service.in
 create mode 100644 tools/hotplug/Linux/systemd/xendomains.service.in
 create mode 100644 tools/hotplug/Linux/systemd/xenstored.service.in
 create mode 100644 tools/hotplug/Linux/systemd/xenstored.socket.in

diff --git a/.gitignore b/.gitignore
index fd1b627..5ece576 100644
--- a/.gitignore
+++ b/.gitignore
@@ -390,3 +390,8 @@ tools/xenstore/xenstore-watch
 docs/txt/misc/*.txt
 docs/txt/man/*.txt
 docs/figs/*.png
+
+tools/hotplug/Linux/systemd/*.conf
+tools/hotplug/Linux/systemd/*.mount
+tools/hotplug/Linux/systemd/*.socket
+tools/hotplug/Linux/systemd/*.service
diff --git a/Makefile b/Makefile
index 41dabbf..104e39d 100644
--- a/Makefile
+++ b/Makefile
@@ -216,8 +216,12 @@ 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)$(SBINDIR)/xendomains
        rm -f  $(D)$(SYSCONFIG_DIR)/xencommons
-       rm -rf $(D)/var/run/xen* $(D)/var/lib/xen*
+       rm -f  $(D)$(XEN_SYSTEMD_DIR)/*.service
+       rm -f  $(D)$(XEN_SYSTEMD_DIR)/*.mount
+       rm -f  $(D)$(XEN_SYSTEMD_MODULES_LOAD)/*.conf
+       rm -rf $(D)${XEN_RUN_DIR}* $(D)/var/lib/xen*
        make -C tools uninstall
        rm -rf $(D)/boot/tboot*
 
diff --git a/README b/README
index 480a829..cb85c5a 100644
--- a/README
+++ b/README
@@ -72,6 +72,7 @@ disabled at compile time:
     * cmake (if building vtpm stub domains)
     * markdown
     * figlet (for generating the traditional Xen start of day banner)
+    * systemd daemon development files
 
 Second, you need to acquire a suitable kernel for use in domain 0. If
 possible you should use a kernel provided by your OS distributor. If
@@ -197,6 +198,33 @@ For more details refer to:
 
 http://wiki.xen.org/wiki/Category:Host_Configuration#Linux_kernel_modules
 
+Systemd and legacy init support
+===============================
+
+If you have systemd development packages installed you can build binaries
+that will work for both old init systems and also for systems booted with the
+systemd init replacement by using the configure --enable-systemd flag. When
+systemd is enabled all systemd support gets tucked away under a the shared
+xenstore library libxenstore.so. Systemd support is provided in libxenstore.so
+though the dynamic linking loader (dlopen(), dlsym()) by run time checking
+of the library libsystemd-daemon.so. Only systems that we can verify that
+booted with systemd as its init are expected to work with systemd, otherwise
+the old socket are initialization mechanism is used. If a system has
+libsystemd-daemon.so but it did not boot with systemd the old socket
+initialization mechanism is used. Systems that do not have libsystemd-daemon.so
+will end up using the old socket initialization mechanism. Systemd enables
+active socket activation for the xenstored unix sockets, which can be
+claimed by cxenstored or oxenstored during initialization.
+
+For now even if you have systemd libararies present systemd enablement
+is left disabled, to enable systemd you must use --enable-systemd on
+configure. Systemd may be enabled by default in the future if systemd
+development libraries are present after thorough testing.
+
+For more details refer to the xen xenstored systemd wiki page [3].
+
+[3] http://wiki.xen.org/wiki/Xenstored#xenstored_systemd_support
+
 Python Runtime Libraries
 ========================
 
diff --git a/config/Tools.mk.in b/config/Tools.mk.in
index 84b2612..fbaf11e 100644
--- a/config/Tools.mk.in
+++ b/config/Tools.mk.in
@@ -57,6 +57,12 @@ CONFIG_BLKTAP1      := @blktap1@
 CONFIG_VTPM         := @vtpm@
 CONFIG_QEMUU_EXTRA_ARGS:= @EXTRA_QEMUU_CONFIGURE_ARGS@
 
+CONFIG_SYSTEMD      := @systemd@
+SYSTEMD_CFLAGS      := @SYSTEMD_CFLAGS@
+SYSTEMD_LIBS        := @SYSTEMD_LIBS@
+XEN_SYSTEMD_DIR     := @SYSTEMD_DIR@
+XEN_SYSTEMD_MODULES_LOAD := @SYSTEMD_MODULES_LOAD@
+
 #System options
 ZLIB                := @zlib@
 CONFIG_LIBICONV     := @libiconv@
diff --git a/m4/README.source b/m4/README.source
index 76f7c5a..a3b0fe6 100644
--- a/m4/README.source
+++ b/m4/README.source
@@ -26,3 +26,10 @@ Date:   Mon Feb 3 15:59:18 2014 -0800
     With the newly added glib.mk, some of the noinst_* variables need to use
     += in the evaluation to avoid multiple definition warnings from
     automake.
+
+systemd.m4
+==========
+
+systemd.m4 was contributed to by Luis R. Rodriguez <mcgrof@xxxxxxxxxxxxxxxx>,
+it has no home project but the goal is to generalize this and actually
+upstream it into systemd.
diff --git a/m4/systemd.m4 b/m4/systemd.m4
new file mode 100644
index 0000000..9108173
--- /dev/null
+++ b/m4/systemd.m4
@@ -0,0 +1,120 @@
+# systemd.m4 - Macros to check for and enable systemd          -*- Autoconf -*-
+#
+# Copyright (C) 2014 Luis R. Rodriguez <mcgrof@xxxxxxxx>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+dnl Some optional path options
+AC_DEFUN([AX_SYSTEMD_OPTIONS], [
+       AC_ARG_WITH(systemd, [  --with-systemd          set directory for 
systemd service files],
+               SYSTEMD_DIR="$withval", SYSTEMD_DIR="")
+       AC_SUBST(SYSTEMD_DIR)
+
+       AC_ARG_WITH(systemd, [  --with-systemd-modules-load          set 
directory for systemd modules load files],
+               SYSTEMD_MODULES_LOAD="$withval", SYSTEMD_MODULES_LOAD="")
+       AC_SUBST(SYSTEMD_MODULES_LOAD)
+])
+
+AC_DEFUN([AX_ENABLE_SYSTEMD_OPTS], [
+       AX_ARG_DEFAULT_ENABLE([systemd], [Disable systemd support])
+       AX_SYSTEMD_OPTIONS()
+])
+
+AC_DEFUN([AX_ALLOW_SYSTEMD_OPTS], [
+       AX_ARG_DEFAULT_DISABLE([systemd], [Enable systemd support])
+       AX_SYSTEMD_OPTIONS()
+])
+
+AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [
+       AC_CHECK_HEADER([systemd/sd-daemon.h], [
+           AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], 
[libsystemddaemon="y"])
+       ])
+       AS_IF([test "x$libsystemddaemon" = x], [
+           AC_MSG_ERROR([Unable to find a suitable libsystemd-daemon library])
+       ])
+
+       PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon])
+       dnl pkg-config older than 0.24 does not set these for
+       dnl PKG_CHECK_MODULES() worth also noting is that as of version 208
+       dnl of systemd pkg-config --cflags currently yields no extra flags yet.
+       AC_SUBST([SYSTEMD_CFLAGS])
+       AC_SUBST([SYSTEMD_LIBS])
+
+       AS_IF([test "x$SYSTEMD_DIR" = x], [
+           dnl In order to use the line below we need to fix upstream systemd
+           dnl to properly ${prefix} for child variables in
+           dnl src/core/systemd.pc.in but this is a bit complex at the
+           dnl moment as they depend on another rootprefix, which can vary
+           dnl from prefix in practice. We provide our own definition as we
+           dnl *know* where systemd will dump this to, but this does limit
+           dnl us to stick to a non custom systemdsystemunitdir, dnl to work
+           dnl around this we provide the additional configure option
+           dnl --with-systemd where you can specify the directory for the unit
+           dnl files. It would also be best to just extend the upstream
+           dnl pkg-config  pkg.m4 with an AC_DEFUN() to do this neatly.
+           dnl SYSTEMD_DIR="`$PKG_CONFIG --define-variable=prefix=$PREFIX 
--variable=systemdsystemunitdir systemd`"
+           SYSTEMD_DIR="\$(prefix)/lib/systemd/system/"
+       ], [])
+
+       AS_IF([test "x$SYSTEMD_DIR" = x], [
+           AC_MSG_ERROR([SYSTEMD_DIR is unset])
+       ], [])
+
+       dnl There is no variable for this yet for some reason
+       AS_IF([test "x$SYSTEMD_MODULES_LOAD" = x], [
+           SYSTEMD_MODULES_LOAD="\$(prefix)/lib/modules-load.d/"
+       ], [])
+
+       AS_IF([test "x$SYSTEMD_MODULES_LOAD" = x], [
+           AC_MSG_ERROR([SYSTEMD_MODULES_LOAD is unset])
+       ], [])
+])
+
+AC_DEFUN([AX_CHECK_SYSTEMD], [
+       AS_IF([test "x$systemd" = "xy" ], [
+           AC_DEFINE([HAVE_SYSTEMD], [1], [Systemd available and enabled])
+           systemd=y
+           AX_CHECK_SYSTEMD_LIBS()
+       ],[systemd=n])
+])
+
+AC_DEFUN([AX_CHECK_SYSTEMD_ENABLE_AVAILABLE], [
+       AC_CHECK_HEADER([systemd/sd-daemon.h], [
+           AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], [systemd="y"])
+       ])
+])
+
+dnl Enables systemd by default and requires a --disable-systemd option flag
+dnl to configure if you want to disable.
+AC_DEFUN([AX_ENABLE_SYSTEMD], [
+       AX_ENABLE_SYSTEMD_OPTS()
+       AX_CHECK_SYSTEMD()
+])
+
+dnl Systemd will be disabled by default and requires you to run configure with
+dnl --enable-systemd to look for and enable systemd.
+AC_DEFUN([AX_ALLOW_SYSTEMD], [
+       AX_ALLOW_SYSTEMD_OPTS()
+       AX_CHECK_SYSTEMD()
+])
+
+dnl Systemd will be disabled by default but if your build system is detected
+dnl to have systemd build libraries it will be enabled. You can always force
+dnl disable with --disable-systemd
+AC_DEFUN([AX_AVAILABLE_SYSTEMD], [
+       AX_ALLOW_SYSTEMD_OPTS()
+       AX_CHECK_SYSTEMD_ENABLE_AVAILABLE()
+       AX_CHECK_SYSTEMD()
+])
diff --git a/tools/configure.ac b/tools/configure.ac
index 470894a..d8135cc 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -5,7 +5,17 @@ AC_PREREQ([2.67])
 AC_INIT([Xen Hypervisor Tools], m4_esyscmd([../version.sh ../xen/Makefile]),
     [xen-devel@xxxxxxxxxxxxx], [xen], [http://www.xen.org/])
 AC_CONFIG_SRCDIR([libxl/libxl.c])
-AC_CONFIG_FILES([../config/Tools.mk])
+AC_CONFIG_FILES([
+../config/Tools.mk
+hotplug/Linux/systemd/proc-xen.mount
+hotplug/Linux/systemd/var-lib-xenstored.mount
+hotplug/Linux/systemd/xenstored.socket
+hotplug/Linux/systemd/xenstored.service
+hotplug/Linux/systemd/xenconsoled.service
+hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service
+hotplug/Linux/systemd/xendomains.service
+hotplug/Linux/systemd/xen-watchdog.service
+])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_AUX_DIR([../])
 
@@ -48,6 +58,7 @@ m4_include([../m4/extfs.m4])
 m4_include([../m4/fetcher.m4])
 m4_include([../m4/ax_compare_version.m4])
 m4_include([../m4/expand_config.m4])
+m4_include([../m4/systemd.m4])
 
 AX_XEN_EXPAND_CONFIG()
 
@@ -250,5 +261,6 @@ esac
 # Checks for header files.
 AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h])
 
+AX_AVAILABLE_SYSTEMD()
 AC_OUTPUT()
 
diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile
index 90b0b0c..7d8af99 100644
--- a/tools/hotplug/Linux/Makefile
+++ b/tools/hotplug/Linux/Makefile
@@ -25,6 +25,8 @@ XEN_SCRIPTS += vscsi
 XEN_SCRIPTS += block-iscsi
 XEN_SCRIPTS += $(XEN_SCRIPTS-y)
 
+SUBDIRS-$(CONFIG_SYSTEMD) += systemd
+
 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
@@ -33,7 +35,7 @@ UDEV_RULES_DIR = $(CONFIG_DIR)/udev
 UDEV_RULES = xen-backend.rules $(UDEV_RULES-y)
 
 .PHONY: all
-all: $(XENCOMMONS_INITD)
+all: $(XENCOMMONS_INITD) subdirs-all
 
 $(XENCOMMONS_INITD): $(XEN_ROOT)/config/modules $(XENCOMMONS_INITD).in
        @set -e ;                                                       \
@@ -67,7 +69,7 @@ $(XENCOMMONS_INITD): $(XEN_ROOT)/config/modules 
$(XENCOMMONS_INITD).in
 build: all
 
 .PHONY: install
-install: all install-initd install-scripts install-udev
+install: all install-initd install-scripts install-udev subdirs-install
 
 # See docs/misc/distro_mapping.txt for INITD_DIR location
 .PHONY: install-initd
@@ -105,4 +107,4 @@ install-udev:
        done
 
 .PHONY: clean
-clean:
+clean: subdirs-clean
diff --git a/tools/hotplug/Linux/systemd/Makefile 
b/tools/hotplug/Linux/systemd/Makefile
new file mode 100644
index 0000000..2301e85
--- /dev/null
+++ b/tools/hotplug/Linux/systemd/Makefile
@@ -0,0 +1,70 @@
+XEN_ROOT = $(CURDIR)/../../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+XEN_SYSTEMD_MODULES = xen.conf
+
+XEN_SYSTEMD_MOUNT =  proc-xen.mount
+XEN_SYSTEMD_MOUNT += var-lib-xenstored.mount
+
+XEN_SYSTEMD_SOCKET += xenstored.socket
+
+XEN_SYSTEMD_SERVICE  = xenstored.service
+XEN_SYSTEMD_SERVICE += xenconsoled.service
+XEN_SYSTEMD_SERVICE += xen-qemu-dom0-disk-backend.service
+XEN_SYSTEMD_SERVICE += xendomains.service
+XEN_SYSTEMD_SERVICE += xen-watchdog.service
+
+ALL_XEN_SYSTEMD =      $(XEN_SYSTEMD_MODULES)  \
+                       $(XEN_SYSTEMD_MOUNT)    \
+                       $(XEN_SYSTEMD_SOCKET)   \
+                       $(XEN_SYSTEMD_SERVICE)
+
+.PHONY: all
+all:   $(ALL_XEN_SYSTEMD)
+
+.PHONY: clean
+clean:
+       rm -f *.socket *.service *.mount *.conf
+
+.PHONY: install
+install: $(ALL_XEN_SYSTEMD)
+       [ -d $(DESTDIR)$(XEN_SYSTEMD_DIR) ] || \
+               $(INSTALL_DIR) $(DESTDIR)$(XEN_SYSTEMD_DIR)
+       [ -d $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD) ] || \
+               $(INSTALL_DIR) $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD)
+       $(INSTALL_DATA) *.socket $(DESTDIR)$(XEN_SYSTEMD_DIR)
+       $(INSTALL_DATA) *.service $(DESTDIR)$(XEN_SYSTEMD_DIR)
+       $(INSTALL_DATA) *.mount $(DESTDIR)$(XEN_SYSTEMD_DIR)
+       $(INSTALL_DATA) *.conf $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD)
+
+$(XEN_SYSTEMD_MODULES): $(XEN_ROOT)/config/modules
+       @set -e ;                                                       \
+       IFS=''                                                          ;\
+       cat  $(XEN_ROOT)/config/modules | (                             \
+               while read l ; do                                       \
+                       if echo $${l} | egrep -q "^#" ; then            \
+                               continue                                ;\
+                       fi                                              ;\
+                       if echo "$${l}" | egrep -q "\|" ; then          \
+                               m1=$${l%%|*}                            ;\
+                               m2=$${l#*|}                             ;\
+                               # Systemd modules-load.d lacks support  ;\
+                               # for module replacement options, we    ;\
+                               # need to add that support upstream but ;\
+                               # its best instead to ensure this file  ;\
+                               # is no longer needed. Some folks       ;\
+                               # however have reported issues with     ;\
+                               # some modules automatically loading    ;\
+                               # so we just load all necessary xen     ;\
+                               # modules and for replacements we load  ;\
+                               # the latest module                     ;\
+                               echo "$$m1" ;\
+                               echo "$$m2" ;\
+                       else                                            \
+                               echo "$$l"                              ;\
+                       fi                                              ;\
+               done                                                    \
+       ) > $@
+
+.PHONY: clean
+clean:
diff --git a/tools/hotplug/Linux/systemd/proc-xen.mount.in 
b/tools/hotplug/Linux/systemd/proc-xen.mount.in
new file mode 100644
index 0000000..f0c4f3a
--- /dev/null
+++ b/tools/hotplug/Linux/systemd/proc-xen.mount.in
@@ -0,0 +1,9 @@
+[Unit]
+Description=Mount /proc/xen files
+ConditionVirtualization=xen
+RefuseManualStop=true
+
+[Mount]
+What=xenfs
+Where=/proc/xen
+Type=xenfs
diff --git a/tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in 
b/tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in
new file mode 100644
index 0000000..e49d9d4
--- /dev/null
+++ b/tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in
@@ -0,0 +1,13 @@
+[Unit]
+Description=mount xenstore file system
+ConditionVirtualization=xen
+RefuseManualStop=true
+
+[Mount]
+Environment=XENSTORED_MOUNT_CTX=
+EnvironmentFile=-/etc/sysconfig/xenstored
+EnvironmentFile=-/etc/default/xenstored
+What=xenstore
+Where=@XEN_LIB_STORED@
+Type=tmpfs
+Options=mode=755,context="$XENSTORED_MOUNT_CTX"
diff --git a/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in 
b/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in
new file mode 100644
index 0000000..8dbd110
--- /dev/null
+++ b/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in
@@ -0,0 +1,22 @@
+[Unit]
+Description=qemu for xen dom0 disk backend
+Requires=proc-xen.mount var-lib-xenstored.mount xenstored.socket
+After=xenstored.service xenconsoled.service
+Before=xendomains.service libvirtd.service libvirt-guests.service
+RefuseManualStop=true
+ConditionVirtualization=xen
+
+[Service]
+Type=simple
+EnvironmentFile=-/etc/default/xenstored
+EnvironmentFile=-/etc/sysconfig/xenstored
+PIDFile=@XEN_RUN_DIR@/qemu-dom0.pid
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStartPre=/bin/mkdir -p /var/run/xen
+ExecStart=@LIBEXEC@/qemu-system-i386 -xen-domid 0 \
+       -xen-attach -name dom0 -nographic -M xenpv -daemonize \
+       -monitor /dev/null -serial /dev/null -parallel /dev/null \
+       -pidfile @XEN_RUN_DIR@/qemu-dom0.pid
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tools/hotplug/Linux/systemd/xen-watchdog.service.in 
b/tools/hotplug/Linux/systemd/xen-watchdog.service.in
new file mode 100644
index 0000000..acb2b77
--- /dev/null
+++ b/tools/hotplug/Linux/systemd/xen-watchdog.service.in
@@ -0,0 +1,13 @@
+[Unit]
+Description=Xen-watchdog - run xen watchdog daemon
+Requires=proc-xen.mount
+After=proc-xen.mount xendomains.service
+ConditionVirtualization=xen
+
+[Service]
+Type=forking
+ExecStart=@SBINDIR@/xenwatchdogd 30 15
+KillSignal=USR1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tools/hotplug/Linux/systemd/xenconsoled.service.in 
b/tools/hotplug/Linux/systemd/xenconsoled.service.in
new file mode 100644
index 0000000..15fad35
--- /dev/null
+++ b/tools/hotplug/Linux/systemd/xenconsoled.service.in
@@ -0,0 +1,20 @@
+[Unit]
+Description=Xenconsoled - handles logging from guest consoles and hypervisor
+Requires=xenstored.socket
+After=xenstored.service
+ConditionVirtualization=xen
+
+[Service]
+Type=simple
+Environment=XENCONSOLED_ARGS=
+Environment=XENCONSOLED_LOG=none
+Environment=XENCONSOLED_LOG_DIR=@XEN_LOG_DIR@/console
+EnvironmentFile=-/etc/default/xenconsoled
+EnvironmentFile=-/etc/sysconfig/xenconsoled
+PIDFile=@XEN_RUN_DIR@/xenconsoled.pid
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStartPre=/bin/mkdir -p ${XENCONSOLED_LOG_DIR}
+ExecStart=@SBINDIR@/xenconsoled --pid-file @XEN_RUN_DIR@/xenconsoled.pid 
--log=${XENCONSOLED_LOG} --log-dir=${XENCONSOLED_LOG_DIR} $XENCONSOLED_ARGS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tools/hotplug/Linux/systemd/xendomains.service.in 
b/tools/hotplug/Linux/systemd/xendomains.service.in
new file mode 100644
index 0000000..70ce7c0
--- /dev/null
+++ b/tools/hotplug/Linux/systemd/xendomains.service.in
@@ -0,0 +1,16 @@
+[Unit]
+Description=Xendomains - start and stop guests on boot and shutdown
+Requires=xenstored.socket
+After=xenstored.service xenconsoled.service
+ConditionVirtualization=xen
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStart=-@LIBEXEC@/xendomains start
+ExecStop=@LIBEXEC@/xendomains stop
+ExecReload=@LIBEXEC@/xendomains restart
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tools/hotplug/Linux/systemd/xenstored.service.in 
b/tools/hotplug/Linux/systemd/xenstored.service.in
new file mode 100644
index 0000000..e1ed116
--- /dev/null
+++ b/tools/hotplug/Linux/systemd/xenstored.service.in
@@ -0,0 +1,27 @@
+[Unit]
+Description=Xenstored - daemon managing xenstore file system
+Requires=xenstored.socket proc-xen.mount var-lib-xenstored.mount
+After=proc-xen.mount var-lib-xenstored.mount
+Before=libvirtd.service libvirt-guests.service
+RefuseManualStop=true
+ConditionVirtualization=xen
+ConditionFileIsExecutable=@XENSTORED@
+
+[Service]
+Type=notify
+Environment=XENSTORED_ARGS=
+Environment=XENSTORED_ROOTDIR=@XEN_LIB_STORED@
+EnvironmentFile=-/etc/default/xenstored
+EnvironmentFile=-/etc/sysconfig/xenstored
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStartPre=-/bin/rm -f @XEN_LIB_STORED@/tdb*
+ExecStartPre=/bin/mkdir -p @XEN_RUN_DIR@
+ExecStart=@XENSTORED@ --no-fork $XENSTORED_ARGS
+ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"
+ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/domid" 0
+
+[Install]
+WantedBy=multi-user.target
+Also=xenstored.socket
+Also=proc-xen.mount
+Also=var-lib-xenstored.mount
diff --git a/tools/hotplug/Linux/systemd/xenstored.socket.in 
b/tools/hotplug/Linux/systemd/xenstored.socket.in
new file mode 100644
index 0000000..7d998ab
--- /dev/null
+++ b/tools/hotplug/Linux/systemd/xenstored.socket.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=Xen xenstored / oxenstored Activation Socket
+ConditionVirtualization=xen
+
+[Socket]
+ListenStream=/var/run/xenstored/socket
+ListenStream=/var/run/xenstored/socket_ro
+SocketMode=0600
+
+[Install]
+WantedBy=sockets.target
-- 
2.0.0.rc3.18.g00a5b79


_______________________________________________
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®.