Skip to contentSkip to conversation

tools: systemd patches

PATCH In review Wei Liu 5 participants 13 messages Oct 21, 2014 – Oct 23, 2014

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

cover tools: systemd patches

This small series tries to fix some problems in systemd stuffs.

The first patch was based on one of Olaf's email on fixing the clean target.

Patch 2 and 3 add a missing service to run xen-init-dom0. The basic thing is that we need to run xen-init-dom0 to generate JSON config stub for Dom0 before xendomains. xen-init-dom0 only needs to run once.

Wei.

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

 tools/configure.ac                                   |    1 +
 tools/hotplug/Linux/systemd/Makefile                 |    2 ++
 tools/hotplug/Linux/systemd/xen-init-dom0.service.in |   14 ++++++++++++++
 tools/hotplug/Linux/systemd/xendomains.service.in    |    2 +-
 tools/hotplug/Linux/systemd/xenstored.service.in     |    2 --
 5 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 tools/hotplug/Linux/systemd/xen-init-dom0.service.in
Signature · 1 line
1.7.10.4
author
#1 lore raw

PATCH 1/3 systemd: fix clean target in Makefile

---
 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)
Signature · 1 line
1.7.10.4
author
#4 lore raw

PATCH 2/3 systemd: add xen-init-dom0 service

In reply to Wei Liu

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

Please rerun autoconf after applying this patch.

---
 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(-)
 create mode 100644 tools/hotplug/Linux/systemd/xen-init-dom0.service.in
tools/configure.ac +1 -0
index f584798..62ccf47 100644
@@ -15,6 +15,7 @@ hotplug/Linux/init.d/xendomains
 hotplug/Linux/systemd/proc-xen.mount
 hotplug/Linux/systemd/var-lib-xenstored.mount
 hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service
+hotplug/Linux/systemd/xen-init-dom0.service
 hotplug/Linux/systemd/xen-watchdog.service
 hotplug/Linux/systemd/xenconsoled.service
 hotplug/Linux/systemd/xendomains.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 013e69e..e3bf837 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
Signature · 1 line
1.7.10.4
author
#9 lore raw

PATCH 3/3 systemd: xendomains now depends on xen-init-dom0

In reply to Wei Liu
---
 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 f88c336..8577317 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
 ConditionVirtualization=xen
 
 [Service]
Signature · 1 line
1.7.10.4
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] systemd: fix clean target in Makefile

In reply to Wei Liu
Quoted 1 line · Wei Liu

I just acked the first copy of this before I noticed this newer one. Anyway:

Are you going to make a case for a release exception (for some or all of the series) to Konrad?

Quoted 16 lines
---
 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)
#11 lore raw

Re: [PATCH 3/3] systemd: xendomains now depends on xen-init-dom0

In reply to Wei Liu
Quoted 10 lines · Wei Liu
---
 tools/hotplug/Linux/systemd/xendomains.service.in |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/systemd/xendomains.service.in +0 -0
index f88c336..8577317 100644

tools/hotplug/Linux/systemd/xendomains.service.in line 5

Quoted 6 lines
tools/hotplug/Linux/systemd/xendomains.service.in +1 -1
@@ -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
 ConditionVirtualization=xen

Having a service listed in After does not mean a service depends on the other. It just mean: run xendomains.service after xen-init-dom0.service, but xen-init-dom0.service might not run at all..

If xen-init-dom0.service needs to be run before xendomains.service, you also need to add it to the Requires list.

So the patch should probably look like this:
-Requires=xenstored.socket
-After=xenstored.service xenconsoled.service +Requires=xenstored.socket xen-init-dom0.service +After=xenstored.service xenconsoled.service xen-init-dom0.service

(This also means, if xen-init-dom0 fail, xendomains will not be started at all.)

Signature · 1 line
Anthony PERARD
author
#12 lore raw

Re: [PATCH 3/3] systemd: xendomains now depends on xen-init-dom0

Quoted 22 lines · Anthony PERARD
Quoted 10 lines · Wei Liu
---
 tools/hotplug/Linux/systemd/xendomains.service.in |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/systemd/xendomains.service.in +0 -0
index f88c336..8577317 100644

tools/hotplug/Linux/systemd/xendomains.service.in line 5

Quoted 6 lines
tools/hotplug/Linux/systemd/xendomains.service.in +1 -1
@@ -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
 ConditionVirtualization=xen

Having a service listed in After does not mean a service depends on the other. It just mean: run xendomains.service after xen-init-dom0.service, but xen-init-dom0.service might not run at all..

Quoted 3 lines

If xen-init-dom0.service needs to be run before xendomains.service, you also need to add it to the Requires list.

Then I must have misread the manual

"After= ensures that the configured unit is started after the listed unit finished starting up"

Looks like "finished starting up" doesn't guarantee it exits with success?

Quoted 9 lines

So the patch should probably look like this:

tools/hotplug/Linux/systemd/xendomains.service.in +2 -2
-Requires=xenstored.socket
-After=xenstored.service xenconsoled.service
+Requires=xenstored.socket xen-init-dom0.service
+After=xenstored.service xenconsoled.service xen-init-dom0.service

(This also means, if xen-init-dom0 fail, xendomains will not be started at all.)

Anyway, this looks sensible and it's what I expect. I will add in that line.

Wei.

Quoted 2 lines
Signature · 1 line
Anthony PERARD
#3 lore raw

Re: [PATCH 1/3] systemd: fix clean target in Makefile

In reply to Ian Campbell
Quoted 9 lines · Ian Campbell
Quoted 1 line · Wei Liu

I just acked the first copy of this before I noticed this newer one. Anyway:

Are you going to make a case for a release exception (for some or all of the series) to Konrad?

I believe this is a bug-fix so it can go in anytime.

Quoted 24 lines
Quoted 10 lines
---
 tools/hotplug/Linux/systemd/Makefile |    1 +
 1 file changed, 1 insertion(+)
tools/hotplug/Linux/systemd/Makefile +0 -0
index 9c58b33..0c40a73 100644

tools/hotplug/Linux/systemd/Makefile all: $(ALL_XEN_SYSTEMD) · line 31

Quoted 7 lines
tools/hotplug/Linux/systemd/Makefile +1 -0
@@ -25,6 +25,7 @@ all:	$(ALL_XEN_SYSTEMD)
 
 .PHONY: clean
 clean:
+	rm -f $(XEN_SYSTEMD_MODULES)
 
 .PHONY: install
 install: $(ALL_XEN_SYSTEMD)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH 2/3] systemd: add xen-init-dom0 service

In reply to Wei Liu
Quoted 6 lines · Wei Liu

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

Please rerun autoconf after applying this patch.

I've tested this patch, and it works fine. It also looks good.

One would just need to adds "systemctl enable xen-init-dom0" in the doc, if there is one.

I just have one comment below.

Quoted 38 lines
---
 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(-)
 create mode 100644 tools/hotplug/Linux/systemd/xen-init-dom0.service.in
tools/configure.ac +1 -0
index f584798..62ccf47 100644
@@ -15,6 +15,7 @@ hotplug/Linux/init.d/xendomains
 hotplug/Linux/systemd/proc-xen.mount
 hotplug/Linux/systemd/var-lib-xenstored.mount
 hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service
+hotplug/Linux/systemd/xen-init-dom0.service
 hotplug/Linux/systemd/xen-watchdog.service
 hotplug/Linux/systemd/xenconsoled.service
 hotplug/Linux/systemd/xendomains.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

This two lines looks weird. I think they needs to be both the same.

Right now, I think systemd is ignoring the "After=" because xenstored.service is not yet on the list of services to start. But it will work because as soon as xen-init-dom0 is going to try to access xenstored, systemd is going to start it (because .socket).

So, IMHO, the right thing to do is either:
Requires=xenstored.socket
After=xenstored.socket
or:
Requires=xenstored.service
After=xenstored.service

Quoted 31 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in new file +10 -0
+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 013e69e..e3bf837 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
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Signature · 1 line
Anthony PERARD
#7 lore raw

Re: [PATCH 2/3] systemd: add xen-init-dom0 service

Quoted 6 lines · Anthony PERARD

So, IMHO, the right thing to do is either:
Requires=xenstored.socket
After=xenstored.socket
or:
Requires=xenstored.service
After=xenstored.service

I agree with that.

Olaf

author
#8 lore raw

Re: [PATCH 2/3] systemd: add xen-init-dom0 service

Quoted 11 lines · Olaf Hering
Quoted 6 lines · Anthony PERARD

So, IMHO, the right thing to do is either:
Requires=xenstored.socket
After=xenstored.socket
or:
Requires=xenstored.service
After=xenstored.service

I agree with that.

Then I (or you?) will need to fix other service files as well!

Anyway, I (or you?) should fix this as soon as possible.

Wei.

Quoted 1 line

Olaf