tools/hotplug: fix systemd service files for dom0
PATCH 1/1 tools/hotplug: fix 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 all service files are not 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.
---
I'm having a hard time to get a pvops dom0, so this is only tested with SUSE dom0.
tools/hotplug/Linux/systemd/proc-xen.mount.in | 3 ++- tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in | 2 +- 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, 10 insertions(+), 9 deletions(-)
tools/hotplug/Linux/systemd/proc-xen.mount.in +2 -1
@@ -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 +1 -1
@@ -1,6 +1,6 @@ [Unit] Description=mount xenstore file system -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilities RefuseManualStop=true [Mount]
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1,6 +1,6 @@ [Unit] Description=xenstore ro socket -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilities [Socket] ListenStream=/var/run/xenstored/socket_ro
Quoted 16 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 all service files are not 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/capabilitiesexists 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.
Quoted 8 lines
Signed-off-by Olaf Hering <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Wei Liu <[email protected]>---
I'm having a hard time to get a pvops dom0, so this is only tested with SUSE dom0.
I've tested this patch in both dom0 and bare metal (with Linux 3.17.1 and systemd v216) and it mostly works, only one unit does not work, var-lib-xenstored.mount.
(for some reason, ConditionVirtualization=xen, is still true on dom0 with systemd v216, even so systemd-detect-virt is returning 'none' ...)
Quoted 29 lines
tools/hotplug/Linux/systemd/proc-xen.mount.in | 3 ++- tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in | 2 +- 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, 10 insertions(+), 9 deletions(-)tools/hotplug/Linux/systemd/proc-xen.mount.in +2
-1@@ -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 +0
-0
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in line 3
Quoted 4 lines
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in +1
-1@@ -1,6 +1,6 @@ [Unit] Description=mount xenstore file system -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilities
On my systemd, var/lib/xenstored is not mounted because ConditionPathExists=/proc/xen/capabilities was not met even so proc-xen.mount is mounted.
So there is probably a dependency missing on proc-xen.mount.
Quoted 3 lines
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in +0
-0RefuseManualStop=true [Mount]
Signature · 1 line
Anthony PERARD
Quoted 12 lines · Anthony PERARD
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in line 3
Quoted 6 lines · Olaf Hering
+++ b/tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in +1
-1@@ -1,6 +1,6 @@ [Unit] Description=mount xenstore file system -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilitiesOn my systemd, var/lib/xenstored is not mounted because ConditionPathExists=/proc/xen/capabilities was not met even so proc-xen.mount is mounted.
Quoted 1 line
So there is probably a dependency missing on proc-xen.mount.
Yes, that is fixed with the latest version.
Olaf
Quoted 24 lines · Anthony PERARD
Quoted 23 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 all service files are not 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/capabilitiesexists 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.
Signed-off-by Olaf Hering <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Wei Liu <[email protected]>---
Quoted 8 lines
Quoted 1 line
I'm having a hard time to get a pvops dom0, so this is only tested with SUSE dom0.
I've tested this patch in both dom0 and bare metal (with Linux 3.17.1 and systemd v216) and it mostly works, only one unit does not work, var-lib-xenstored.mount.
(for some reason, ConditionVirtualization=xen, is still true on dom0 with systemd v216, even so systemd-detect-virt is returning 'none' ...)
Based on a comment I saw on either an earlier version of this series or one of Olaf's fixes this is expected, the behaviour changed (to exclude dom0) in a more recent version.