Skip to contentSkip to conversation

xenstored: do not redirect stderr to /dev/null

PATCH In review Edwin Török 2 participants 2 messages Oct 25, 2023 – Oct 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xenstored: do not redirect stderr to /dev/null

From: Edwin Török <[email protected]>

By default stderr gets redirected to /dev/null because oxenstored daemonizes itself. This must be a left-over from pre-systemd days.

In ee7815f49f ("tools/oxenstored: Set uncaught exception handler") a workaround was added to log exceptions directly to syslog to cope with standard error being lost.

However it is better to not lose standard error (what if the connection to syslog itself fails, how'd we log that?), and use the '--no-fork' flag to do that.
This flag is supported by both C and O versions of xenstored.

Both versions also call sd_notify so there is no need for forking.

Leave the default daemonize as is so that xenstored keeps working on non-Linux systems as before.

---
 tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/init.d/sysconfig.xencommons.in +1 -1
index 433e4849af..09a1230cee 100644
@@ -52,7 +52,7 @@
 # like "--trace-file @XEN_LOG_DIR@/xenstored-trace.log"
 # See "@sbindir@/xenstored --help" for possible options.
 # Only evaluated if XENSTORETYPE is "daemon".
-XENSTORED_ARGS=
+XENSTORED_ARGS=--no-fork
 
 ## Type: string
 ## Default: Not defined, tracing off
Signature · 1 line
2.41.0
#1 lore raw
Quoted 30 lines · Edwin Török

From: Edwin Török <[email protected]>

By default stderr gets redirected to /dev/null because oxenstored daemonizes itself. This must be a left-over from pre-systemd days.

In ee7815f49f ("tools/oxenstored: Set uncaught exception handler") a workaround was added to log exceptions directly to syslog to cope with standard error being lost.

However it is better to not lose standard error (what if the connection to syslog itself fails, how'd we log that?), and use the '--no-fork' flag to do that.
This flag is supported by both C and O versions of xenstored.

Both versions also call sd_notify so there is no need for forking.

Leave the default daemonize as is so that xenstored keeps working on non-Linux systems as before.

---
tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/init.d/sysconfig.xencommons.in +0 -0
index 433e4849af..09a1230cee 100644

tools/hotplug/Linux/init.d/sysconfig.xencommons.in line 55

Quoted 5 lines
tools/hotplug/Linux/init.d/sysconfig.xencommons.in +1 -1
@@ -52,7 +52,7 @@
 # like "--trace-file @XEN_LOG_DIR@/xenstored-trace.log"
 # See "@sbindir@/xenstored --help" for possible options.
 # Only evaluated if XENSTORETYPE is "daemon".
-XENSTORED_ARGS=
+XENSTORED_ARGS=--no-fork

I think the CI failure is due to this patch, and it only happens on Linux systems that do not use systemd. In that case we do need to fork, because that is the only way not to tie up the boot sequence.

I'll try to make '--no-fork' depend on having systemd present, because otherwise I tested both C and O xenstored and they do start up with --no-fork.

Best regards,
--Edwin