]> xenbits.xensource.com Git - xen.git/commitdiff
tools/xenstored: move systemd handling to posix.c
authorJuergen Gross <jgross@suse.com>
Mon, 5 Feb 2024 10:49:51 +0000 (11:49 +0100)
committerJulien Grall <jgrall@amazon.com>
Mon, 5 Feb 2024 19:26:32 +0000 (19:26 +0000)
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>
Reviewed-by: Julien Grall <jgrall@amazon.com>
tools/xenstored/core.c
tools/xenstored/core.h
tools/xenstored/minios.c
tools/xenstored/posix.c

index eba7744fde5af2fb19eb545d299ec81760ff3730..7b5e1d0c0fd7d08b07105ca1ba0615f2e36b87f8 100644 (file)
 #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 (;;) {
index 72173f168456ee52ff73aec9e002660be38fd3fa..0de2d8a26ed9f3cf3a55be95a6c9c0a0cd9523df 100644 (file)
@@ -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];
index 4f48f6308378c7c1274bd10e2012749ccf7d54ec..45bb0440beec906e43d552186d8a00d6a4a8c5e0 100644 (file)
@@ -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)
+{
+}
index 9463ef5c8d7e77194fdd20ea23697149824c1915..97c8dcaba34d0e62f50c77a2e43efff75039e75f 100644 (file)
@@ -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
+}