importd: allow activation in early boot, and make it socket activatable
authorLennart Poettering <lennart@poettering.net>
Wed, 8 May 2024 09:11:43 +0000 (11:11 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 25 Jun 2024 07:57:42 +0000 (09:57 +0200)
Previously, importd was only accessible via D-Bus, which required it to
be a late boot service. Now that we have Varlink we can rearrange things
to become early-boot activated, just after the image directories are
mounted.

This will later allow us to have generator that auto-downloads images on
boot.

src/import/importd.c
units/meson.build
units/systemd-importd.service.in
units/systemd-importd.socket [new file with mode: 0644]

index 5ef89ac88446329088737ac22b6a9ebcf0a4df90..112180c846577ad1e4b8ca285c696a76c011b389 100644 (file)
@@ -1743,7 +1743,7 @@ static int manager_connect_bus(Manager *m) {
         assert(m->event);
         assert(!m->bus);
 
-        r = sd_bus_default_system(&m->bus);
+        r = bus_open_system_watch_bind(&m->bus);
         if (r < 0)
                 return log_error_errno(r, "Failed to get system bus connection: %m");
 
index b231341a1fb1af00416c176c1563671a11bd6ac5..bdc34e6f2c826979e1b2c707155eb9754f3fb11b 100644 (file)
@@ -361,6 +361,11 @@ units = [
           'conditions' : ['ENABLE_IMPORTD'],
           'symlinks' : ['dbus-org.freedesktop.import1.service'],
         },
+        {
+          'file' : 'systemd-importd.socket',
+          'conditions' : ['ENABLE_IMPORTD'],
+          'symlinks' : ['sockets.target.wants/'],
+        },
         {
           'file' : 'systemd-initctl.service.in',
           'conditions' : ['HAVE_SYSV_COMPAT'],
index daa93776e178c3ea7910ad4c0c3ebf2cb8e0ac41..e119d4092924e31e0d6e5c9270a3252995d68ee5 100644 (file)
@@ -8,9 +8,15 @@
 #  (at your option) any later version.
 
 [Unit]
-Description=Virtual Machine and Container Download Service
+Description=Disk Image Download Service
 Documentation=man:systemd-importd.service(8)
 Documentation=man:org.freedesktop.import1(5)
+DefaultDependencies=no
+After=systemd-importd.socket
+WantsMountsFor=/var/lib/machines /var/lib/portables /var/lib/extensions /var/lib/confexts
+After=systemd-remount-fs.service
+Before=shutdown.target
+Conflicts=shutdown.target
 
 [Service]
 Type=notify
diff --git a/units/systemd-importd.socket b/units/systemd-importd.socket
new file mode 100644 (file)
index 0000000..d1c9c22
--- /dev/null
@@ -0,0 +1,24 @@
+#  SPDX-License-Identifier: LGPL-2.1-or-later
+#
+#  This file is part of systemd.
+#
+#  systemd 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; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Disk Image Download Service Socket
+Documentation=man:systemd-importd.service(8)
+Documentation=man:org.freedesktop.import1(5)
+DefaultDependencies=no
+WantsMountsFor=/var/lib/machines /var/lib/portables /var/lib/extensions /var/lib/confexts
+After=systemd-remount-fs.service
+Before=sockets.target
+Conflicts=shutdown.target
+Before=shutdown.target
+
+[Socket]
+ListenStream=/run/systemd/io.systemd.Import
+FileDescriptorName=varlink
+SocketMode=0666