Skip to contentSkip to conversation

Drop libsystemd

PATCH Superseded Andrew Cooper 5 participants 12 messages Apr 25, 2024 – May 1, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Drop libsystemd

On advise from the systemd leadership. See patch 1 for details.

Andrew Cooper (2):
tools/{c,o}xenstored: Don't link against libsystemd
tools: Drop libsystemd as a dependency

 automation/build/archlinux/current.dockerfile |   1 +
 .../build/suse/opensuse-leap.dockerfile       |   1 +
 .../build/suse/opensuse-tumbleweed.dockerfile |   1 +
 automation/build/ubuntu/focal.dockerfile      |   1 +
 config/Tools.mk.in                            |   2 -
 m4/systemd.m4                                 |  23 +-
 tools/config.h.in                             |   3 -
 tools/configure                               | 523 +-----------------
 tools/ocaml/xenstored/Makefile                |  12 +-
 tools/ocaml/xenstored/systemd.ml              |  15 -
 tools/ocaml/xenstored/systemd.mli             |  16 -
 tools/ocaml/xenstored/systemd_stubs.c         |  47 --
 tools/ocaml/xenstored/xenstored.ml            |   1 -
 tools/xenstored/Makefile                      |   5 -
 tools/xenstored/posix.c                       |   9 -
 15 files changed, 8 insertions(+), 652 deletions(-)
 delete mode 100644 tools/ocaml/xenstored/systemd.ml
 delete mode 100644 tools/ocaml/xenstored/systemd.mli
 delete mode 100644 tools/ocaml/xenstored/systemd_stubs.c

base-commit: 23cd1207e7f6ee3e51fb42e11dba8d7cdb28e1e5

Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 tools/{c,o}xenstored: Don't link against libsystemd

libsystemd is a giant dependency for one single function, but in the wake of the xz backdoor, it turns out that even systemd leadership recommend against linking against libsystemd for sd_notify().

Since commit 7b61011e1450 ("tools: make xenstore domain easy configurable") in Xen 4.8, the launch-xenstore script invokes systemd-notify directly, so its not even necessary for the xenstored's to call sd_notify() themselves.

Therefore, just drop the calls to sd_notify() and stop linking against libsystemd.

No functional change.

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>
CC: Stefano Stabellini <[email protected]>

---
 tools/ocaml/xenstored/Makefile        | 12 +------
 tools/ocaml/xenstored/systemd.ml      | 15 ---------
 tools/ocaml/xenstored/systemd.mli     | 16 ---------
 tools/ocaml/xenstored/systemd_stubs.c | 47 ---------------------------
 tools/ocaml/xenstored/xenstored.ml    |  1 -
 tools/xenstored/Makefile              |  5 ---
 tools/xenstored/posix.c               |  9 -----
 7 files changed, 1 insertion(+), 104 deletions(-)
 delete mode 100644 tools/ocaml/xenstored/systemd.ml
 delete mode 100644 tools/ocaml/xenstored/systemd.mli
 delete mode 100644 tools/ocaml/xenstored/systemd_stubs.c
tools/ocaml/xenstored/Makefile +1 -11
index e8aaecf2e630..1e4b51cc5432 100644
@@ -4,8 +4,6 @@ include $(OCAML_TOPLEVEL)/common.make
 
 # Include configure output (config.h)
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
-CFLAGS-$(CONFIG_SYSTEMD)  += $(SYSTEMD_CFLAGS)
-LDFLAGS-$(CONFIG_SYSTEMD) += $(SYSTEMD_LIBS)
 
 CFLAGS  += $(CFLAGS-y)
 CFLAGS  += $(APPEND_CFLAGS)
@@ -25,13 +23,6 @@ poll_OBJS = poll
 poll_C_OBJS = select_stubs
 OCAML_LIBRARY = syslog poll
 
-LIBS += systemd.cma systemd.cmxa
-systemd_OBJS = systemd
-systemd_C_OBJS = systemd_stubs
-OCAML_LIBRARY += systemd
-
-LIBS_systemd += $(LDFLAGS-y)
-
 OBJS = paths \
 	define \
 	stdext \
@@ -56,12 +47,11 @@ OBJS = paths \
 	process \
 	xenstored
 
-INTF = symbol.cmi trie.cmi syslog.cmi systemd.cmi poll.cmi
+INTF = symbol.cmi trie.cmi syslog.cmi poll.cmi
 
 XENSTOREDLIBS = \
 	unix.cmxa \
 	-ccopt -L -ccopt . syslog.cmxa \
-	-ccopt -L -ccopt . systemd.cmxa \
 	-ccopt -L -ccopt . poll.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/mmap $(OCAML_TOPLEVEL)/libs/mmap/xenmmap.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \
tools/ocaml/xenstored/systemd.ml deleted +0 -15
deleted file mode 100644
index 39127f712d72..000000000000
@@ -1,15 +0,0 @@
-(*
- * Copyright (C) 2014 Luis R. Rodriguez <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *)
-
-external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"
tools/ocaml/xenstored/systemd.mli deleted +0 -16
deleted file mode 100644
index 18b9331031f9..000000000000
@@ -1,16 +0,0 @@
-(*
- * Copyright (C) 2014 Luis R. Rodriguez <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *)
-
-(** Tells systemd we're ready *)
-external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"
tools/ocaml/xenstored/systemd_stubs.c deleted +0 -47

47 lines not on this page · raw message

tools/ocaml/xenstored/xenstored.ml +0 -1
index 1aaa3e995e1f..6bcd6d11da55 100644
@@ -621,7 +621,6 @@ let () =
     process_domains store cons domains
   in
 
-  Systemd.sd_notify_ready ();
   let live_update = ref false in
   while not (!quit && Connections.prevents_quit cons = [])
   do
tools/xenstored/Makefile +0 -5
index e0897ed1ba30..09adfe1d5064 100644
@@ -9,11 +9,6 @@ xenstored: LDLIBS += $(LDLIBS_libxenctrl)
 xenstored: LDLIBS += -lrt
 xenstored: LDLIBS += $(SOCKET_LIBS)
 
-ifeq ($(CONFIG_SYSTEMD),y)
-$(XENSTORED_OBJS-y): CFLAGS += $(SYSTEMD_CFLAGS)
-xenstored: LDLIBS += $(SYSTEMD_LIBS)
-endif
-
 TARGETS := xenstored
 
 .PHONY: all
tools/xenstored/posix.c +0 -9
index d88c82d972d7..dc4ed8db591f 100644
@@ -26,9 +26,6 @@
 #include <sys/mman.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-#if defined(HAVE_SYSTEMD)
-#include <systemd/sd-daemon.h>
-#endif
 #include <xen-tools/xenstore-common.h>
 
 #include "utils.h"
@@ -390,12 +387,6 @@ void handle_special_fds(void)
 
 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
 }
 
 int get_socket_fd(void)
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH 1/2] tools/{c,o}xenstored: Don't link against libsystemd

Quoted 6 lines · Andrew Cooper

libsystemd is a giant dependency for one single function, but in the wake of the xz backdoor, it turns out that even systemd leadership recommend against linking against libsystemd for sd_notify().

Since commit 7b61011e1450 ("tools: make xenstore domain easy configurable") in Xen 4.8, the launch-xenstore script invokes systemd-notify directly, so its

That's not enough, it's needs to be systemd-notify --ready to be a replacement for sd_notify(READY=1).

Quoted 1 line

not even necessary for the xenstored's to call sd_notify() themselves.

So, sd_notify() or equivalent is still necessary.

Quoted 2 lines

Therefore, just drop the calls to sd_notify() and stop linking against libsystemd.

Sounds good, be we need to replace the call by something like:
echo READY=1 > $NOTIFY_SOCKET
implemented in C and ocaml. Detail to be checked.

Otherwise, things won't work.

Thanks,

Signature · 1 line
Anthony PERARD
#3 lore raw

Re: [PATCH 1/2] tools/{c,o}xenstored: Don't link against libsystemd

Quoted 13 lines · Anthony PERARD
Quoted 6 lines · Andrew Cooper

libsystemd is a giant dependency for one single function, but in the wake of the xz backdoor, it turns out that even systemd leadership recommend against linking against libsystemd for sd_notify().

Since commit 7b61011e1450 ("tools: make xenstore domain easy configurable") in Xen 4.8, the launch-xenstore script invokes systemd-notify directly, so its

That's not enough, it's needs to be systemd-notify --ready to be a replacement for sd_notify(READY=1).

Quoted 1 line

not even necessary for the xenstored's to call sd_notify() themselves.

So, sd_notify() or equivalent is still necessary.

Quoted 7 lines
Quoted 2 lines

Therefore, just drop the calls to sd_notify() and stop linking against libsystemd.

Sounds good, be we need to replace the call by something like:
echo READY=1 > $NOTIFY_SOCKET
implemented in C and ocaml. Detail to be checked.

Otherwise, things won't work.

Hmm.  It worked in XenRT when stripping this all out, but that is extremely unintuitive behaviour for systemd-notify --booted, seeing as it's entirely different to --ready.

I've got no interest in keeping the C around, but if:

[ -n "$NOTIFY_SOCKET" ] && echo READY=1 > $NOTIFY_SOCKET

works, then can't we just use that after waiting for the the pidfile ?

~Andrew

#4 lore raw

Re: [PATCH 1/2] tools/{c,o}xenstored: Don't link against libsystemd

Quoted 16 lines · Andrew Cooper
Quoted 15 lines · Anthony PERARD
Quoted 6 lines · Andrew Cooper

libsystemd is a giant dependency for one single function, but in the wake of the xz backdoor, it turns out that even systemd leadership recommend against linking against libsystemd for sd_notify().

Since commit 7b61011e1450 ("tools: make xenstore domain easy configurable") in Xen 4.8, the launch-xenstore script invokes systemd-notify directly, so its

That's not enough, it's needs to be systemd-notify --ready to be a replacement for sd_notify(READY=1).

Quoted 1 line

not even necessary for the xenstored's to call sd_notify() themselves.

So, sd_notify() or equivalent is still necessary.

Quoted 2 lines

Therefore, just drop the calls to sd_notify() and stop linking against libsystemd.

Quoted 7 lines
Quoted 5 lines

Sounds good, be we need to replace the call by something like:
echo READY=1 > $NOTIFY_SOCKET
implemented in C and ocaml. Detail to be checked.

Otherwise, things won't work.

Hmm.  It worked in XenRT when stripping this all out, but that is

I don't know how XenServer is setup, maybe it doesn't matter? Anyway...

Quoted 2 lines

extremely unintuitive behaviour for systemd-notify --booted, seeing as it's entirely different to --ready.

Yes, this --booted option should probably not exist, and there's systemctl is-system-running that does something similar.

Quoted 6 lines

I've got no interest in keeping the C around, but if:

[ -n "$NOTIFY_SOCKET" ] && echo READY=1 > $NOTIFY_SOCKET

works, then can't we just use that after waiting for the the pidfile ?

Run systemd-notify --ready instead. Hopefully, that will be enough. ($NOTIFY_SOCKET is a socket, and a bit more complicated that I though, it can start with "@" for example)

Cheers,

Signature · 1 line
Anthony PERARD
#5 lore raw

Re: [PATCH 1/2] tools/{c,o}xenstored: Don't link against libsystemd

Quoted 17 lines · Anthony PERARD
Quoted 16 lines · Andrew Cooper
Quoted 15 lines · Anthony PERARD
Quoted 6 lines · Andrew Cooper

libsystemd is a giant dependency for one single function, but in the wake of the xz backdoor, it turns out that even systemd leadership recommend against linking against libsystemd for sd_notify().

Since commit 7b61011e1450 ("tools: make xenstore domain easy configurable") in Xen 4.8, the launch-xenstore script invokes systemd-notify directly, so its

That's not enough, it's needs to be systemd-notify --ready to be a replacement for sd_notify(READY=1).

Quoted 1 line

not even necessary for the xenstored's to call sd_notify() themselves.

So, sd_notify() or equivalent is still necessary.

Quoted 2 lines

Therefore, just drop the calls to sd_notify() and stop linking against libsystemd.

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

Sounds good, be we need to replace the call by something like:
echo READY=1 > $NOTIFY_SOCKET
implemented in C and ocaml. Detail to be checked.

Otherwise, things won't work.

Hmm.  It worked in XenRT when stripping this all out, but that is

I don't know how XenServer is setup, maybe it doesn't matter?

In theory it's straight systemd, but I could also believe that Xapi checks for the pidfile too.

Quoted 7 lines

Anyway...

Quoted 2 lines

extremely unintuitive behaviour for systemd-notify --booted, seeing as it's entirely different to --ready.

Yes, this --booted option should probably not exist, and there's systemctl is-system-running that does something similar.

Quoted 8 lines
Quoted 5 lines

I've got no interest in keeping the C around, but if:

[ -n "$NOTIFY_SOCKET" ] && echo READY=1 > $NOTIFY_SOCKET

works, then can't we just use that after waiting for the the pidfile ?

Run systemd-notify --ready instead. Hopefully, that will be enough. ($NOTIFY_SOCKET is a socket, and a bit more complicated that I though, it can start with "@" for example)

I'll do a prep patch to adjust launch-xenstore after which this patch should be fine in this form (modulo a tweak in the commit message).

~Andrew

#6 lore raw

Re: [PATCH 1/2] tools/{c,o}xenstored: Don't link against libsystemd

In reply to Anthony PERARD
Quoted 3 lines · Anthony PERARD

Run systemd-notify --ready instead. Hopefully, that will be enough. ($NOTIFY_SOCKET is a socket, and a bit more complicated that I though, it can start with "@" for example)

FTR: If it turns out that calling systemd-notify binary isn't working well enough, we could have an implementation of sd_notify() in our tree, openssh are doing there own here:
https://bugzilla.mindrot.org/show_bug.cgi?id=2641
and there's an example implementation on systemd's documentation:
https://www.freedesktop.org/software/systemd/man/devel/sd_notify.html#Notes
(Nothing for ocaml)

But let's go with systemd-notify --ready as it is just easier to write a bit of shell script.

Cheers,

Signature · 1 line
Anthony PERARD
#7 lore raw

Re: [PATCH 1/2] tools/{c,o}xenstored: Don't link against libsystemd

Quoted 12 lines · Anthony PERARD
Quoted 3 lines · Anthony PERARD

Run systemd-notify --ready instead. Hopefully, that will be enough. ($NOTIFY_SOCKET is a socket, and a bit more complicated that I though, it can start with "@" for example)

FTR: If it turns out that calling systemd-notify binary isn't working well enough, we could have an implementation of sd_notify() in our tree, openssh are doing there own here:
https://bugzilla.mindrot.org/show_bug.cgi?id=2641
and there's an example implementation on systemd's documentation:
https://www.freedesktop.org/software/systemd/man/devel/sd_notify.html#Notes
(Nothing for ocaml)

Quoted 2 lines

But let's go with systemd-notify --ready as it is just easier to write a bit of shell script.

I was already thinking of going down the small-library-function route.

Given that I miss-analysed the launch-xenstore, script, I'm not overly enthused with just falling back to waiting on the pidfile, because that's adding technical debt rather than removing it.

~Andrew

#8 lore raw

Re: [PATCH 1/2] tools/{c,o}xenstored: Don't link against libsystemd

In reply to Andrew Cooper
Quoted 7 lines · Andrew Cooper

libsystemd is a giant dependency for one single function, but in the wake of the xz backdoor, it turns out that even systemd leadership recommend against linking against libsystemd for sd_notify().

Since commit 7b61011e1450 ("tools: make xenstore domain easy configurable") in Xen 4.8, the launch-xenstore script invokes systemd-notify directly, so its not even necessary for the xenstored's to call sd_notify() themselves.

You are aware that in the daemon case the call of systemd-notify does not signal readyness of xenstored? It is just called with the "--booted" parameter in order to detect whether systemd is active or not.

So in order to just drop the sd_notify() call from xenstored you need to modify the launch-xenstore script, too.

Juergen

Quoted 218 lines

Therefore, just drop the calls to sd_notify() and stop linking against libsystemd.

No functional change.

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>
CC: Stefano Stabellini <[email protected]>

---
  tools/ocaml/xenstored/Makefile        | 12 +------
  tools/ocaml/xenstored/systemd.ml      | 15 ---------
  tools/ocaml/xenstored/systemd.mli     | 16 ---------
  tools/ocaml/xenstored/systemd_stubs.c | 47 ---------------------------
  tools/ocaml/xenstored/xenstored.ml    |  1 -
  tools/xenstored/Makefile              |  5 ---
  tools/xenstored/posix.c               |  9 -----
  7 files changed, 1 insertion(+), 104 deletions(-)

delete mode 100644 tools/ocaml/xenstored/systemd.ml delete mode 100644 tools/ocaml/xenstored/systemd.mli delete mode 100644 tools/ocaml/xenstored/systemd_stubs.c

tools/ocaml/xenstored/Makefile +1 -11
index e8aaecf2e630..1e4b51cc5432 100644
@@ -4,8 +4,6 @@ include $(OCAML_TOPLEVEL)/common.make
 
  # Include configure output (config.h)
  CFLAGS += -include $(XEN_ROOT)/tools/config.h
-CFLAGS-$(CONFIG_SYSTEMD)  += $(SYSTEMD_CFLAGS)
-LDFLAGS-$(CONFIG_SYSTEMD) += $(SYSTEMD_LIBS)
 
  CFLAGS  += $(CFLAGS-y)
  CFLAGS  += $(APPEND_CFLAGS)
@@ -25,13 +23,6 @@ poll_OBJS = poll
  poll_C_OBJS = select_stubs
  OCAML_LIBRARY = syslog poll
 
-LIBS += systemd.cma systemd.cmxa
-systemd_OBJS = systemd
-systemd_C_OBJS = systemd_stubs
-OCAML_LIBRARY += systemd
-
-LIBS_systemd += $(LDFLAGS-y)
-
  OBJS = paths \
  	define \
  	stdext \
@@ -56,12 +47,11 @@ OBJS = paths \
  	process \
  	xenstored
 
-INTF = symbol.cmi trie.cmi syslog.cmi systemd.cmi poll.cmi
+INTF = symbol.cmi trie.cmi syslog.cmi poll.cmi
 
  XENSTOREDLIBS = \
  	unix.cmxa \
  	-ccopt -L -ccopt . syslog.cmxa \
-	-ccopt -L -ccopt . systemd.cmxa \
  	-ccopt -L -ccopt . poll.cmxa \
  	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/mmap $(OCAML_TOPLEVEL)/libs/mmap/xenmmap.cmxa \
  	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \
tools/ocaml/xenstored/systemd.ml deleted +0 -15
deleted file mode 100644
index 39127f712d72..000000000000
@@ -1,15 +0,0 @@
-(*
- * Copyright (C) 2014 Luis R. Rodriguez <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *)
-
-external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"
tools/ocaml/xenstored/systemd.mli deleted +0 -16
deleted file mode 100644
index 18b9331031f9..000000000000
@@ -1,16 +0,0 @@
-(*
- * Copyright (C) 2014 Luis R. Rodriguez <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *)
-
-(** Tells systemd we're ready *)
-external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"
tools/ocaml/xenstored/systemd_stubs.c deleted +0 -47
deleted file mode 100644
index f4c875075abe..000000000000
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2014 Luis R. Rodriguez <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- */
-
-#include <string.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <caml/mlvalues.h>
-#include <caml/memory.h>
-#include <caml/alloc.h>
-#include <caml/custom.h>
-#include <caml/signals.h>
-#include <caml/fail.h>
-
-#if defined(HAVE_SYSTEMD)
-
-#include <systemd/sd-daemon.h>
-
-CAMLprim value ocaml_sd_notify_ready(value ignore)
-{
-	CAMLparam1(ignore);
-
-	sd_notify(1, "READY=1");
-
-	CAMLreturn(Val_unit);
-}
-
-#else
-
-CAMLprim value ocaml_sd_notify_ready(value ignore)
-{
-	CAMLparam1(ignore);
-
-	CAMLreturn(Val_unit);
-}
-#endif
tools/ocaml/xenstored/xenstored.ml +0 -1
index 1aaa3e995e1f..6bcd6d11da55 100644
@@ -621,7 +621,6 @@ let () =
      process_domains store cons domains
    in
 
-  Systemd.sd_notify_ready ();
    let live_update = ref false in
    while not (!quit && Connections.prevents_quit cons = [])
    do
tools/xenstored/Makefile +0 -5
index e0897ed1ba30..09adfe1d5064 100644
@@ -9,11 +9,6 @@ xenstored: LDLIBS += $(LDLIBS_libxenctrl)
  xenstored: LDLIBS += -lrt
  xenstored: LDLIBS += $(SOCKET_LIBS)
 
-ifeq ($(CONFIG_SYSTEMD),y)
-$(XENSTORED_OBJS-y): CFLAGS += $(SYSTEMD_CFLAGS)
-xenstored: LDLIBS += $(SYSTEMD_LIBS)
-endif
-
  TARGETS := xenstored
 
  .PHONY: all
tools/xenstored/posix.c +0 -9
index d88c82d972d7..dc4ed8db591f 100644
@@ -26,9 +26,6 @@
  #include <sys/mman.h>
  #include <sys/socket.h>
  #include <sys/un.h>
-#if defined(HAVE_SYSTEMD)
-#include <systemd/sd-daemon.h>
-#endif
  #include <xen-tools/xenstore-common.h>
 
  #include "utils.h"
@@ -390,12 +387,6 @@ void handle_special_fds(void)
 
  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
  }
 
  int get_socket_fd(void)
#9 lore raw

PATCH 2/2 tools: Drop libsystemd as a dependency

In reply to Andrew Cooper

There are no more users, and we want to disuade people from introducing new users just for sd_notify() and friends. Drop the dependency.

We still want the overall --with{,out}-systemd to gate the generation of the service/unit/mount/etc files.

Rerun autogen.sh, and mark the dependency as removed in the build containers.

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>
CC: Stefano Stabellini <[email protected]>

---
 automation/build/archlinux/current.dockerfile |   1 +
 .../build/suse/opensuse-leap.dockerfile       |   1 +
 .../build/suse/opensuse-tumbleweed.dockerfile |   1 +
 automation/build/ubuntu/focal.dockerfile      |   1 +
 config/Tools.mk.in                            |   2 -
 m4/systemd.m4                                 |  23 +-
 tools/config.h.in                             |   3 -
 tools/configure                               | 523 +-----------------
 8 files changed, 7 insertions(+), 548 deletions(-)
automation/build/archlinux/current.dockerfile +1 -0
index d974a1434fd5..a350b53ad8e2 100644
@@ -39,6 +39,7 @@ RUN pacman -S --refresh --sysupgrade --noconfirm --noprogressbar --needed \
         sdl2 \
         spice \
         spice-protocol \
+        # systemd for Xen < 4.19
         systemd \
         transfig \
         usbredir \
automation/build/suse/opensuse-leap.dockerfile +1 -0
index e1ec38a41445..0483d9826d7d 100644
@@ -61,6 +61,7 @@ RUN zypper install -y --no-recommends \
         'pkgconfig(sdl2)' \
         python3-devel \
         python3-setuptools \
+        # systemd-devel for Xen < 4.19
         systemd-devel \
         tar \
         transfig \
automation/build/suse/opensuse-tumbleweed.dockerfile +1 -0
index f00e03eda7b1..59b168e717b2 100644
@@ -62,6 +62,7 @@ RUN zypper install -y --no-recommends \
         'pkgconfig(sdl2)' \
         python3-devel \
         python3-setuptools \
+        # systemd-devel for Xen < 4.19
         systemd-devel \
         tar \
         transfig \
automation/build/ubuntu/focal.dockerfile +1 -0
index 30a9b8e84ffe..8171347c4656 100644
@@ -36,6 +36,7 @@ RUN apt-get update && \
         libnl-3-dev \
         ocaml-nox \
         libfindlib-ocaml-dev \
+        # libsystemd-dev for Xen < 4.19
         libsystemd-dev \
         transfig \
         pandoc \
config/Tools.mk.in +0 -2
index b54ab21f966b..50fbef841f3f 100644
@@ -52,8 +52,6 @@ CONFIG_PYGRUB       := @pygrub@
 CONFIG_LIBFSIMAGE   := @libfsimage@
 
 CONFIG_SYSTEMD      := @systemd@
-SYSTEMD_CFLAGS      := @SYSTEMD_CFLAGS@
-SYSTEMD_LIBS        := @SYSTEMD_LIBS@
 XEN_SYSTEMD_DIR     := @SYSTEMD_DIR@
 XEN_SYSTEMD_MODULES_LOAD := @SYSTEMD_MODULES_LOAD@
 CONFIG_9PFS         := @ninepfs@
m4/systemd.m4 +1 -22
index 112dc11b5e05..aa1ebe94f56c 100644
@@ -41,15 +41,6 @@ AC_DEFUN([AX_ALLOW_SYSTEMD_OPTS], [
 ])
 
 AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [
-	PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon],,
-		[PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 209])]
-        )
-	dnl pkg-config older than 0.24 does not set these for
-	dnl PKG_CHECK_MODULES() worth also noting is that as of version 208
-	dnl of systemd pkg-config --cflags currently yields no extra flags yet.
-	AC_SUBST([SYSTEMD_CFLAGS])
-	AC_SUBST([SYSTEMD_LIBS])
-
 	AS_IF([test "x$SYSTEMD_DIR" = x], [
 	    dnl In order to use the line below we need to fix upstream systemd
 	    dnl to properly ${prefix} for child variables in
@@ -83,23 +74,11 @@ AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [
 AC_DEFUN([AX_CHECK_SYSTEMD], [
 	dnl Respect user override to disable
 	AS_IF([test "x$enable_systemd" != "xno"], [
-	     AS_IF([test "x$systemd" = "xy" ], [
-		AC_DEFINE([HAVE_SYSTEMD], [1], [Systemd available and enabled])
-			systemd=y
-			AX_CHECK_SYSTEMD_LIBS()
-	    ],[
-		AS_IF([test "x$enable_systemd" = "xyes"],
-			[AC_MSG_ERROR([Unable to find systemd development library])],
-			[systemd=n])
-	    ])
+	systemd=y
 	],[systemd=n])
 ])
 
 AC_DEFUN([AX_CHECK_SYSTEMD_ENABLE_AVAILABLE], [
-	PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon], [systemd="y"],[
-		PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 209],
-				  [systemd="y"],[systemd="n"])
-	])
 ])
 
 dnl Enables systemd by default and requires a --disable-systemd option flag
tools/config.h.in +0 -3
index 0bb2fe08a143..56ac7800032f 100644
@@ -60,9 +60,6 @@
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
-/* Systemd available and enabled */
-#undef HAVE_SYSTEMD
-
 /* Define to 1 if you have the <sys/eventfd.h> header file. */
 #undef HAVE_SYS_EVENTFD_H
 
tools/configure +2 -521

550 lines not on this page · raw message

Signature · 1 line
2.30.2
#10 lore raw

Re: [PATCH 2/2] tools: Drop libsystemd as a dependency

Quoted 21 lines · Andrew Cooper
m4/systemd.m4 +0 -9
index 112dc11b5e05..aa1ebe94f56c 100644
@@ -41,15 +41,6 @@ AC_DEFUN([AX_ALLOW_SYSTEMD_OPTS], [
 ])
 
 AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [
-	PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon],,
-		[PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 209])]
-        )
-	dnl pkg-config older than 0.24 does not set these for
-	dnl PKG_CHECK_MODULES() worth also noting is that as of version 208
-	dnl of systemd pkg-config --cflags currently yields no extra flags yet.
-	AC_SUBST([SYSTEMD_CFLAGS])
-	AC_SUBST([SYSTEMD_LIBS])
-
 	AS_IF([test "x$SYSTEMD_DIR" = x], [
 	    dnl In order to use the line below we need to fix upstream systemd
 	    dnl to properly ${prefix} for child variables in

m4/systemd.m4 AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [ · line 89

Quoted 7 lines
m4/systemd.m4 +0 -4
@@ -83,23 +74,11 @@ AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [
 AC_DEFUN([AX_CHECK_SYSTEMD], [
 	dnl Respect user override to disable
 	AS_IF([test "x$enable_systemd" != "xno"], [
-	     AS_IF([test "x$systemd" = "xy" ], [
-		AC_DEFINE([HAVE_SYSTEMD], [1], [Systemd available and enabled])
-			systemd=y
-			AX_CHECK_SYSTEMD_LIBS()

I think you need to keep calling AX_CHECK_SYSTEMD_LIBS() here, otherwise, nothing sets $SYSTEMD_DIR or $SYSTEMD_MODULES_LOAD.

Quoted 4 lines
m4/systemd.m4 +0 -4
-	    ],[
-		AS_IF([test "x$enable_systemd" = "xyes"],
-			[AC_MSG_ERROR([Unable to find systemd development library])],
-			[systemd=n])

m4/systemd.m4 AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [ · line 102

Quoted 10 lines
m4/systemd.m4 +1 -5
-	    ])
+	systemd=y
 	],[systemd=n])
 ])
 
 AC_DEFUN([AX_CHECK_SYSTEMD_ENABLE_AVAILABLE], [
-	PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon], [systemd="y"],[
-		PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 209],
-				  [systemd="y"],[systemd="n"])
-	])

Instead, or in addition, you could AX_AVAILABLE_SYSTEMD() in configure.ac by AX_ENABLE_SYSTEMD(). (Or AX_ALLOW_SYSTEMD()).

With the current patch, AX_CHECK_SYSTEMD() will enable systemd "support", even if it supposed to be disabled by default. So it's better to use AX_ENABLE_SYSTEMD() as this will set the correct help message.

And can you add an entry in CHANGELOG? As systemd support isn't automatically enabled with the presence of the libs anymore.

Thanks,

Signature · 1 line
Anthony PERARD
Acked-by on the v1 series
#11 lore raw
In reply to Andrew Cooper
Quoted 9 lines · Andrew Cooper

On advise from the systemd leadership. See patch 1 for details.

Andrew Cooper (2):
tools/{c,o}xenstored: Don't link against libsystemd
tools: Drop libsystemd as a dependency

I agree with the general direction of limiting exposure to systemd libraries. The exact way is currently being debated.

— C