importd: allow activation in early boot, and make it socket activatable

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.
This commit is contained in:
Lennart Poettering 2024-05-08 11:11:43 +02:00
parent 17a6043a14
commit f596658811
4 changed files with 37 additions and 2 deletions

View 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");

View 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'],

View 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

View File

@ -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