Skip to contentSkip to conversation

tools/systemd fixes

PATCH Applied Olaf Hering 4 participants 17 messages Oct 24, 2014 – Oct 27, 2014

lore
Share & tools
lore
#0 lore raw

cover tools/systemd fixes

This series combines all outstanding changes for systemd service files. Right now the existing service files will work only with older systemd version (208?) which incorrectly set "ConditionVirtualization=xen" to true in a dom0. There is no support for detecting dom0 in systemd. The proper way to detect a dom0 is to check for control_d in /proc/xen/capabilities.

The content of the patches is unchanged compared to what was sent out to the list already. A few patches are acked by IanC.

New in this series is an update of the dependencies between services. As Anthony correctly pointed out its better to depend on xenstore.socket instead of xenstored.service.

The last patch is a small helper to visualize dependencies. It made it easier for me to see whats going on, so its included here as well.

Olaf

Olaf Hering (4):
tools/hotplug: fix conditions in systemd service files for dom0 tools/hotplug: systemd xenstored dependencies tools/hotplug: every systemd service depends on proc-xen.mount tools/hotplug: add helper script to visualize systemd dependencies

Wei Liu (3):
tools/hotplug: fix clean target in systemd Makefile tools/hotplug: add systemd xen-init-dom0 service tools/hotplug: xendomains now depends on xen-init-dom0

 tools/configure.ac                                 |  1 +
 tools/hotplug/Linux/systemd/Makefile               |  2 ++
 tools/hotplug/Linux/systemd/proc-xen.mount.in      |  3 ++-
 .../Linux/systemd/show_service_dependencies.sh     | 31 ++++++++++++++++++++++
 .../Linux/systemd/var-lib-xenstored.mount.in       |  4 ++-
 .../hotplug/Linux/systemd/xen-init-dom0.service.in | 14 ++++++++++
 .../systemd/xen-qemu-dom0-disk-backend.service.in  |  6 ++---
 .../hotplug/Linux/systemd/xen-watchdog.service.in  |  2 +-
 tools/hotplug/Linux/systemd/xenconsoled.service.in |  6 ++---
 tools/hotplug/Linux/systemd/xendomains.service.in  |  6 ++---
 tools/hotplug/Linux/systemd/xenstored.service.in   |  4 +--
 tools/hotplug/Linux/systemd/xenstored.socket.in    |  4 ++-
 tools/hotplug/Linux/systemd/xenstored_ro.socket.in |  4 ++-
 13 files changed, 70 insertions(+), 17 deletions(-)
 create mode 100644 tools/hotplug/Linux/systemd/show_service_dependencies.sh
 create mode 100644 tools/hotplug/Linux/systemd/xen-init-dom0.service.in
#1 lore raw

PATCH 1/7 tools/hotplug: fix conditions in systemd service files for dom0

ConditionVirtualization= checks if systemd runs in some sort of guest. It is not supposed to detect host capabilities. The current implementation happens to work because systemd-detect-virt from v208 returns also 'xen' in a dom0. In v210 and later 'none' is returned and no service files will be started.

Adjust the checks to detect a dom0 vs. native boot. Mounting xenfs depends on /proc/xen, but should only be done for pvops because xenfs exists only there. All other service files should not be started in domU. The file /proc/xen/capabilities exists in both dom0 and domU in a pvops kernel, but only in dom0 it contains 'control_d'. The existing ExecStartPre= check will prevent starting in a domU.

ConditionVirtualization=!xen is true in a dom0. But this check is broken in systemd v208, so its not used.

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/hotplug/Linux/systemd/proc-xen.mount.in                     | 3 ++-
 tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in            | 4 +++-
 tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in | 2 +-
 tools/hotplug/Linux/systemd/xen-watchdog.service.in               | 2 +-
 tools/hotplug/Linux/systemd/xenconsoled.service.in                | 2 +-
 tools/hotplug/Linux/systemd/xendomains.service.in                 | 2 +-
 tools/hotplug/Linux/systemd/xenstored.service.in                  | 2 +-
 tools/hotplug/Linux/systemd/xenstored.socket.in                   | 2 +-
 tools/hotplug/Linux/systemd/xenstored_ro.socket.in                | 2 +-
 9 files changed, 12 insertions(+), 9 deletions(-)
tools/hotplug/Linux/systemd/proc-xen.mount.in +2 -1
index f0c4f3a..64ebe7f 100644
@@ -1,6 +1,7 @@
 [Unit]
 Description=Mount /proc/xen files
-ConditionVirtualization=xen
+ConditionPathExists=/proc/xen
+ConditionPathExists=!/proc/xen/capabilities
 RefuseManualStop=true
 
 [Mount]
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in +3 -1
index 44dfce8..6c46be3 100644
@@ -1,6 +1,8 @@
 [Unit]
 Description=mount xenstore file system
-ConditionVirtualization=xen
+Requires=proc-xen.mount
+After=proc-xen.mount
+ConditionPathExists=/proc/xen/capabilities
 RefuseManualStop=true
 
 [Mount]
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in +1 -1
index d3470fc..52101af 100644
@@ -4,7 +4,7 @@ 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
+ConditionPathExists=/proc/xen/capabilities
 
 [Service]
 Type=simple
tools/hotplug/Linux/systemd/xen-watchdog.service.in +1 -1
index ee77bf9..1eecd2a 100644
@@ -2,7 +2,7 @@
 Description=Xen-watchdog - run xen watchdog daemon
 Requires=proc-xen.mount
 After=proc-xen.mount xendomains.service
-ConditionVirtualization=xen
+ConditionPathExists=/proc/xen/capabilities
 
 [Service]
 Type=forking
tools/hotplug/Linux/systemd/xenconsoled.service.in +1 -1
index 7ca0264..6ab0fc1 100644
@@ -2,7 +2,7 @@
 Description=Xenconsoled - handles logging from guest consoles and hypervisor
 Requires=xenstored.socket
 After=xenstored.service
-ConditionVirtualization=xen
+ConditionPathExists=/proc/xen/capabilities
 
 [Service]
 Type=simple
tools/hotplug/Linux/systemd/xendomains.service.in +1 -1
index f88c336..2684df0 100644
@@ -2,7 +2,7 @@
 Description=Xendomains - start and stop guests on boot and shutdown
 Requires=xenstored.socket
 After=xenstored.service xenconsoled.service
-ConditionVirtualization=xen
+ConditionPathExists=/proc/xen/capabilities
 
 [Service]
 Type=oneshot
tools/hotplug/Linux/systemd/xenstored.service.in +1 -1
index 013e69e..0f0d77d 100644
@@ -4,7 +4,7 @@ Requires=xenstored_ro.socket xenstored.socket proc-xen.mount var-lib-xenstored.m
 After=proc-xen.mount var-lib-xenstored.mount
 Before=libvirtd.service libvirt-guests.service
 RefuseManualStop=true
-ConditionVirtualization=xen
+ConditionPathExists=/proc/xen/capabilities
 
 [Service]
 Type=notify
tools/hotplug/Linux/systemd/xenstored.socket.in +1 -1
index 461e4f4..9b28e74 100644
@@ -1,6 +1,6 @@
 [Unit]
 Description=xenstore socket
-ConditionVirtualization=xen
+ConditionPathExists=/proc/xen/capabilities
 
 [Socket]
 ListenStream=/var/run/xenstored/socket
tools/hotplug/Linux/systemd/xenstored_ro.socket.in +1 -1
index 6ab5c28..80402b3 100644
@@ -1,6 +1,6 @@
 [Unit]
 Description=xenstore ro socket
-ConditionVirtualization=xen
+ConditionPathExists=/proc/xen/capabilities
 
 [Socket]
 ListenStream=/var/run/xenstored/socket_ro
#3 lore raw

PATCH 2/7 tools/hotplug: fix clean target in systemd Makefile

In reply to Olaf Hering

From: Wei Liu <[email protected]>

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/hotplug/Linux/systemd/Makefile | 1 +
 1 file changed, 1 insertion(+)
tools/hotplug/Linux/systemd/Makefile +1 -0
index 9c58b33..0c40a73 100644
@@ -25,6 +25,7 @@ all:	$(ALL_XEN_SYSTEMD)
 
 .PHONY: clean
 clean:
+	rm -f $(XEN_SYSTEMD_MODULES)
 
 .PHONY: install
 install: $(ALL_XEN_SYSTEMD)
#4 lore raw

PATCH 3/7 tools/hotplug: add systemd xen-init-dom0 service

In reply to Olaf Hering

From: Wei Liu <[email protected]>

Also prevent xenstored.service from writing Dom0 nodes. The initialisation is now done with xen-init-dom0.

Please rerun autoconf after applying this patch.

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/configure.ac                                   |  1 +
 tools/hotplug/Linux/systemd/Makefile                 |  1 +
 tools/hotplug/Linux/systemd/xen-init-dom0.service.in | 14 ++++++++++++++
 tools/hotplug/Linux/systemd/xenstored.service.in     |  2 --
 4 files changed, 16 insertions(+), 2 deletions(-)
tools/configure.ac +1 -0
index f584798..1ac63a3 100644
@@ -14,6 +14,7 @@ hotplug/Linux/init.d/xencommons
 hotplug/Linux/init.d/xendomains
 hotplug/Linux/systemd/proc-xen.mount
 hotplug/Linux/systemd/var-lib-xenstored.mount
+hotplug/Linux/systemd/xen-init-dom0.service
 hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service
 hotplug/Linux/systemd/xen-watchdog.service
 hotplug/Linux/systemd/xenconsoled.service
tools/hotplug/Linux/systemd/Makefile +1 -0
index 0c40a73..51c10fe 100644
@@ -14,6 +14,7 @@ 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
+XEN_SYSTEMD_SERVICE += xen-init-dom0.service
 
 ALL_XEN_SYSTEMD =	$(XEN_SYSTEMD_MODULES)  \
 			$(XEN_SYSTEMD_MOUNT)	\
tools/hotplug/Linux/systemd/xen-init-dom0.service.in new file +14 -0
new file mode 100644
index 0000000..e947760
@@ -0,0 +1,14 @@
+[Unit]
+Description=xen-init-dom0, initialise Dom0 configuration (xenstore nodes, JSON configuration stub)
+Requires=xenstored.socket
+After=xenstored.service
+ConditionPathExists=/proc/xen/capabilities
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStart=@LIBEXEC_BIN@/xen-init-dom0
+
+[Install]
+WantedBy=multi-user.target
tools/hotplug/Linux/systemd/xenstored.service.in +0 -2
index 0f0d77d..45fc0f2 100644
@@ -17,8 +17,6 @@ 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=/bin/sh -c "exec $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
#8 lore raw

PATCH 4/7 tools/hotplug: xendomains now depends on xen-init-dom0

In reply to Olaf Hering

From: Wei Liu <[email protected]>

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/hotplug/Linux/systemd/xendomains.service.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/systemd/xendomains.service.in +1 -1
index 2684df0..3ed4892 100644
@@ -1,7 +1,7 @@
 [Unit]
 Description=Xendomains - start and stop guests on boot and shutdown
 Requires=xenstored.socket
-After=xenstored.service xenconsoled.service
+After=xenstored.service xenconsoled.service xen-init-dom0.service
 ConditionPathExists=/proc/xen/capabilities
 
 [Service]
#9 lore raw

PATCH 5/7 tools/hotplug: systemd xenstored dependencies

In reply to Olaf Hering

Everything which uses xenstored does this via the socket. Update the existing service files to enable the xenstored.socket with the Requires= statement. And schedule startup of the given service files after the socket is enabled with the After= statement.
Once something tries to access the socket systemd will launch xenstored.

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/hotplug/Linux/systemd/xen-init-dom0.service.in              | 2 +-
 tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in | 2 +-
 tools/hotplug/Linux/systemd/xenconsoled.service.in                | 2 +-
 tools/hotplug/Linux/systemd/xendomains.service.in                 | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +1 -1
index e947760..3ed1633 100644
@@ -1,7 +1,7 @@
 [Unit]
 Description=xen-init-dom0, initialise Dom0 configuration (xenstore nodes, JSON configuration stub)
 Requires=xenstored.socket
-After=xenstored.service
+After=xenstored.socket
 ConditionPathExists=/proc/xen/capabilities
 
 [Service]
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in +1 -1
index 52101af..0b9c2e5 100644
@@ -1,7 +1,7 @@
 [Unit]
 Description=qemu for xen dom0 disk backend
 Requires=proc-xen.mount var-lib-xenstored.mount xenstored.socket
-After=xenstored.service xenconsoled.service
+After=xenstored.socket xenconsoled.service
 Before=xendomains.service libvirtd.service libvirt-guests.service
 RefuseManualStop=true
 ConditionPathExists=/proc/xen/capabilities
tools/hotplug/Linux/systemd/xenconsoled.service.in +1 -1
index 6ab0fc1..d3b85a5 100644
@@ -1,7 +1,7 @@
 [Unit]
 Description=Xenconsoled - handles logging from guest consoles and hypervisor
 Requires=xenstored.socket
-After=xenstored.service
+After=xenstored.socket
 ConditionPathExists=/proc/xen/capabilities
 
 [Service]
tools/hotplug/Linux/systemd/xendomains.service.in +1 -1
index 3ed4892..214da7a 100644
@@ -1,7 +1,7 @@
 [Unit]
 Description=Xendomains - start and stop guests on boot and shutdown
 Requires=xenstored.socket
-After=xenstored.service xenconsoled.service xen-init-dom0.service
+After=xenstored.socket xenconsoled.service xen-init-dom0.service
 ConditionPathExists=/proc/xen/capabilities
 
 [Service]
#11 lore raw

PATCH 6/7 tools/hotplug: every systemd service depends on proc-xen.mount

In reply to Olaf Hering

Every systemd service file uses /proc/xen/capabilites to check if it runs in a dom0. Update every service file to enable proc-xen.mount with the Requires= statement and schedule its startup with the After= statement.
In some places var-lib-xenstored.mount is removed. This is ok because its optional and this unit is enabled by xenstored itself. After all its a private directory for xenstored.

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/hotplug/Linux/systemd/xen-init-dom0.service.in              | 4 ++--
 tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in | 4 ++--
 tools/hotplug/Linux/systemd/xenconsoled.service.in                | 4 ++--
 tools/hotplug/Linux/systemd/xendomains.service.in                 | 4 ++--
 tools/hotplug/Linux/systemd/xenstored.socket.in                   | 2 ++
 tools/hotplug/Linux/systemd/xenstored_ro.socket.in                | 2 ++
 6 files changed, 12 insertions(+), 8 deletions(-)
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +2 -2
index 3ed1633..4d4cb23 100644
@@ -1,7 +1,7 @@
 [Unit]
 Description=xen-init-dom0, initialise Dom0 configuration (xenstore nodes, JSON configuration stub)
-Requires=xenstored.socket
-After=xenstored.socket
+Requires=xenstored.socket proc-xen.mount
+After=xenstored.socket proc-xen.mount
 ConditionPathExists=/proc/xen/capabilities
 
 [Service]
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in +2 -2
index 0b9c2e5..1e21abb 100644
@@ -1,7 +1,7 @@
 [Unit]
 Description=qemu for xen dom0 disk backend
-Requires=proc-xen.mount var-lib-xenstored.mount xenstored.socket
-After=xenstored.socket xenconsoled.service
+Requires=proc-xen.mount xenstored.socket
+After=proc-xen.mount xenstored.socket xenconsoled.service
 Before=xendomains.service libvirtd.service libvirt-guests.service
 RefuseManualStop=true
 ConditionPathExists=/proc/xen/capabilities
tools/hotplug/Linux/systemd/xenconsoled.service.in +2 -2
index d3b85a5..e6cb853 100644
@@ -1,7 +1,7 @@
 [Unit]
 Description=Xenconsoled - handles logging from guest consoles and hypervisor
-Requires=xenstored.socket
-After=xenstored.socket
+Requires=proc-xen.mount xenstored.socket
+After=proc-xen.mount xenstored.socket
 ConditionPathExists=/proc/xen/capabilities
 
 [Service]
tools/hotplug/Linux/systemd/xendomains.service.in +2 -2
index 214da7a..757278f 100644
@@ -1,7 +1,7 @@
 [Unit]
 Description=Xendomains - start and stop guests on boot and shutdown
-Requires=xenstored.socket
-After=xenstored.socket xenconsoled.service xen-init-dom0.service
+Requires=proc-xen.mount xenstored.socket
+After=proc-xen.mount xenstored.socket xenconsoled.service xen-init-dom0.service
 ConditionPathExists=/proc/xen/capabilities
 
 [Service]
tools/hotplug/Linux/systemd/xenstored.socket.in +2 -0
index 9b28e74..2e8ee04 100644
@@ -1,5 +1,7 @@
 [Unit]
 Description=xenstore socket
+Requires=proc-xen.mount var-lib-xenstored.mount
+After=proc-xen.mount var-lib-xenstored.mount
 ConditionPathExists=/proc/xen/capabilities
 
 [Socket]
tools/hotplug/Linux/systemd/xenstored_ro.socket.in +2 -0
index 80402b3..140ad94 100644
@@ -1,5 +1,7 @@
 [Unit]
 Description=xenstore ro socket
+Requires=proc-xen.mount var-lib-xenstored.mount
+After=proc-xen.mount var-lib-xenstored.mount
 ConditionPathExists=/proc/xen/capabilities
 
 [Socket]
#13 lore raw

PATCH 7/7 tools/hotplug: add helper script to visualize systemd dependencies

In reply to Olaf Hering

A small helper to draw a graph with dot(1) and show it with display(1):
bash tools/hotplug/Linux/systemd/show_service_dependencies.sh \
tools/hotplug/Linux/systemd/*.in

A red line means Requires= aka "enable it"
A blue line means After=
A green line means Before=

---
 .../Linux/systemd/show_service_dependencies.sh     | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
tools/hotplug/Linux/systemd/show_service_dependencies.sh new file +31 -0
new file mode 100644
index 0000000..e3e4c68
@@ -0,0 +1,31 @@
+#!/bin/bash
+# dot(1) from graphviz, display(1) from ImageMagick
+# Usage: bash $0 tools/hotplug/Linux/systemd/*.in
+(
+echo " digraph systemd {"
+for file in "$@"
+do
+	if test -f "$file"
+	then
+		unit=${file##*/}
+		unit=${unit%.in}
+		requires="`grep ^Requires= $file | cut -f 2- -d =`"
+		before="`grep ^Before= $file | cut -f 2- -d =`"
+		after="`grep ^After= $file | cut -f 2- -d =`"
+		echo "\"$unit\" [fillcolor=lightgray color=black fontcolor=black style=filled];"
+		for i in $requires
+		do
+			echo "\"$i\" -> \"$unit\" [color=red];"
+		done
+		for i in $after
+		do
+			echo "\"$i\" -> \"$unit\" [color=blue];"
+		done
+		for i in $before
+		do
+			echo "\"$unit\" -> \"$i\" [color=green];"
+		done
+	fi
+done
+echo "}"
+) | dot -Tpng | display -
#5 lore raw

Re: [PATCH 3/7] tools/hotplug: add systemd xen-init-dom0 service

In reply to Olaf Hering

On Fri, Oct 24, 2014 at 04:17:06PM +0200, Olaf Hering wrote:
[...]

Quoted 29 lines

index f584798..1ac63a3 100644

tools/configure.ac +1 -0
@@ -14,6 +14,7 @@ hotplug/Linux/init.d/xencommons
 hotplug/Linux/init.d/xendomains
 hotplug/Linux/systemd/proc-xen.mount
 hotplug/Linux/systemd/var-lib-xenstored.mount
+hotplug/Linux/systemd/xen-init-dom0.service
 hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service
 hotplug/Linux/systemd/xen-watchdog.service
 hotplug/Linux/systemd/xenconsoled.service
tools/hotplug/Linux/systemd/Makefile +1 -0
index 0c40a73..51c10fe 100644
@@ -14,6 +14,7 @@ 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
+XEN_SYSTEMD_SERVICE += xen-init-dom0.service
 
 ALL_XEN_SYSTEMD =	$(XEN_SYSTEMD_MODULES)  \
 			$(XEN_SYSTEMD_MOUNT)	\
tools/hotplug/Linux/systemd/xen-init-dom0.service.in new file +0 -0
new file mode 100644
index 0000000..e947760

tools/hotplug/Linux/systemd/xen-init-dom0.service.in line 4

Quoted 4 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in new file +4 -0
@@ -0,0 +1,14 @@
+[Unit]
+Description=xen-init-dom0, initialise Dom0 configuration (xenstore nodes, JSON configuration stub)
+Requires=xenstored.socket
+After=xenstored.service

Olaf, you forgot to change this...

Wei.

#6 lore raw

Re: [PATCH 3/7] tools/hotplug: add systemd xen-init-dom0 service

Quoted 5 lines · Wei Liu

tools/hotplug/Linux/systemd/xen-init-dom0.service.in line 4

Quoted 2 lines · Olaf Hering
tools/hotplug/Linux/systemd/xen-init-dom0.service.in new file +2 -0
+Requires=xenstored.socket
+After=xenstored.service

Olaf, you forgot to change this...

Its in a later patch which does it all at once.

Olaf

#7 lore raw

Re: [PATCH 3/7] tools/hotplug: add systemd xen-init-dom0 service

Quoted 10 lines · Olaf Hering
Quoted 5 lines · Wei Liu

tools/hotplug/Linux/systemd/xen-init-dom0.service.in line 4

Quoted 2 lines · Olaf Hering
tools/hotplug/Linux/systemd/xen-init-dom0.service.in new file +2 -0
+Requires=xenstored.socket
+After=xenstored.service

Olaf, you forgot to change this...

Its in a later patch which does it all at once.

Yeah, Hit "send" too soon...

Wei.

Quoted 1 line

Olaf

Acked-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] tools/hotplug: fix conditions in systemd service files for dom0

In reply to Olaf Hering
Quoted 13 lines · Olaf Hering

ConditionVirtualization= checks if systemd runs in some sort of guest. It is not supposed to detect host capabilities. The current implementation happens to work because systemd-detect-virt from v208 returns also 'xen' in a dom0. In v210 and later 'none' is returned and no service files will be started.

Adjust the checks to detect a dom0 vs. native boot. Mounting xenfs depends on /proc/xen, but should only be done for pvops because xenfs exists only there. All other service files should not be started in domU. The file /proc/xen/capabilities exists in both dom0 and domU in a pvops kernel, but only in dom0 it contains 'control_d'. The existing ExecStartPre= check will prevent starting in a domU.

Quoted 8 lines

ConditionVirtualization=!xen is true in a dom0. But this check is broken in systemd v208, so its not used.

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
Acked-by on v1 5/7
#10 lore raw

Re: [PATCH 5/7] tools/hotplug: systemd xenstored dependencies

In reply to Olaf Hering
Quoted 11 lines · Olaf Hering

Everything which uses xenstored does this via the socket. Update the existing service files to enable the xenstored.socket with the Requires= statement. And schedule startup of the given service files after the socket is enabled with the After= statement.
Once something tries to access the socket systemd will launch xenstored.

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
Acked-by on v1 6/7
#12 lore raw

Re: [PATCH 6/7] tools/hotplug: every systemd service depends on proc-xen.mount

In reply to Olaf Hering
Quoted 8 lines · Olaf Hering

Every systemd service file uses /proc/xen/capabilites to check if it runs in a dom0. Update every service file to enable proc-xen.mount with the Requires= statement and schedule its startup with the After= statement.
In some places var-lib-xenstored.mount is removed. This is ok because its optional and this unit is enabled by xenstored itself. After all its a private directory for xenstored.

Quoted 5 lines
Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
Acked-by on v1 7/7
#14 lore raw

Re: [PATCH 7/7] tools/hotplug: add helper script to visualize systemd dependencies

In reply to Olaf Hering
Quoted 9 lines · Olaf Hering

A small helper to draw a graph with dot(1) and show it with display(1):
bash tools/hotplug/Linux/systemd/show_service_dependencies.sh \
tools/hotplug/Linux/systemd/*.in

A red line means Requires= aka "enable it"
A blue line means After=
A green line means Before=

The more tools the better. ;-)

#15 lore raw
In reply to Olaf Hering
Quoted 10 lines · Olaf Hering

This series combines all outstanding changes for systemd service files. Right now the existing service files will work only with older systemd version (208?) which incorrectly set "ConditionVirtualization=xen" to true in a dom0. There is no support for detecting dom0 in systemd. The proper way to detect a dom0 is to check for control_d in /proc/xen/capabilities.

The content of the patches is unchanged compared to what was sent out to the list already. A few patches are acked by IanC.

Quoted 8 lines

New in this series is an update of the dependencies between services. As Anthony correctly pointed out its better to depend on xenstore.socket instead of xenstored.service.

The last patch is a small helper to visualize dependencies. It made it easier for me to see whats going on, so its included here as well.

Olaf

Ian,

If you are waiting for my comments, I am OK with all of those patches going in. And Wei has Acked them so that is super!

Quoted 29 lines

Olaf Hering (4):
tools/hotplug: fix conditions in systemd service files for dom0 tools/hotplug: systemd xenstored dependencies tools/hotplug: every systemd service depends on proc-xen.mount tools/hotplug: add helper script to visualize systemd dependencies

Wei Liu (3):
tools/hotplug: fix clean target in systemd Makefile tools/hotplug: add systemd xen-init-dom0 service tools/hotplug: xendomains now depends on xen-init-dom0

 tools/configure.ac                                 |  1 +
 tools/hotplug/Linux/systemd/Makefile               |  2 ++
 tools/hotplug/Linux/systemd/proc-xen.mount.in      |  3 ++-
 .../Linux/systemd/show_service_dependencies.sh     | 31 ++++++++++++++++++++++
 .../Linux/systemd/var-lib-xenstored.mount.in       |  4 ++-
 .../hotplug/Linux/systemd/xen-init-dom0.service.in | 14 ++++++++++
 .../systemd/xen-qemu-dom0-disk-backend.service.in  |  6 ++---
 .../hotplug/Linux/systemd/xen-watchdog.service.in  |  2 +-
 tools/hotplug/Linux/systemd/xenconsoled.service.in |  6 ++---
 tools/hotplug/Linux/systemd/xendomains.service.in  |  6 ++---
 tools/hotplug/Linux/systemd/xenstored.service.in   |  4 +--
 tools/hotplug/Linux/systemd/xenstored.socket.in    |  4 ++-
 tools/hotplug/Linux/systemd/xenstored_ro.socket.in |  4 ++-
 13 files changed, 70 insertions(+), 17 deletions(-)
 create mode 100644 tools/hotplug/Linux/systemd/show_service_dependencies.sh
 create mode 100644 tools/hotplug/Linux/systemd/xen-init-dom0.service.in
Applied
#16 lore raw
Quoted 18 lines · Konrad Rzeszutek Wilk
Quoted 17 lines · Olaf Hering

This series combines all outstanding changes for systemd service files. Right now the existing service files will work only with older systemd version (208?) which incorrectly set "ConditionVirtualization=xen" to true in a dom0. There is no support for detecting dom0 in systemd. The proper way to detect a dom0 is to check for control_d in /proc/xen/capabilities.

The content of the patches is unchanged compared to what was sent out to the list already. A few patches are acked by IanC.

New in this series is an update of the dependencies between services. As Anthony correctly pointed out its better to depend on xenstore.socket instead of xenstored.service.

The last patch is a small helper to visualize dependencies. It made it easier for me to see whats going on, so its included here as well.

Quoted 8 lines
Quoted 1 line

Olaf

Ian,

If you are waiting for my comments, I am OK with all of those patches going in. And Wei has Acked them so that is super!

Applied.