[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v4 13/15] 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. These are originally based on the Fedora systemd files. Changes made from Fedora's systemd files: * 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 build systemd dynamic change, that is upon build time you pick what xentore you want, we don't want multiple service files floating around, although its possible to support with this target files this seems rather pointless right now specially since we cannot stop [co]xenstored. We instead strive for simplicity with one direct target build. * enables systemd socket activation for C xenstored and Ocaml oxenstored * 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 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. * 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 * defines a modules-load.d for us * 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 with systemd enabled. The systemd files will be sanitized for meta @VARIABLES@ upon configuration and installed upon the install target. Systems that do not use systemd will not have these files installed and will end up using the old LSB init scripts. 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> --- .gitignore | 5 +++ Makefile | 11 +++++- tools/configure.ac | 12 +++++- tools/hotplug/Linux/Makefile | 8 ++-- tools/hotplug/Linux/systemd/Makefile | 44 ++++++++++++++++++++++ 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 +++++++ .../Linux/systemd/xen.conf.modules-load.d.in | 16 ++++++++ tools/hotplug/Linux/systemd/xenconsoled.service.in | 20 ++++++++++ tools/hotplug/Linux/systemd/xendomains.service.in | 16 ++++++++ tools/hotplug/Linux/systemd/xenstored.service.in | 25 ++++++++++++ tools/hotplug/Linux/systemd/xenstored.socket.in | 9 +++++ 14 files changed, 218 insertions(+), 5 deletions(-) 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/xen.conf.modules-load.d.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..5330985 100644 --- a/Makefile +++ b/Makefile @@ -216,8 +216,17 @@ 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)/xenconsoled.service + rm -f $(D)$(XEN_SYSTEMD_DIR)/xendomains.service + rm -f $(D)$(XEN_SYSTEMD_DIR)/xenstored.service + rm -f $(D)$(XEN_SYSTEMD_DIR)/oxenstored.service + rm -f $(D)$(XEN_SYSTEMD_DIR)/xen-watchdog.service + rm -f $(D)$(XEN_SYSTEMD_DIR)/proc-xen.mount + rm -f $(D)$(XEN_SYSTEMD_DIR)/var-lib-xenstored.mount + rm -f $(D)$(XEN_SYSTEMD_MODULES_LOAD)/xen.conf + rm -rf $(D)${XEN_RUN_DIR}* $(D)/var/lib/xen* make -C tools uninstall rm -rf $(D)/boot/tboot* diff --git a/tools/configure.ac b/tools/configure.ac index ac984a3..8a8831f 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([../]) diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile index 7e6646e..540e908 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,13 +35,13 @@ UDEV_RULES_DIR = $(CONFIG_DIR)/udev UDEV_RULES = xen-backend.rules $(UDEV_RULES-y) .PHONY: all -all: +all: subdirs-all .PHONY: build build: .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 @@ -80,4 +82,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..f23a727 --- /dev/null +++ b/tools/hotplug/Linux/systemd/Makefile @@ -0,0 +1,44 @@ +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) + +%.conf: %.conf.modules-load.d.in + cp $< $@ + +.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..6eb61b2 --- /dev/null +++ b/tools/hotplug/Linux/systemd/proc-xen.mount.in @@ -0,0 +1,9 @@ +[Unit] +Description=Mount /proc/xen files +ConditionPathIsDirectory=/proc/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..a393b06 --- /dev/null +++ b/tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in @@ -0,0 +1,13 @@ +[Unit] +Description=mount xenstore file system +ConditionPathIsDirectory=/proc/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..1855719 --- /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 +ConditionPathIsDirectory=/proc/xen + +[Service] +Type=forking +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..c202fe9 --- /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 +ConditionPathIsDirectory=/proc/xen + +[Service] +Type=forking +ExecStart=@SBINDIR@/xenwatchdogd 30 15 +KillSignal=USR1 + +[Install] +WantedBy=multi-user.target diff --git a/tools/hotplug/Linux/systemd/xen.conf.modules-load.d.in b/tools/hotplug/Linux/systemd/xen.conf.modules-load.d.in new file mode 100644 index 0000000..3fbd59b --- /dev/null +++ b/tools/hotplug/Linux/systemd/xen.conf.modules-load.d.in @@ -0,0 +1,16 @@ +xen-evtchn +xen-gntdev +xen-gntalloc +xen-blkback +xen-netback +xen-pciback +evtchn +gntdev +netbk +blkbk +xen-scsibk +usbbk +pciback +xen-acpi-processor +blktap2 +blktap diff --git a/tools/hotplug/Linux/systemd/xenconsoled.service.in b/tools/hotplug/Linux/systemd/xenconsoled.service.in new file mode 100644 index 0000000..50fe583 --- /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 +ConditionPathIsDirectory=/proc/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 @XEN_RUN_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..ee44484 --- /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 +ConditionPathIsDirectory=/proc/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..f64dfa1 --- /dev/null +++ b/tools/hotplug/Linux/systemd/xenstored.service.in @@ -0,0 +1,25 @@ +[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 +ConditionPathIsDirectory=/proc/xen +ConditionFileIsExecutable=@XENSTORED@ + +[Service] +Type=forking +Environment=XENSTORED_ARGS= +Environment=XENSTORED_ROOTDIR=@XEN_LIB_STORED@ +EnvironmentFile=-/etc/default/xenstored +EnvironmentFile=-/etc/sysconfig/xenstored +PIDFile=@XEN_RUN_DIR@/xenstored.pid +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@ --pid-file @XEN_RUN_DIR@/xenstored.pid $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 diff --git a/tools/hotplug/Linux/systemd/xenstored.socket.in b/tools/hotplug/Linux/systemd/xenstored.socket.in new file mode 100644 index 0000000..3270f4d --- /dev/null +++ b/tools/hotplug/Linux/systemd/xenstored.socket.in @@ -0,0 +1,9 @@ +[Unit] +Description=Xen xenstored / oxenstored Activation Socket + +[Socket] +ListenStream=/var/run/xenstored/socket +ListenStream=/var/run/xenstored/socket_ro + +[Install] +WantedBy=sockets.target -- 1.9.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |