diff mbox series

[v3,23/33] tools/xenstored: move systemd handling to posix.c

Message ID 20240104090055.27323-24-jgross@suse.com (mailing list archive)
State Superseded
Headers show
Series tools: enable xenstore-stubdom to use 9pfs | expand

Commit Message

Jürgen Groß Jan. 4, 2024, 9 a.m. UTC
Move systemd handling to a new late_init() function in posix.c.

This prepares a future removal of the NO_SOCKETS macro.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- new patch
---
 tools/xenstored/core.c   | 17 +----------------
 tools/xenstored/core.h   |  1 +
 tools/xenstored/minios.c |  4 ++++
 tools/xenstored/posix.c  | 13 +++++++++++++
 4 files changed, 19 insertions(+), 16 deletions(-)

Comments

Jason Andryuk Jan. 10, 2024, 8:26 p.m. UTC | #1
On Thu, Jan 4, 2024 at 4:13 AM Juergen Gross <jgross@suse.com> wrote:
>
> Move systemd handling to a new late_init() function in posix.c.
>
> This prepares a future removal of the NO_SOCKETS macro.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
Julien Grall Jan. 25, 2024, 6:48 p.m. UTC | #2
Hi Juergen,

On 04/01/2024 09:00, Juergen Gross wrote:
> Move systemd handling to a new late_init() function in posix.c.
> 
> This prepares a future removal of the NO_SOCKETS macro.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Julien Grall <jgrall@amazon.com>

Cheers,
diff mbox series

Patch

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index eba7744fde..7b5e1d0c0f 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -54,16 +54,6 @@ 
 #include "control.h"
 #include "lu.h"
 
-#ifndef NO_SOCKETS
-#if defined(HAVE_SYSTEMD)
-#define XEN_SYSTEMD_ENABLED 1
-#endif
-#endif
-
-#if defined(XEN_SYSTEMD_ENABLED)
-#include <systemd/sd-daemon.h>
-#endif
-
 extern xenevtchn_handle *xce_handle; /* in domain.c */
 static int xce_pollfd_idx = -1;
 static struct pollfd *fds;
@@ -2938,12 +2928,7 @@  int main(int argc, char *argv[])
 	/* Get ready to listen to the tools. */
 	initialize_fds(&sock_pollfd_idx, &timeout);
 
-#if defined(XEN_SYSTEMD_ENABLED)
-	if (!live_update) {
-		sd_notify(1, "READY=1");
-		fprintf(stderr, SD_NOTICE "xenstored is ready\n");
-	}
-#endif
+	late_init(live_update);
 
 	/* Main loop. */
 	for (;;) {
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index 72173f1684..0de2d8a26e 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -385,6 +385,7 @@  static inline bool domain_is_unprivileged(const struct connection *conn)
 /* Return the event channel used by xenbus. */
 evtchn_port_t get_xenbus_evtchn(void);
 void early_init(bool live_update, bool dofork, const char *pidfile);
+void late_init(bool live_update);
 
 void init_sockets(void);
 extern int reopen_log_pipe[2];
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 4f48f63083..45bb0440be 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -49,3 +49,7 @@  void unmap_xenbus(void *interface)
 void early_init(bool live_update, bool dofork, const char *pidfile)
 {
 }
+
+void late_init(bool live_update)
+{
+}
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index 9463ef5c8d..97c8dcaba3 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -24,6 +24,9 @@ 
 #include <stdlib.h>
 #include <syslog.h>
 #include <sys/mman.h>
+#if defined(HAVE_SYSTEMD)
+#include <systemd/sd-daemon.h>
+#endif
 #include <xen-tools/xenstore-common.h>
 
 #include "utils.h"
@@ -184,3 +187,13 @@  void early_init(bool live_update, bool dofork, const char *pidfile)
 	if (!live_update)
 		init_sockets();
 }
+
+void late_init(bool live_update)
+{
+#if defined(HAVE_SYSTEMD)
+	if (!live_update) {
+		sd_notify(1, "READY=1");
+		fprintf(stderr, SD_NOTICE "xenstored is ready\n");
+	}
+#endif
+}