Skip to contentSkip to conversation

Drop libsystemd

PATCH In review Andrew Cooper 5 participants 15 messages May 16, 2024 – May 23, 2024 Licenses and spdx stuff

lore
Share & tools
lore
#0 lore raw

v2 cover Drop libsystemd

On advise from the systemd leadership.

v2:
* Import the free-standing example and use that to retain existing functionality.

Andrew Cooper (4):
LICENSES: Add MIT-0 (MIT No Attribution)
tools: Import standalone sd_notify() implementation from systemd tools/{c,o}xenstored: Don't link against libsystemd
tools: Drop libsystemd as a dependency

 LICENSES/MIT-0                                |  31 +++
 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                                 |   9 -
 tools/configure                               | 256 ------------------
 tools/include/xen-sd-notify.h                 |  98 +++++++
 tools/ocaml/xenstored/Makefile                |   2 -
 tools/ocaml/xenstored/systemd_stubs.c         |   2 +-
 tools/xenstored/Makefile                      |   5 -
 tools/xenstored/posix.c                       |   4 +-
 13 files changed, 136 insertions(+), 277 deletions(-)
 create mode 100644 LICENSES/MIT-0
 create mode 100644 tools/include/xen-sd-notify.h

base-commit: 977d98e67c2e929c62aa1f495fc4c6341c45abb5

Signature · 1 line
2.30.2
#1 lore raw

PATCH v2 1/4 LICENSES: Add MIT-0 (MIT No Attribution)

We are about to import code licensed under MIT-0. It's compatible for us to use, so identify it as a permitted license.

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>

v2:
* New

---
 LICENSES/MIT-0 | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 LICENSES/MIT-0
LICENSES/MIT-0 new file +31 -0
new file mode 100644
index 000000000000..70fb90ee3486
@@ -0,0 +1,31 @@
+Valid-License-Identifier: MIT-0
+
+SPDX-URL: https://spdx.org/licenses/MIT-0.html
+
+Usage-Guide:
+
+  To use the MIT-0 License put the following SPDX tag/value pair into a
+  comment according to the placement guidelines in the licensing rules
+  documentation:
+    SPDX-License-Identifier: MIT-0
+
+License-Text:
+
+MIT No Attribution
+
+Copyright <year> <copyright holder>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
Signature · 1 line
2.30.2
Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] LICENSES: Add MIT-0 (MIT No Attribution)

Quoted 4 lines · Andrew Cooper

We are about to import code licensed under MIT-0. It's compatible for us to use, so identify it as a permitted license.

Quoted 57 lines

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>

v2:
* New

---
 LICENSES/MIT-0 | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 LICENSES/MIT-0
LICENSES/MIT-0 new file +31 -0
new file mode 100644
index 000000000000..70fb90ee3486
@@ -0,0 +1,31 @@
+Valid-License-Identifier: MIT-0
+
+SPDX-URL: https://spdx.org/licenses/MIT-0.html
+
+Usage-Guide:
+
+  To use the MIT-0 License put the following SPDX tag/value pair into a
+  comment according to the placement guidelines in the licensing rules
+  documentation:
+    SPDX-License-Identifier: MIT-0
+
+License-Text:
+
+MIT No Attribution
+
+Copyright <year> <copyright holder>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
Signature · 1 line
2.30.2
Acked-by on v2 1/4
#3 lore raw

Re: [PATCH v2 1/4] LICENSES: Add MIT-0 (MIT No Attribution)

In reply to Andrew Cooper
Quoted 8 lines · Andrew Cooper

We are about to import code licensed under MIT-0. It's compatible for us to use, so identify it as a permitted license.

Quoted 9 lines

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>

#4 lore raw

PATCH v2 2/4 tools: Import standalone sd_notify() implementation from systemd

In reply to Andrew Cooper

... in order to avoid linking against the whole of libsystemd.

Only minimal changes to the upstream copy, to function as a drop-in replacement for sd_notify() and as a header-only library.

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>

v2:
* New

---
 tools/include/xen-sd-notify.h | 98 +++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 tools/include/xen-sd-notify.h
tools/include/xen-sd-notify.h new file +98 -0
new file mode 100644
index 000000000000..eda9d8b22d9e
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: MIT-0 */
+
+/*
+ * Implement the systemd notify protocol without external dependencies.
+ * Supports both readiness notification on startup and on reloading,
+ * according to the protocol defined at:
+ * https://www.freedesktop.org/software/systemd/man/latest/sd_notify.html
+ * This protocol is guaranteed to be stable as per:
+ * https://systemd.io/PORTABILITY_AND_STABILITY/
+ *
+ * Differences from the upstream copy:
+ * - Rename/rework as a drop-in replacement for systemd/sd-daemon.h
+ * - Only take the subset Xen cares about
+ * - Respect -Wdeclaration-after-statement
+ */
+
+#ifndef XEN_SD_NOTIFY
+#define XEN_SD_NOTIFY
+
+#include <errno.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+static inline void xen_sd_closep(int *fd) {
+  if (!fd || *fd < 0)
+    return;
+
+  close(*fd);
+  *fd = -1;
+}
+
+static inline int xen_sd_notify(const char *message) {
+  union sockaddr_union {
+    struct sockaddr sa;
+    struct sockaddr_un sun;
+  } socket_addr = {
+    .sun.sun_family = AF_UNIX,
+  };
+  size_t path_length, message_length;
+  ssize_t written;
+  const char *socket_path;
+  int __attribute__((cleanup(sd_closep))) fd = -1;
+
+  /* Verify the argument first */
+  if (!message)
+    return -EINVAL;
+
+  message_length = strlen(message);
+  if (message_length == 0)
+    return -EINVAL;
+
+  /* If the variable is not set, the protocol is a noop */
+  socket_path = getenv("NOTIFY_SOCKET");
+  if (!socket_path)
+    return 0; /* Not set? Nothing to do */
+
+  /* Only AF_UNIX is supported, with path or abstract sockets */
+  if (socket_path[0] != '/' && socket_path[0] != '@')
+    return -EAFNOSUPPORT;
+
+  path_length = strlen(socket_path);
+  /* Ensure there is room for NUL byte */
+  if (path_length >= sizeof(socket_addr.sun.sun_path))
+    return -E2BIG;
+
+  memcpy(socket_addr.sun.sun_path, socket_path, path_length);
+
+  /* Support for abstract socket */
+  if (socket_addr.sun.sun_path[0] == '@')
+    socket_addr.sun.sun_path[0] = 0;
+
+  fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
+  if (fd < 0)
+    return -errno;
+
+  if (connect(fd, &socket_addr.sa, offsetof(struct sockaddr_un, sun_path) + path_length) != 0)
+    return -errno;
+
+  written = write(fd, message, message_length);
+  if (written != (ssize_t) message_length)
+    return written < 0 ? -errno : -EPROTO;
+
+  return 1; /* Notified! */
+}
+
+static inline int sd_notify(int unset_environment, const char *message) {
+    int r = xen_sd_notify(message);
+
+    if (unset_environment)
+        unsetenv("NOTIFY_SOCKET");
+
+    return r;
+}
+
+#endif /* XEN_SD_NOTIFY */
Signature · 1 line
2.30.2
#5 lore raw

Re: [PATCH v2 2/4] tools: Import standalone sd_notify() implementation from systemd

Quoted 4 lines · Andrew Cooper

... in order to avoid linking against the whole of libsystemd.

Only minimal changes to the upstream copy, to function as a drop-in replacement for sd_notify() and as a header-only library.

Maybe add explicit link to the original source?

Quoted 24 lines

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>

v2:
* New

---
 tools/include/xen-sd-notify.h | 98 +++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 tools/include/xen-sd-notify.h
tools/include/xen-sd-notify.h new file +0 -0
new file mode 100644
index 000000000000..eda9d8b22d9e
@@ -0,0 +1,98 @@

...

Quoted 1 line

+static inline void xen_sd_closep(int *fd) {

Static inline is one of the changes vs upstream, and gitlab-ci is not happy about it:

/builds/xen-project/patchew/xen/tools/xenstored/../../tools/include/xen-sd-notify.h:45:3: error: cleanup argument not a function

   45 |   int __attribute__((cleanup(sd_closep))) fd = -1;
      |   ^~~
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#6 lore raw

Re: [PATCH v2 2/4] tools: Import standalone sd_notify() implementation from systemd

Quoted 6 lines · Marek Marczykowski-Górecki
Quoted 4 lines · Andrew Cooper

... in order to avoid linking against the whole of libsystemd.

Only minimal changes to the upstream copy, to function as a drop-in replacement for sd_notify() and as a header-only library.

Maybe add explicit link to the original source?

Well, it is in the top of the file...

Quoted 14 lines
(quoted diff) +0 -0

b/tools/include/xen-sd-notify.h new file mode 100644 index 000000000000..eda9d8b22d9e --- /dev/null +++ b/tools/include/xen-sd-notify.h @@ -0,0 +1,98 @@ +/*
SPDX-License-Identifier: MIT-0 */ + +/* + * Implement the systemd notify protocol without external dependencies. + * Supports both readiness notification on startup and on reloading, + * according to the protocol defined at: + *
https://www.freedesktop.org/software/systemd/man/latest/sd_notify.html+
* This protocol is guaranteed to be stable as per: + *
https://systemd.io/PORTABILITY_AND_STABILITY/+ *

Quoted 8 lines
Quoted 1 line

+static inline void xen_sd_closep(int *fd) {

Static inline is one of the changes vs upstream, and gitlab-ci is not happy about it:

/builds/xen-project/patchew/xen/tools/xenstored/../../tools/include/xen-sd-notify.h:45:3: error: cleanup argument not a function

   45 |   int __attribute__((cleanup(sd_closep))) fd = -1;
      |   ^~~

Yes - victim of a last minute refactor.  I've fixed it up locally.

~Andrew

Reviewed-by on v2 2/4
#7 lore raw

Re: [PATCH v2 2/4] tools: Import standalone sd_notify() implementation from systemd

In reply to Andrew Cooper
Quoted 6 lines · Andrew Cooper

... in order to avoid linking against the whole of libsystemd.

Only minimal changes to the upstream copy, to function as a drop-in replacement for sd_notify() and as a header-only library.

With s/cleanup(sd_closep)/cleanup(xen_sd_closep)/

Juergen

Quoted 121 lines

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>

v2:
* New

---
  tools/include/xen-sd-notify.h | 98 +++++++++++++++++++++++++++++++++++
  1 file changed, 98 insertions(+)

create mode 100644 tools/include/xen-sd-notify.h

tools/include/xen-sd-notify.h new file +98 -0
new file mode 100644
index 000000000000..eda9d8b22d9e
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: MIT-0 */
+
+/*
+ * Implement the systemd notify protocol without external dependencies.
+ * Supports both readiness notification on startup and on reloading,
+ * according to the protocol defined at:
+ * https://www.freedesktop.org/software/systemd/man/latest/sd_notify.html
+ * This protocol is guaranteed to be stable as per:
+ * https://systemd.io/PORTABILITY_AND_STABILITY/
+ *
+ * Differences from the upstream copy:
+ * - Rename/rework as a drop-in replacement for systemd/sd-daemon.h
+ * - Only take the subset Xen cares about
+ * - Respect -Wdeclaration-after-statement
+ */
+
+#ifndef XEN_SD_NOTIFY
+#define XEN_SD_NOTIFY
+
+#include <errno.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+static inline void xen_sd_closep(int *fd) {
+  if (!fd || *fd < 0)
+    return;
+
+  close(*fd);
+  *fd = -1;
+}
+
+static inline int xen_sd_notify(const char *message) {
+  union sockaddr_union {
+    struct sockaddr sa;
+    struct sockaddr_un sun;
+  } socket_addr = {
+    .sun.sun_family = AF_UNIX,
+  };
+  size_t path_length, message_length;
+  ssize_t written;
+  const char *socket_path;
+  int __attribute__((cleanup(sd_closep))) fd = -1;
+
+  /* Verify the argument first */
+  if (!message)
+    return -EINVAL;
+
+  message_length = strlen(message);
+  if (message_length == 0)
+    return -EINVAL;
+
+  /* If the variable is not set, the protocol is a noop */
+  socket_path = getenv("NOTIFY_SOCKET");
+  if (!socket_path)
+    return 0; /* Not set? Nothing to do */
+
+  /* Only AF_UNIX is supported, with path or abstract sockets */
+  if (socket_path[0] != '/' && socket_path[0] != '@')
+    return -EAFNOSUPPORT;
+
+  path_length = strlen(socket_path);
+  /* Ensure there is room for NUL byte */
+  if (path_length >= sizeof(socket_addr.sun.sun_path))
+    return -E2BIG;
+
+  memcpy(socket_addr.sun.sun_path, socket_path, path_length);
+
+  /* Support for abstract socket */
+  if (socket_addr.sun.sun_path[0] == '@')
+    socket_addr.sun.sun_path[0] = 0;
+
+  fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
+  if (fd < 0)
+    return -errno;
+
+  if (connect(fd, &socket_addr.sa, offsetof(struct sockaddr_un, sun_path) + path_length) != 0)
+    return -errno;
+
+  written = write(fd, message, message_length);
+  if (written != (ssize_t) message_length)
+    return written < 0 ? -errno : -EPROTO;
+
+  return 1; /* Notified! */
+}
+
+static inline int sd_notify(int unset_environment, const char *message) {
+    int r = xen_sd_notify(message);
+
+    if (unset_environment)
+        unsetenv("NOTIFY_SOCKET");
+
+    return r;
+}
+
+#endif /* XEN_SD_NOTIFY */
#8 lore raw

PATCH v2 3/4 tools/{c,o}xenstored: Don't link against libsystemd

In reply to Andrew Cooper

Use the local freestanding wrapper instead.

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>

v2:
* Redo almost from scratch, using the freestanding wrapper instead.

---
 tools/ocaml/xenstored/Makefile        | 2 --
 tools/ocaml/xenstored/systemd_stubs.c | 2 +-
 tools/xenstored/Makefile              | 5 -----
 tools/xenstored/posix.c               | 4 ++--
 4 files changed, 3 insertions(+), 10 deletions(-)
tools/ocaml/xenstored/Makefile +0 -2
index e8aaecf2e630..a8b8bb64698e 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)
tools/ocaml/xenstored/systemd_stubs.c +1 -1
index f4c875075abe..7dbbdd35bf30 100644
@@ -25,7 +25,7 @@
 
 #if defined(HAVE_SYSTEMD)
 
-#include <systemd/sd-daemon.h>
+#include <xen-sd-notify.h>
 
 CAMLprim value ocaml_sd_notify_ready(value ignore)
 {
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 +2 -2
index d88c82d972d7..6037d739d013 100644
@@ -27,7 +27,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #if defined(HAVE_SYSTEMD)
-#include <systemd/sd-daemon.h>
+#include <xen-sd-notify.h>
 #endif
 #include <xen-tools/xenstore-common.h>
 
@@ -393,7 +393,7 @@ 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");
+		fprintf(stderr, "xenstored is ready\n");
 	}
 #endif
 }
Signature · 1 line
2.30.2
Reviewed-by on v2 3/4
#9 lore raw

Re: [PATCH v2 3/4] tools/{c,o}xenstored: Don't link against libsystemd

Quoted 3 lines · Andrew Cooper

Use the local freestanding wrapper instead.

Juergen

Quoted 83 lines

---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>

v2:
* Redo almost from scratch, using the freestanding wrapper instead.

---
  tools/ocaml/xenstored/Makefile        | 2 --
  tools/ocaml/xenstored/systemd_stubs.c | 2 +-
  tools/xenstored/Makefile              | 5 -----
  tools/xenstored/posix.c               | 4 ++--
  4 files changed, 3 insertions(+), 10 deletions(-)
tools/ocaml/xenstored/Makefile +0 -2
index e8aaecf2e630..a8b8bb64698e 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)
tools/ocaml/xenstored/systemd_stubs.c +1 -1
index f4c875075abe..7dbbdd35bf30 100644
@@ -25,7 +25,7 @@
 
  #if defined(HAVE_SYSTEMD)
 
-#include <systemd/sd-daemon.h>
+#include <xen-sd-notify.h>
 
  CAMLprim value ocaml_sd_notify_ready(value ignore)
  {
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 +2 -2
index d88c82d972d7..6037d739d013 100644
@@ -27,7 +27,7 @@
  #include <sys/socket.h>
  #include <sys/un.h>
  #if defined(HAVE_SYSTEMD)
-#include <systemd/sd-daemon.h>
+#include <xen-sd-notify.h>
  #endif
  #include <xen-tools/xenstore-common.h>
 
@@ -393,7 +393,7 @@ 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");
+		fprintf(stderr, "xenstored is ready\n");
  	}
  #endif
  }
#10 lore raw

PATCH v2 4/4 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: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>

v2:
* Only strip out the library check.

---
 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                                 |   9 -
 tools/configure                               | 256 ------------------
 7 files changed, 4 insertions(+), 267 deletions(-)
automation/build/archlinux/current.dockerfile +1 -0
index 3e37ab5c40c1..d29f1358c2bd 100644
@@ -37,6 +37,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 48d0d50d005d..3ef33458a07c 100644
@@ -59,6 +59,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 53542ba1f4d9..a793601c876d 100644
@@ -60,6 +60,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 7c6a4d07566b..078abd56d56f 100644
@@ -34,6 +34,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 +0 -9
index 112dc11b5e05..e4fe51a8ba5f 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
tools/configure +0 -256

262 lines not on this page · raw message

Signature · 1 line
2.30.2
#11 lore raw

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

Quoted 36 lines · 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: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Christian Lindig <[email protected]>
CC: Edwin Török <[email protected]>

v2:
* Only strip out the library check.

---
  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                                 |   9 -
  tools/configure                               | 256 ------------------
  7 files changed, 4 insertions(+), 267 deletions(-)
automation/build/archlinux/current.dockerfile +0 -0
index 3e37ab5c40c1..d29f1358c2bd 100644

automation/build/archlinux/current.dockerfile RUN pacman -S --refresh --sysupgrade --noconfirm --noprogressbar --needed \ · line 40

Quoted 4 lines
automation/build/archlinux/current.dockerfile +1 -0
@@ -37,6 +37,7 @@ RUN pacman -S --refresh --sysupgrade --noconfirm --noprogressbar --needed \
          sdl2 \
          spice \
          spice-protocol \
+        # systemd for Xen < 4.19

Does this work as intended? A comment between the parameters and no "\" at the end of the line?

Juergen

#12 lore raw

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

Quoted 16 lines · Jürgen Groß

automation/build/archlinux/current.dockerfile RUN pacman -S --refresh --sysupgrade --noconfirm · line 40

Quoted 11 lines · Andrew Cooper
automation/build/archlinux/current.dockerfile +1 -1
index 3e37ab5c40c1..d29f1358c2bd 100644
@@ -37,6 +37,7 @@ RUN pacman -S --refresh --sysupgrade --noconfirm
--noprogressbar --needed \
           sdl2 \
           spice \
           spice-protocol \
+        # systemd for Xen < 4.19

Does this work as intended? A comment between the parameters and no "\" at the
end of the line?

Sadly, yes.

Comments are stripped out on a line-granuar basis, prior to Docker interpreting the remainder.

This is the approved way to do comments in dockerfiles, and we already have other examples of this in our dockerfiles.

See e.g. a0e29b316363d9 for what I'll be doing with these comments in ~3y time.

~Andrew

Reviewed-by on v2 4/4
#13 lore raw

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

In reply to Andrew Cooper
Quoted 9 lines · 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.

Juergen

Acked-by on the v2 series
#14 lore raw
In reply to Andrew Cooper
Quoted 30 lines · Andrew Cooper

On advise from the systemd leadership.

v2:
* Import the free-standing example and use that to retain existing functionality.

Andrew Cooper (4):
LICENSES: Add MIT-0 (MIT No Attribution)
tools: Import standalone sd_notify() implementation from systemd tools/{c,o}xenstored: Don't link against libsystemd
tools: Drop libsystemd as a dependency

LICENSES/MIT-0                                |  31 +++
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                                 |   9 -
tools/configure                               | 256 ------------------
tools/include/xen-sd-notify.h                 |  98 +++++++
tools/ocaml/xenstored/Makefile                |   2 -
tools/ocaml/xenstored/systemd_stubs.c         |   2 +-
tools/xenstored/Makefile                      |   5 -
tools/xenstored/posix.c                       |   4 +-
13 files changed, 136 insertions(+), 277 deletions(-)
Quoted 8 lines

create mode 100644 LICENSES/MIT-0
create mode 100644 tools/include/xen-sd-notify.h

base-commit: 977d98e67c2e929c62aa1f495fc4c6341c45abb5

Signature · 1 line
2.30.2