tools: make xenstore domain/daemon configurable
v4 cover tools: make xenstore domain/daemon configurable
Add a configuration option to /etc/sysconfig/xencommons to let the user configure whether he wants to start xenstore service as a daemon or as a stubdom.
Changes in V4:
- patch 1: remove sd_booted() test, undo unintended white space changes
- patch 3: use @XEN_RUN_DIR@ as requested by Wei Liu
Changes in V3:
- patch 1: re-add sd_notify() call
- split up former patch 2 into 3 patches as requested by Ian Jackson
- patch 4 (was 2): remove check for running xenstore domain, as this is done in init-xenstore-domain already
- patch 4 (was 2): if booted with systemd send a systemd-notify message in the xenstore domain case
- patch 4 (was 2): if booted with systemd don't wait until xenstore daemon is running, as the daemon will have sent a notify message by its own
Changes in V2:
- move service type modification form patch 2 to patch 1 as implied by Ross Lagerwall (at least I guess so)
- add .gitignore entry for launch-xenstore
Juergen Gross (4):
tools: remove systemd xenstore socket definitions
tools: split out xenstored starting form xencommons
tools: use pidfile for test if xenstored is running
tools: make xenstore domain easy configurable
.gitignore | 1 + tools/configure | 7 +- tools/configure.ac | 3 +- tools/hotplug/Linux/Makefile | 1 + tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 42 ++++++++- tools/hotplug/Linux/init.d/xencommons.in | 38 +------- tools/hotplug/Linux/launch-xenstore.in | 87 +++++++++++++++++ tools/hotplug/Linux/systemd/Makefile | 5 - tools/hotplug/Linux/systemd/xenstored.service.in | 13 +-- tools/hotplug/Linux/systemd/xenstored.socket.in | 13 --- tools/hotplug/Linux/systemd/xenstored_ro.socket.in | 13 --- tools/ocaml/xenstored/systemd.ml | 2 - tools/ocaml/xenstored/systemd.mli | 8 -- tools/ocaml/xenstored/systemd_stubs.c | 98 -------------------- tools/ocaml/xenstored/utils.ml | 9 +- tools/ocaml/xenstored/xenstored.ml | 3 +- tools/xenstore/xenstored_core.c | 103 +-------------------- 17 files changed, 146 insertions(+), 300 deletions(-) create mode 100644 tools/hotplug/Linux/launch-xenstore.in delete mode 100644 tools/hotplug/Linux/systemd/xenstored.socket.in delete mode 100644 tools/hotplug/Linux/systemd/xenstored_ro.socket.in
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 1/4 tools: remove systemd xenstore socket definitions
On a system with systemd the xenstore sockets are created via systemd. Remove the related configuration files in order to be able to decide at runtime whether the sockets should be created or not. This will enable Xen to start xenstore either via a daemon or via a stub domain.
As the xenstore domain start program will exit after it has done its job prepare the same behaviour to be tolerated by systemd for the xenstore daemon by specifying the appropriate flags in the service file.
A rerun of autogen.sh is required.
---
V4: remove sd_booted() test, undo unintended white space changes
V3: re-add sd_notify() call
--- tools/configure | 4 +- tools/configure.ac | 2 - tools/hotplug/Linux/systemd/Makefile | 5 - tools/hotplug/Linux/systemd/xenstored.service.in | 5 +- tools/hotplug/Linux/systemd/xenstored.socket.in | 13 --- tools/hotplug/Linux/systemd/xenstored_ro.socket.in | 13 --- tools/ocaml/xenstored/systemd.ml | 2 - tools/ocaml/xenstored/systemd.mli | 8 -- tools/ocaml/xenstored/systemd_stubs.c | 98 -------------------- tools/ocaml/xenstored/utils.ml | 9 +- tools/ocaml/xenstored/xenstored.ml | 3 +- tools/xenstore/xenstored_core.c | 103 +-------------------- 12 files changed, 10 insertions(+), 255 deletions(-) delete mode 100644 tools/hotplug/Linux/systemd/xenstored.socket.in delete mode 100644 tools/hotplug/Linux/systemd/xenstored_ro.socket.in
tools/configure +1 -3
@@ -9670,7 +9670,7 @@ fi if test "x$systemd" = "xy"; then : - ac_config_files="$ac_config_files 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 hotplug/Linux/systemd/xendomains.service hotplug/Linux/systemd/xendriverdomain.service hotplug/Linux/systemd/xenstored.service hotplug/Linux/systemd/xenstored.socket hotplug/Linux/systemd/xenstored_ro.socket" + ac_config_files="$ac_config_files 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 hotplug/Linux/systemd/xendomains.service hotplug/Linux/systemd/xendriverdomain.service hotplug/Linux/systemd/xenstored.service" fi
@@ -10394,8 +10394,6 @@ do "hotplug/Linux/systemd/xendomains.service") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/systemd/xendomains.service" ;; "hotplug/Linux/systemd/xendriverdomain.service") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/systemd/xendriverdomain.service" ;; "hotplug/Linux/systemd/xenstored.service") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/systemd/xenstored.service" ;; - "hotplug/Linux/systemd/xenstored.socket") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/systemd/xenstored.socket" ;; - "hotplug/Linux/systemd/xenstored_ro.socket") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/systemd/xenstored_ro.socket" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac
tools/configure.ac +0 -2
@@ -438,8 +438,6 @@ AS_IF([test "x$systemd" = "xy"], [ hotplug/Linux/systemd/xendomains.service hotplug/Linux/systemd/xendriverdomain.service hotplug/Linux/systemd/xenstored.service - hotplug/Linux/systemd/xenstored.socket - hotplug/Linux/systemd/xenstored_ro.socket ]) ])
tools/hotplug/Linux/systemd/Makefile +0 -5
@@ -6,9 +6,6 @@ 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_SOCKET += xenstored_ro.socket - XEN_SYSTEMD_SERVICE = xenstored.service XEN_SYSTEMD_SERVICE += xenconsoled.service XEN_SYSTEMD_SERVICE += xen-qemu-dom0-disk-backend.service
@@ -19,7 +16,6 @@ XEN_SYSTEMD_SERVICE += xendriverdomain.service ALL_XEN_SYSTEMD = $(XEN_SYSTEMD_MODULES) \ $(XEN_SYSTEMD_MOUNT) \ - $(XEN_SYSTEMD_SOCKET) \ $(XEN_SYSTEMD_SERVICE) .PHONY: all
@@ -38,7 +34,6 @@ install: $(ALL_XEN_SYSTEMD) $(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)
tools/hotplug/Linux/systemd/xenstored.service.in +3 -2
@@ -1,6 +1,6 @@ [Unit] Description=The Xen xenstore -Requires=xenstored_ro.socket xenstored.socket proc-xen.mount var-lib-xenstored.mount +Requires=proc-xen.mount var-lib-xenstored.mount After=proc-xen.mount var-lib-xenstored.mount Before=libvirtd.service libvirt-guests.service RefuseManualStop=true
@@ -8,6 +8,8 @@ ConditionPathExists=/proc/xen/capabilities [Service] Type=notify +NotifyAccess=all +RemainAfterExit=true KillMode=none Environment=XENSTORED_ARGS= Environment=XENSTORED=@XENSTORED@
@@ -19,6 +21,5 @@ ExecStart=/bin/sh -c "exec $XENSTORED --no-fork $XENSTORED_ARGS" [Install] WantedBy=multi-user.target -Also=xenstored_ro.socket xenstored.socket Also=proc-xen.mount Also=var-lib-xenstored.mount
tools/hotplug/Linux/systemd/xenstored.socket.in deleted +0 -13
@@ -1,13 +0,0 @@ -[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] -ListenStream=@XEN_RUN_STORED@/socket -SocketMode=0600 -Service=xenstored.service - -[Install] -WantedBy=sockets.target
tools/hotplug/Linux/systemd/xenstored_ro.socket.in deleted +0 -13
@@ -1,13 +0,0 @@ -[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] -ListenStream=@XEN_RUN_STORED@/socket_ro -SocketMode=0660 -Service=xenstored.service - -[Install] -WantedBy=sockets.target
tools/ocaml/xenstored/systemd.ml +0 -2
@@ -12,6 +12,4 @@ * GNU Lesser General Public License for more details. *) -external sd_listen_fds: string -> Unix.file_descr = "ocaml_sd_listen_fds" -external launched_by_systemd: unit -> bool = "ocaml_launched_by_systemd" external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"
tools/ocaml/xenstored/systemd.mli +0 -8
@@ -12,13 +12,5 @@ * GNU Lesser General Public License for more details. *) -(** Calls the C library sd_listen_fds() function for us. Although - * the library doesn't accept argument we send one over to help - * us do sanity checks on the expected sockets *) -val sd_listen_fds: string -> Unix.file_descr - -(** Tells us whether the process is launched by systemd *) -val launched_by_systemd: unit -> bool - (** Tells systemd we're ready *) external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"
tools/ocaml/xenstored/systemd_stubs.c +0 -98
114 lines not on this page · raw message
tools/ocaml/xenstored/utils.ml +1 -8
@@ -73,22 +73,15 @@ let trim_path path = let join_by_null ls = String.concat "\000" ls (* unix utils *) -let create_regular_unix_socket name = +let create_unix_socket name = Unixext.unlink_safe name; Unixext.mkdir_rec (Filename.dirname name) 0o700; let sockaddr = Unix.ADDR_UNIX(name) in let sock = Unix.socket Unix.PF_UNIX Unix.SOCK_STREAM 0 in - Unix.set_close_on_exec sock; Unix.bind sock sockaddr; Unix.listen sock 1; sock -let create_unix_socket name = - if Systemd.launched_by_systemd() then - Systemd.sd_listen_fds name - else - create_regular_unix_socket name - let read_file_single_integer filename = let fd = Unix.openfile filename [ Unix.O_RDONLY ] 0o640 in let buf = String.make 20 (char_of_int 0) in
tools/ocaml/xenstored/xenstored.ml +1 -2
@@ -428,8 +428,7 @@ let _ = process_domains store cons domains in - if Systemd.launched_by_systemd () then - Systemd.sd_notify_ready (); + Systemd.sd_notify_ready (); while not !quit do try
tools/xenstore/xenstored_core.c +4 -99
133 lines not on this page · raw message
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 1/4] tools: remove systemd xenstore socket definitions
Quoted 5 lines · Juergen Gross
On a system with systemd the xenstore sockets are created via systemd. Remove the related configuration files in order to be able to decide at runtime whether the sockets should be created or not. This will enable Xen to start xenstore either via a daemon or via a stub domain.
Quoted 8 lines
As the xenstore domain start program will exit after it has done its job prepare the same behaviour to be tolerated by systemd for the xenstore daemon by specifying the appropriate flags in the service file.
A rerun of
autogen.shis required.Signed-off-by Juergen Gross <[email protected]>
The ocaml bits would need an ack from Dave.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
David Scott
Acked-byRe: [PATCH v4 1/4] tools: remove systemd xenstore socket definitions
Quoted 14 lines · Wei Liu
Quoted 10 lines · Juergen Gross
On a system with systemd the xenstore sockets are created via systemd. Remove the related configuration files in order to be able to decide at runtime whether the sockets should be created or not. This will enable Xen to start xenstore either via a daemon or via a stub domain.
As the xenstore domain start program will exit after it has done its job prepare the same behaviour to be tolerated by systemd for the xenstore daemon by specifying the appropriate flags in the service file.
Quoted 7 lines
Quoted 3 lines
A rerun of
autogen.shis required.Signed-off-by Juergen Gross <[email protected]>Acked-by Wei Liu <[email protected]>The ocaml bits would need an ack from Dave.
The OCaml bits look fine to me
Cheers,
Dave
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 2/4 tools: split out xenstored starting form xencommons
In reply to Juergen GrossIn order to prepare starting a xenstore domain split out the starting of the xenstore daemon from the xencommons script into a dedicated launch-xenstore script.
Correct one error: don't remove old tdb files in background, as this could lead to very subtle races.
A rerun of autogen.sh is required.
--- .gitignore | 1 + tools/configure | 3 +- tools/configure.ac | 1 + tools/hotplug/Linux/Makefile | 1 + tools/hotplug/Linux/init.d/xencommons.in | 36 ++------------------- tools/hotplug/Linux/launch-xenstore.in | 55 ++++++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 34 deletions(-) create mode 100644 tools/hotplug/Linux/launch-xenstore.in
.gitignore +1 -0
@@ -157,6 +157,7 @@ tools/hotplug/Linux/init.d/xen-watchdog tools/hotplug/Linux/init.d/xencommons tools/hotplug/Linux/init.d/xendomains tools/hotplug/Linux/init.d/xendriverdomain +tools/hotplug/Linux/launch-xenstore tools/hotplug/Linux/systemd/*.conf tools/hotplug/Linux/systemd/*.mount tools/hotplug/Linux/systemd/*.socket
tools/configure +2 -1
@@ -2410,7 +2410,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/sysconfig.xendomains hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain libxl/xenlight.pc.in libxl/xlutil.pc.in ocaml/xenstored/oxenstored.conf" +ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/sysconfig.xendomains hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain hotplug/Linux/launch-xenstore hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain libxl/xenlight.pc.in libxl/xlutil.pc.in ocaml/xenstored/oxenstored.conf" ac_config_headers="$ac_config_headers config.h"
@@ -10376,6 +10376,7 @@ do "hotplug/Linux/init.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xencommons" ;; "hotplug/Linux/init.d/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendomains" ;; "hotplug/Linux/init.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendriverdomain" ;; + "hotplug/Linux/launch-xenstore") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/launch-xenstore" ;; "hotplug/Linux/vif-setup") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/vif-setup" ;; "hotplug/Linux/xen-hotplug-common.sh") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xen-hotplug-common.sh" ;; "hotplug/Linux/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xendomains" ;;
tools/configure.ac +1 -0
@@ -15,6 +15,7 @@ hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain +hotplug/Linux/launch-xenstore hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains
tools/hotplug/Linux/Makefile +1 -0
@@ -30,6 +30,7 @@ XEN_SCRIPTS += block-drbd-probe XEN_SCRIPTS += block-dummy XEN_SCRIPTS += $(XEN_SCRIPTS-y) XEN_SCRIPTS += colo-proxy-setup +XEN_SCRIPTS += launch-xenstore SUBDIRS-$(CONFIG_SYSTEMD) += systemd
tools/hotplug/Linux/init.d/xencommons.in +3 -33
@@ -18,7 +18,6 @@ # Description: Starts and stops the daemons neeeded for xl/xend ### END INIT INFO -XENSTORED=@XENSTORED@ BACKEND_MODULES="@LINUX_BACKEND_MODULES@" . @XEN_SCRIPT_DIR@/hotplugpath.sh
@@ -53,8 +52,6 @@ if test -f /proc/xen/capabilities && \ fi do_start () { - local time=0 - local timeout=30 local mod for mod in $BACKEND_MODULES ; do modprobe "$mod" &>/dev/null ; done
@@ -62,37 +59,10 @@ do_start () { mkdir -p ${XEN_RUN_DIR} mkdir -p ${XEN_LOCK_DIR} - if ! `${bindir}/xenstore-read -s / >/dev/null 2>&1` - then - test -z "$XENSTORED_ROOTDIR" && XENSTORED_ROOTDIR="@XEN_LIB_STORED@" - rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null - test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T @XEN_LOG_DIR@/xenstored-trace.log" + @XEN_SCRIPT_DIR@/launch-xenstore || exit 1 - if [ -n "$XENSTORED" ] ; then - echo -n Starting $XENSTORED... - $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS - else - echo "No xenstored found" - exit 1 - fi - - # Wait for xenstored to actually come up, timing out after 30 seconds - while [ $time -lt $timeout ] && ! `${bindir}/xenstore-read -s / >/dev/null 2>&1` ; do - echo -n . - time=$(($time+1)) - sleep 1 - done - echo - - # Exit if we timed out - if ! [ $time -lt $timeout ] ; then - echo Could not start xenstored - exit 1 - fi - - echo Setting domain 0 name, domid and JSON config... - ${LIBEXEC_BIN}/xen-init-dom0 - fi + echo Setting domain 0 name, domid and JSON config... + ${LIBEXEC_BIN}/xen-init-dom0 echo Starting xenconsoled... test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" --log=$XENCONSOLED_TRACE"
tools/hotplug/Linux/launch-xenstore.in new file +55 -0
55 lines not on this page · raw message
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 2/4] tools: split out xenstored starting form xencommons
Quoted 7 lines · Juergen Gross
In order to prepare starting a xenstore domain split out the starting of the xenstore daemon from the xencommons script into a dedicated launch-xenstore script.
Correct one error: don't remove old tdb files in background, as this could lead to very subtle races.
Sorry to only notice this now -- I suppose this shouldn't be in commit message because it is a changelog for different revision of your patch, or you need to describe what the race is if there is really such issue -- and that's a potential backport candidate.
As far as I can tell this is pure code motion and shouldn't have any change in behaviour. Hence this line in commit message makes me feel a bit confused.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 2/4] tools: split out xenstored starting form xencommons
Quoted 5 lines · Wei Liu
Quoted 4 lines · Juergen Gross
In order to prepare starting a xenstore domain split out the starting of the xenstore daemon from the xencommons script into a dedicated launch-xenstore script.
Quoted 8 lines
Quoted 3 lines
Correct one error: don't remove old tdb files in background, as this could lead to very subtle races.
Sorry to only notice this now -- I suppose this shouldn't be in commit message because it is a changelog for different revision of your patch, or you need to describe what the race is if there is really such issue -- and that's a potential backport candidate.
- rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null
...
+ rm -f "$XENSTORED_ROOTDIR"/tdb* 2>/dev/null
Please note the "&" in the removed line. And the description just tells you that: the file shouldn't be removed in the background. How else would you describe it?
And the race should be obvious: removing a file in the background which is going to be used by the next command is racy.
Quoted 3 lines
As far as I can tell this is pure code motion and shouldn't have any change in behaviour. Hence this line in commit message makes me feel a bit confused.
Still confused?
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 2/4] tools: split out xenstored starting form xencommons
Quoted 23 lines · Juergen Gross
Quoted 13 lines · Wei Liu
Quoted 7 lines · Juergen Gross
In order to prepare starting a xenstore domain split out the starting of the xenstore daemon from the xencommons script into a dedicated launch-xenstore script.
Correct one error: don't remove old tdb files in background, as this could lead to very subtle races.
Sorry to only notice this now -- I suppose this shouldn't be in commit message because it is a changelog for different revision of your patch, or you need to describe what the race is if there is really such issue -- and that's a potential backport candidate.
(quoted diff) +1
-1- rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null + rm -f "$XENSTORED_ROOTDIR"/tdb* 2>/dev/nullPlease note the "&" in the removed line. And the description just tells you that: the file shouldn't be removed in the background. How else would you describe it?
Quoted 8 lines
And the race should be obvious: removing a file in the background which is going to be used by the next command is racy.
Quoted 3 lines
As far as I can tell this is pure code motion and shouldn't have any change in behaviour. Hence this line in commit message makes me feel a bit confused.
Still confused?
Ah, the 2> vs &> thing is really subtle. I missed that, sorry.
I think you need to separate that one change out so that we can backport it to stable releases to avoid the race.
Wei.
Quoted 3 lines
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 2/4] tools: split out xenstored starting form xencommons
Wei Liu writes ("Re: [PATCH v4 2/4] tools: split out xenstored starting form xencommons"):
Quoted 4 lines · Juergen Gross
Quoted 1 line
Still confused?
Ah, the 2> vs &> thing is really subtle. I missed that, sorry.
`&>' is a (bash-specific, I think) syntax for redirection, not a request to run anything in the background.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 2/4] tools: split out xenstored starting form xencommons
Quoted 9 lines · Ian Jackson
Wei Liu writes ("Re: [PATCH v4 2/4] tools: split out xenstored starting form xencommons"):
Quoted 4 lines · Juergen Gross
Quoted 1 line
Still confused?
Ah, the 2> vs &> thing is really subtle. I missed that, sorry.
`&>' is a (bash-specific, I think) syntax for redirection, not a request to run anything in the background.
I skimmed too fast and read that as "& >". :-/
Quoted 1 line
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 2/4] tools: split out xenstored starting form xencommons
In reply to Juergen GrossQuoted 6 lines · Juergen Gross
(quoted diff) +1
-1- rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null + rm -f "$XENSTORED_ROOTDIR"/tdb* 2>/dev/nullPlease note the "&" in the removed line. And the description just tells you that: the file shouldn't be removed in the background. How else would you describe it?
"&>" redirects stdout and stderr at the same time. See bash(1) "Redirecting Standard Output and Standard Error". Are you saying it does fork into background instead?
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 2/4] tools: split out xenstored starting form xencommons
Quoted 5 lines · Olaf Hering
Quoted 3 lines · Juergen Gross
(quoted diff) +1
-1- rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null + rm -f "$XENSTORED_ROOTDIR"/tdb* 2>/dev/null
Quoted 7 lines
Quoted 3 lines
Please note the "&" in the removed line. And the description just tells you that: the file shouldn't be removed in the background. How else would you describe it?
"&>" redirects stdout and stderr at the same time. See bash(1) "Redirecting Standard Output and Standard Error". Are you saying it does fork into background instead?
No. I'm saying that I managed to overlook that part of the man page.
I explicitly had a look as I didn't know the &> notation and I wanted to make sure I don't miss anything. I failed obviously. :-(
Thanks for the bash lesson. :-)
V5 is about to come...
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 2/4] tools: split out xenstored starting form xencommons
In reply to Olaf HeringOlaf Hering writes ("Re: [Xen-devel] [PATCH v4 2/4] tools: split out xenstored starting form xencommons"):
Quoted 3 lines
"&>" redirects stdout and stderr at the same time. See bash(1) "Redirecting Standard Output and Standard Error". Are you saying it does fork into background instead?
Snap. That'll teach me not to read the whole thread :-).
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 3/4 tools: use pidfile for test if xenstored is running
In reply to Juergen GrossInstead of trying to read xenstore via xenstore-read use the pidfile of xenstored for the test whether xenstored is running. This prepares support of xenstore domain, as trying to read xenstore will block for ever in case xenstore domain is started after trying to read.
---
V4: use @XEN_RUN_DIR@ as requested by Wei Liu
--- tools/hotplug/Linux/init.d/xencommons.in | 2 +- tools/hotplug/Linux/launch-xenstore.in | 58 +++++++++++++++++++------------- 2 files changed, 35 insertions(+), 25 deletions(-)
tools/hotplug/Linux/init.d/xencommons.in +1 -1
@@ -96,7 +96,7 @@ case "$1" in do_start ;; status) - ${bindir}/xenstore-read -s / + test -f @XEN_RUN_DIR@/xenstored.pid ;; stop) do_stop
tools/hotplug/Linux/launch-xenstore.in +34 -24
72 lines not on this page · raw message
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 3/4] tools: use pidfile for test if xenstored is running
Quoted 6 lines · Juergen Gross
Instead of trying to read xenstore via xenstore-read use the pidfile of xenstored for the test whether xenstored is running. This prepares support of xenstore domain, as trying to read xenstore will block for ever in case xenstore domain is started after trying to read.
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 4/4 tools: make xenstore domain easy configurable
In reply to Juergen GrossAdd configuration entries to sysconfig.xencommons for selection of the xenstore type (domain or daemon) and start the selected xenstore service via a script called from sysvinit or systemd.
---
V3: - remove check for running xenstore domain, as this is done in
init-xenstore-domain already
- if booted with systemd send a systemd-notify message in the xenstore domain case
- if booted with systemd don't wait until xenstore daemon is running, as the daemon will have sent a notify message by its own
- split up patch as requested by Ian Jackson
V2: - add .gitignore entry for launch-xenstore
--- tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 42 ++++++++++++++++++++-- tools/hotplug/Linux/launch-xenstore.in | 42 ++++++++++++++++------ tools/hotplug/Linux/systemd/xenstored.service.in | 8 +---- 3 files changed, 72 insertions(+), 20 deletions(-)
tools/hotplug/Linux/init.d/sysconfig.xencommons.in +39 -3
@@ -6,12 +6,24 @@ #XENCONSOLED_TRACE=[none|guest|hv|all] ## Type: string +## Default: daemon +# +# Select type of xentore service. +# +# This can be either of: +# * daemon +# * domain +# +# Changing this requires a reboot to take effect. +# +#XENSTORETYPE=daemon + +## Type: string ## Default: xenstored # # Select xenstore implementation, this can be either -# of these below. If using systemd it's preferred that you -# just edit the xenstored.service unit file and change -# the XENSTORED variable there. +# of these below. +# Only evaluated if XENSTORETYPE is "daemon". # # This can be either of: # * @sbindir@/oxenstored
@@ -26,21 +38,45 @@ # Additional commandline arguments to start xenstored, # like "--trace-file @XEN_LOG_DIR@/xenstored-trace.log" # See "@sbindir@/xenstored --help" for possible options. +# Only evaluated if XENSTORETYPE is "daemon". XENSTORED_ARGS= ## Type: string ## Default: Not defined, tracing off # # Log xenstored messages +# Only evaluated if XENSTORETYPE is "daemon". #XENSTORED_TRACE=[yes|on|1] ## Type: string ## Default: "@XEN_LIB_STORED@" # # Running xenstored on XENSTORED_ROOTDIR +# Only evaluated if XENSTORETYPE is "daemon". #XENSTORED_ROOTDIR=@XEN_LIB_STORED@ ## Type: string +## Default: @LIBEXEC@/boot/xenstore-stubdom.gz +# +# xenstore domain kernel. +# Only evaluated if XENSTORETYPE is "domain". +#XENSTORE_DOMAIN_KERNEL=@LIBEXEC@/boot/xenstore-stubdom.gz + +## Type: integer +## Default: 8 +# +# xenstore domain memory size in MiB. +# Only evaluated if XENSTORETYPE is "domain". +#XENSTORE_DOMAIN_SIZE=8 + +## Type: string +## Default: "" +# +# Additional arguments for starting the xenstore domain. +# Only evaluated if XENSTORETYPE is "domain". +XENSTORE_DOMAIN_ARGS= + +## Type: string ## Default: Not defined, xenbackendd debug mode off # # Running xenbackendd in debug mode
tools/hotplug/Linux/launch-xenstore.in +32 -10
50 lines not on this page · raw message
tools/hotplug/Linux/systemd/xenstored.service.in +1 -7
@@ -10,14 +10,8 @@ ConditionPathExists=/proc/xen/capabilities Type=notify NotifyAccess=all RemainAfterExit=true -KillMode=none -Environment=XENSTORED_ARGS= -Environment=XENSTORED=@XENSTORED@ -EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons 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" +ExecStart=@XEN_SCRIPT_DIR@/launch-xenstore [Install] WantedBy=multi-user.target
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 4/4] tools: make xenstore domain easy configurable
Quoted 5 lines · Juergen Gross
Add configuration entries to sysconfig.xencommons for selection of the xenstore type (domain or daemon) and start the selected xenstore service via a script called from sysvinit or systemd.
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel