]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 months agofirstboot: use parse_boolean_argument in one more place 41651/head
Zbigniew Jędrzejewski-Szmek [Thu, 16 Apr 2026 07:20:31 +0000 (09:20 +0200)] 
firstboot: use parse_boolean_argument in one more place

This was pointed out in review.

2 months agofirstboot: use free_and_strdup_warn in parse_argv
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 14:31:15 +0000 (16:31 +0200)] 
firstboot: use free_and_strdup_warn in parse_argv

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agofirstboot: convert to the new option parser
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 14:27:35 +0000 (16:27 +0200)] 
firstboot: convert to the new option parser

The descriptions for boolean options are adjusted to work better
with BOOL as the metavar.

Description of --copy is fixed, fixup for
f649325ba73a7165a14c1f1134b30b12a96d3718.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agofirstboot: reorder option cases to match --help output
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 14:53:56 +0000 (16:53 +0200)] 
firstboot: reorder option cases to match --help output

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agocreds: convert to the new option and verb parsers
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 13:37:24 +0000 (15:37 +0200)] 
creds: convert to the new option and verb parsers

Metavars in --help are adjusted to make the left column less
wide. --no-ask-password and --quiet are now shown in help.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agocreds: reorder option cases to match --help output
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 14:50:55 +0000 (16:50 +0200)] 
creds: reorder option cases to match --help output

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agocgtop: convert to the new option parser
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 13:08:25 +0000 (15:08 +0200)] 
cgtop: convert to the new option parser

A few --help strings are changed to the common option variants.
The optional args for --unit, --user-unit, --xattr, --cgroup-id
are shown in synopsis.

A define is defined for the default of --depth to make things
clearer.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agocgtop: reorder option cases to match --help output
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 14:46:38 +0000 (16:46 +0200)] 
cgtop: reorder option cases to match --help output

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agocgls: fix/update/restore the handling of --xattr and --cgroup-id
Zbigniew Jędrzejewski-Szmek [Thu, 16 Apr 2026 08:07:32 +0000 (10:07 +0200)] 
cgls: fix/update/restore the handling of --xattr and --cgroup-id

This is a bit tricky. Previously, the --help string said
"-x --xattr=BOOL", which normally means that '-x BOOL' and '--xattr BOOL'
and '--xattr=BOOL' are all accepted and equivalent. But actually only
the third form was accepted. '-x' should have been and is now documented
as "Same as --xattr=true". The man page tried to explain this, but not
very strongly. So update the man page to have more emphasis and restore
the special behaviour for -x and -c. This is a on old program, so I
think in this case, maintaining compatiblity in behaviour is important.

2 months agocgls: convert to the new option parser
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 13:06:55 +0000 (15:06 +0200)] 
cgls: convert to the new option parser

arg_names is changed to be a normal strv. In the new parser code,
the argument is returned as a const char*. Dropping the const
to stuff it into the array would be too ugly.

The metavars for optional args are now shown in --help.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agopo: Update Serbian and add Serbian Latin translation (#41597)
kostich [Thu, 16 Apr 2026 12:38:09 +0000 (14:38 +0200)] 
po: Update Serbian and add Serbian Latin translation (#41597)

Updates the existing Serbian (`sr`) translation and adds a new Serbian
Latin (`sr@latin`) translation, with both locales registered in
`po/LINGUAS`.

2 months agomachined: gate metadata querying behind inspect-machines/images action
Luca Boccassi [Tue, 14 Apr 2026 19:22:39 +0000 (20:22 +0100)] 
machined: gate metadata querying behind inspect-machines/images action

Ensure only privileged users can call the system scope machined's
APIs that get data out of a machine

Follow-up for 1bd979dddbb6ed3ffe410d78a7ff80cbb1c42a64
Follow-up for 9153b02bb5030e29d6008992fb74b9028d7c392c

2 months agoshared/options: add equivalent of "-" in getopt_long
Zbigniew Jędrzejewski-Szmek [Wed, 15 Apr 2026 20:52:06 +0000 (22:52 +0200)] 
shared/options: add equivalent of "-" in getopt_long

The parsing "mode" is specified as an exclusive mode, i.e. a combination
of "+" and "-" is not supported. In principle this could be supported,
but we don't use that in our code and are unlikely ever to do so.

2 months agocore: implement MountContext/Runtime for io.systemd.Unit.List + tests 39391/head
Ivan Kruglov [Fri, 17 Oct 2025 14:59:23 +0000 (07:59 -0700)] 
core: implement MountContext/Runtime for io.systemd.Unit.List + tests

2 months agocore: implement AutomountContext/Runtime for io.systemd.Unit.List + tests
Ivan Kruglov [Fri, 17 Oct 2025 12:13:14 +0000 (05:13 -0700)] 
core: implement AutomountContext/Runtime for io.systemd.Unit.List + tests

2 months agosysupdated: don't crash when an mstack machine image is found
Kai Lüke [Thu, 16 Apr 2026 06:24:27 +0000 (15:24 +0900)] 
sysupdated: don't crash when an mstack machine image is found

As soon as machinectl list-images has an mstack entry updatectl fails
because systemd-sysupdated crashes with an assertion failing because
the mstack case was not handled.
For now mstack is not supported as image for sysupdate to operate on
and we can skip it.

Fixes https://github.com/systemd/systemd/issues/41649

2 months agoshared/options: convert mode boolean to an enum
Zbigniew Jędrzejewski-Szmek [Thu, 16 Apr 2026 07:05:01 +0000 (09:05 +0200)] 
shared/options: convert mode boolean to an enum

This will make it easier to add new modes of operation later.
But I'm happy with how this came out — I think the mode setting
is nicer to read then the old bool.

2 months agocore: implement KillContext for io.systemd.Unit.List + tests
Ivan Kruglov [Fri, 17 Oct 2025 10:27:29 +0000 (03:27 -0700)] 
core: implement KillContext for io.systemd.Unit.List + tests

2 months agoshared: exec_command_build_json()
Ivan Kruglov [Fri, 17 Oct 2025 13:43:36 +0000 (06:43 -0700)] 
shared: exec_command_build_json()

2 months agoshared: move src/import/curl-util.h to src/shared/
Zbigniew Jędrzejewski-Szmek [Tue, 31 Mar 2026 10:40:47 +0000 (12:40 +0200)] 
shared: move src/import/curl-util.h to src/shared/

Move more common definitions in the header file instead of repeating
them in bunch of places. src/import/curl-util.[ch] is renamed so that
it's shared more naturally with other components.

2 months agotest-network: verify DHCP server PoolSize and PoolOffset DBus properties 41137/head
Jonathan Davies [Sun, 15 Mar 2026 22:48:24 +0000 (22:48 +0000)] 
test-network: verify DHCP server PoolSize and PoolOffset DBus properties

Add integration test coverage for the PoolSize and PoolOffset properties
exposed on the org.freedesktop.network1.DHCPServer DBus interface.

2 months agonetworkd: add DHCPServer PoolSize and PoolOffset DBus properties
Jonathan Davies [Sun, 15 Mar 2026 22:22:37 +0000 (22:22 +0000)] 
networkd: add DHCPServer PoolSize and PoolOffset DBus properties

Closes https://github.com/systemd/systemd/issues/30011

2 months agosd-varlink: Don't log successful sentinel error dispatch as a failure
Daan De Meyer [Wed, 15 Apr 2026 08:02:07 +0000 (08:02 +0000)] 
sd-varlink: Don't log successful sentinel error dispatch as a failure

sd_varlink_error() deliberately returns a negative errno mapped from
the error id on success so callbacks can `return sd_varlink_error(...);`
to enqueue the reply and propagate a matching errno at once. When
varlink_dispatch_method() dispatches a configured error sentinel itself,
it doesn't need that mapping — but it was treating any negative return
as a dispatch failure and logging "Failed to process sentinel" even
though the error reply had been successfully enqueued.

Detect success via the state transition to VARLINK_PROCESSED_METHOD
instead, so only genuine enqueue failures are logged.

2 months agosystemd-vmspawn: QMP-varlink bridge for VM runtime control (#41449)
Christian Brauner [Wed, 15 Apr 2026 10:33:35 +0000 (12:33 +0200)] 
systemd-vmspawn: QMP-varlink bridge for VM runtime control (#41449)

systemd-vmspawn currently has zero runtime control over the VMs it
launches. It can kill QEMU (SIGTERM) or SSH in, but it cannot pause,
resume, request a graceful power-off, query status, or
react to VM events. QEMU exposes all of this via its QMP protocol;
systemd's native IPC is varlink. This series bridges the two.

  Architecture

```
  machinectl → machined (Machine.List → discovers controlAddress)
  machinectl → vmspawn varlink socket (direct connection)
                 ├── io.systemd.MachineInstance       (generic VM control)
                 ├── io.systemd.VirtualMachineInstance (placeholder)
                 └── io.systemd.QemuMachineInstance   (QEMU-specific; AcquireQMP stub)
  vmspawn internally → socketpair → QEMU QMP
```

machined stores the controlAddress but never connects to vmspawn.
machinectl discovers the address from Machine.List and connects
directly. Socket mode 0600 is the access-control boundary —
the socket is rooted in vmspawn's $RUNTIME_DIRECTORY, so only the UID
that launched the VM can talk to it.

  QMP client library (src/shared/qmp-client.{c,h})

  A small non-blocking QMP client modeled on sd-varlink's pump contract:

- Reference-counted QmpClient with an explicit five-state machine:
HANDSHAKE_INITIAL → HANDSHAKE_GREETING_RECEIVED →
HANDSHAKE_CAPABILITIES_SENT → RUNNING → DISCONNECTED.
- qmp_client_connect_fd() is non-blocking: it wraps the fd in a
JsonStream and returns immediately. The greeting + qmp_capabilities
handshake is driven lazily on the first
qmp_client_invoke() or by the event loop — whichever comes first — so
callers never block during connect.
- qmp_client_attach_event() attaches to sd_event for async operation;
qmp_client_process() performs one pump step (write → dispatch → parse →
read → disconnect) with the same contract as
sd_varlink_process(); qmp_client_wait() blocks until the next I/O event.
- qmp_client_invoke() sends an async command and fires the registered
qmp_command_callback_t with (result, error_desc, error, userdata) on
completion. Synchronous callers drive
  process()/wait() in a loop until qmp_client_is_idle() is true.
- QmpClientArgs bundles the JSON arguments and an FD list for a single
command; the QMP_CLIENT_ARGS_FD() macro hands one fd to the callee for
SCM_RIGHTS passing. On partial-stage failure the
args list is narrowed so the caller's cleanup closes only the
untransferred tail.
- Event broadcast to a registered callback via qmp_client_bind_event();
transport loss surfaces through qmp_client_bind_disconnect().
- qmp_schema_has_member() walks the query-qmp-schema result for optional
runtime capability probes.

  vmspawn device setup via QMP

vmspawn starts QEMU paused (-S), sets up devices via QMP, then resumes
with cont. The entire device plane moves off the legacy INI config path
and onto the bridge.

A new MachineConfig aggregate in vmspawn-qmp.h groups the per-device
info (DriveInfos, NetworkInfo, VirtiofsInfos, VsockInfo) with a single
machine_config_done() cleanup that chains the
sub-structure destructors; each conversion patch populates exactly the
field it owns.

  What the conversion enables:

- FD-based device passing via add-fd / getfd + SCM_RIGHTS — vmspawn
opens every image file, TAP, VSOCK, and virtiofs socket itself and hands
the fd to QEMU. QEMU never needs filesystem
  access.
- Ephemeral overlays via blockdev-create + async job-concluded
continuations on anonymous O_TMPFILE / memfd backings — no named overlay
files on disk.
- PCIe root-port pre-allocation for q35/virt machine types so
hotplug-capable slots exist at boot (NVMe, virtio-scsi, etc.).
- io_uring availability probing with automatic fallback to the default
AIO backend if QEMU's build doesn't support it.

Per-command callbacks call sd_event_exit() on setup failure so vmspawn
shuts down cleanly if any device can't be attached.

  machinectl integration

- machinectl pause / resume / poweroff / reboot / terminate go through
the varlink control socket for VMs.
- D-Bus fallback for containers: poweroff sends SIGRTMIN+4, terminate
calls the existing TerminateMachine method — unchanged container
behavior.
- Multi-machine parallel dispatch via sd_event for bulk operations
(machinectl pause vm1 vm2 ...) so one slow VM doesn't serialize the
rest.
- SubscribeEvents streaming with per-subscriber event-name filters
(importd Pull-style pattern: initial {ready:true} notify, fan out via
varlink_many_notifybo(), lazy init — QMP event pump
  runs only while subscribers exist).

  Tests

- Unit test with a mock QMP server covering handshake, command/response,
events, and EOF.
- Integration test against real QEMU (-machine none) exercising
handshake + query-qmp-schema (~200 KB reply, validates the buffered
reader across multiple read()s) and query-status.
- Integration test for the machinectl verbs end-to-end: pause / resume /
describe / subscribe / terminate.
- Integration test for the multi-drive pipeline and ephemeral overlays
(blockdev-create async job continuations).
- Stress test: 5 cycles of start → 3× (pause/describe/resume/describe) →
terminate.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agoTODO: add some vmspawn todos 41449/head
Christian Brauner [Thu, 2 Apr 2026 11:58:55 +0000 (13:58 +0200)] 
TODO: add some vmspawn todos

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: add integration test for multi-drive and ephemeral QMP setup
Christian Brauner [Tue, 7 Apr 2026 19:40:40 +0000 (21:40 +0200)] 
vmspawn: add integration test for multi-drive and ephemeral QMP setup

Test the async QMP drive pipeline with real QEMU:

Test 1 (multi-drive): launches vmspawn with --image plus two
--extra-drive flags. This exercises multiple fdset allocations,
pipelined blockdev-add commands relying on FIFO ordering, io_uring
retry callbacks, and multiple device_add commands — all fired
without waiting for responses.

Test 2 (ephemeral): launches vmspawn with --image --ephemeral. This
exercises the most complex async path: blockdev-create fires a
background job, JOB_STATUS_CHANGE events are watched via the event
callback, and when the job concludes the deferred continuation fires
the overlay format node + device_add. If the continuation fails, the
root drive is never attached, the kernel panics, and vmspawn exits
without registering — so successful registration proves the pipeline
works.

Both tests use a raw ext4 image with a minimal init (sleep infinity)
and direct kernel boot. No virtiofsd needed.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: add integration test for machinectl VM control verbs
Christian Brauner [Mon, 30 Mar 2026 13:15:17 +0000 (15:15 +0200)] 
vmspawn: add integration test for machinectl VM control verbs

Add TEST-87-AUX-UTILS-VM.vmspawn.sh that validates the QMP-varlink
bridge end-to-end using a real QEMU instance:

- Launches vmspawn with --directory and --linux for direct kernel boot
  (no UEFI firmware or bootable image needed)
- Waits for machine registration with machined
- Verifies varlinkAddress is exposed in Machine.List
- Tests machinectl pause, resume, poweroff
- Exercises MachineInstance varlink interface directly via varlinkctl:
  QueryStatus state verification across pause/resume, Pause, Resume

Skipped automatically if vmspawn, QEMU, or a bootable kernel is not
available. Runs as part of TEST-87-AUX-UTILS-VM in the mkosi
integration test suite.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: add integration test for QMP client library against real QEMU
Christian Brauner [Mon, 30 Mar 2026 13:04:42 +0000 (15:04 +0200)] 
vmspawn: add integration test for QMP client library against real QEMU

Add a test that launches QEMU with -machine none (no bootable image
needed) and exercises the QMP client library against the real QMP
implementation:

- test_qmp_client_qemu_handshake_and_schema: sends query-qmp-schema
  (~200KB response that exercises the buffered multi-read() path)
  via qmp_client_invoke(), then cleanly shuts down QEMU via quit.
  The QMP handshake completes transparently inside invoke().

- test_qmp_client_qemu_query_status: validates query-status response
  parsing, stop/cont command sequencing with id correlation, and state
  verification between commands

The test is automatically skipped when QEMU is not installed.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: add integration test for QMP client library
Christian Brauner [Mon, 30 Mar 2026 20:17:59 +0000 (22:17 +0200)] 
vmspawn: add integration test for QMP client library

Test the QMP client library using a mock QMP server over a socketpair:

- test_qmp_client_basic: Verifies full handshake, query-status with
  response parsing, stop/cont commands, and asynchronous STOP event
  delivery via the sd-event I/O callback
- test_qmp_client_eof: Verifies that the client properly detects
  server disconnection (EOF) and returns a disconnect error

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agoshell-completion: add bash/zsh completions for machinectl pause/resume
Christian Brauner [Thu, 2 Apr 2026 14:21:14 +0000 (16:21 +0200)] 
shell-completion: add bash/zsh completions for machinectl pause/resume

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agoman: document machinectl pause/resume and update poweroff for VMs
Christian Brauner [Thu, 2 Apr 2026 14:21:21 +0000 (16:21 +0200)] 
man: document machinectl pause/resume and update poweroff for VMs

Add manpage entries for the new pause and resume verbs. Update the
poweroff description to cover VMs (ACPI powerdown via QMP) in addition
to containers (SIGRTMIN+4).

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agomachinectl: add VM control commands
Christian Brauner [Mon, 30 Mar 2026 12:28:29 +0000 (14:28 +0200)] 
machinectl: add VM control commands

Add new verbs for controlling vmspawn VMs:

  machinectl poweroff <machine>
  machinectl pause <machine>
  machinectl resume <machine>

Each verb discovers the machine's varlinkAddress via machined's
Machine.List, connects directly to vmspawn's varlink socket, and
calls the corresponding io.systemd.MachineInstance method.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: convert drive device setup to bridge
Christian Brauner [Wed, 8 Apr 2026 06:54:23 +0000 (08:54 +0200)] 
vmspawn: convert drive device setup to bridge

Remove the static blockdev/device/snapshot INI config sections and
the SCSI controller setup for both the root image drive and extra
drives. Replace with DriveInfos that are constructed in the parent
after fork: vmspawn opens all image files and passes fds to QEMU via
the add-fd path. For ephemeral mode, anonymous overlay files are
created via O_TMPFILE or memfd.

The resolve_disk_driver() helper maps DiskType to the appropriate
QEMU driver name and serial format.

The post-fork device-info preparation is split into helpers:
prepare_primary_drive() and prepare_extra_drives() for per-drive
construction, assign_pcie_ports() for naming the pre-allocated
pcie-root-port bridges once every device type is known, and
prepare_device_info() that stitches them together against the
MachineConfig aggregate.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: convert virtiofs device setup to bridge
Christian Brauner [Tue, 7 Apr 2026 12:50:23 +0000 (14:50 +0200)] 
vmspawn: convert virtiofs device setup to bridge

Remove the static chardev/device INI config sections for both the
root filesystem and runtime mount virtiofs instances. Replace with
VirtiofsInfos that capture socket paths and tags for each virtiofs
mount, passed to vmspawn_varlink_setup_virtiofs() for runtime
configuration via QMP.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: convert VSOCK device setup to bridge
Christian Brauner [Tue, 7 Apr 2026 12:48:06 +0000 (14:48 +0200)] 
vmspawn: convert VSOCK device setup to bridge

Remove the static vsock0 INI config section and the related pass_fds
plumbing. Replace with a VsockInfo struct that captures the vhost fd
and guest CID, passed to vmspawn_qmp_setup_vsock() for runtime
configuration via QMP. The VSOCK fd is now sent to QEMU via QMP getfd
+ SCM_RIGHTS instead of being inherited.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: convert network device setup to bridge
Christian Brauner [Tue, 7 Apr 2026 12:47:10 +0000 (14:47 +0200)] 
vmspawn: convert network device setup to bridge

Remove the static netdev/nic INI config sections for both privileged
TAP, nsresourced TAP, and user-mode networking. Replace them with a
NetworkInfo struct that captures the network type, TAP fd or interface
name, and MAC address, passed to vmspawn_varlink_setup_network() for
runtime configuration via QMP.

For the nsresourced TAP path the fd is now passed to QEMU via QMP
getfd + SCM_RIGHTS instead of being inherited through pass_fds.

Declare the MachineConfig aggregate that this and the following
conversion patches populate, zero-initialized with explicit -EBADF
for the fd fields so every sub-structure cleans up safely regardless
of which device types the invocation ends up using.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: QMP-varlink bridge for VM runtime control
Christian Brauner [Wed, 8 Apr 2026 07:02:37 +0000 (09:02 +0200)] 
vmspawn: QMP-varlink bridge for VM runtime control

Create a QMP socketpair for QEMU machine monitor control, configure
the QMP chardev+mon via the QEMU config file, and wire up the bridge
infrastructure.

After fork, vmspawn initializes the QMP bridge, probes QEMU feature
support synchronously (driving the QMP handshake to RUNNING
transparently), resumes vCPUs, then sets up the varlink server for
runtime VM control. The control socket path is passed to machined via
the controlAddress field in machine registration.

Device configuration still uses the legacy INI config path and will
be converted to bridge calls in subsequent commits.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: pre-allocate PCIe root ports for device hotplug
Christian Brauner [Wed, 8 Apr 2026 07:02:26 +0000 (09:02 +0200)] 
vmspawn: pre-allocate PCIe root ports for device hotplug

On PCIe machine types (q35, virt), QMP device_add is always hotplug —
even with vCPUs stopped. The root PCIe bus (pcie.0) does not support
hotplugging; only pcie-root-port bridges do. Pre-allocate enough root
ports in the QEMU config file for all devices that will be set up via
QMP, plus 10 spare ports for future runtime hotplug.

Add ARCHITECTURE_NEEDS_PCIE_ROOT_PORTS macro to guard PCIe-specific
setup on x86, ARM, RISC-V, and LoongArch (the architectures whose
QEMU machine type is q35 or virt).

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agovmspawn: set up varlink bridge infrastructure
Christian Brauner [Mon, 30 Mar 2026 12:08:40 +0000 (14:08 +0200)] 
vmspawn: set up varlink bridge infrastructure

Create the QMP-to-varlink bridge layer (vmspawn-qmp.{c,h}) and the
varlink server layer (vmspawn-varlink.{c,h}).

The QMP bridge (VmspawnQmpBridge) owns the QmpClient connection and
manages pending background jobs (e.g. blockdev-create continuations).
vmspawn_qmp_init() creates the client and attaches it to the event
loop. vmspawn_qmp_probe_features() drives io_uring and qcow2
discard-no-unref probes synchronously via a qmp_client_process() +
qmp_client_wait() loop — the QMP handshake completes transparently on
the first invoke. vmspawn_qmp_start() resumes vCPUs via an async
"cont" command.

The varlink server (VmspawnVarlinkContext) exposes three interfaces:

- io.systemd.MachineInstance: generic machine control (Terminate,
  PowerOff, Reboot, Pause, Resume, Describe, SubscribeEvents).
  Method handlers forward to QMP commands asynchronously — the
  varlink reply is deferred until the QMP response arrives.
- io.systemd.VirtualMachineInstance: VM-specific (placeholder for
  future snapshot/migration methods).
- io.systemd.QemuMachineInstance: QEMU-specific (AcquireQMP stub).

The server listens on <runtime_dir>/control with mode 0600.

Event streaming follows the importd Pull pattern: SubscribeEvents
sends an initial {ready:true} notification, then fans out QMP events
to all subscribers. The disconnect handler only unrefs subscriber
links (matching resolved's vl_on_notification_disconnect pattern).

Introduce the MachineConfig aggregate in vmspawn-qmp.h grouping the
per-device info structures (DriveInfos, NetworkInfo, VirtiofsInfos,
VsockInfo) together with machine_config_done() that chains the
individual done helpers. Callers populate it field-by-field and rely
on the _cleanup_ attribute for orderly teardown regardless of which
device types the invocation ends up using.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agoshared: add QMP client library
Christian Brauner [Mon, 30 Mar 2026 12:02:10 +0000 (14:02 +0200)] 
shared: add QMP client library

Async QMP client for talking to QEMU's machine monitor from
libsystemd-shared. The I/O core (buffered read/write, output queue,
event source management) follows sd-varlink's patterns.

State machine:

  INITIAL -> GREETING_RECEIVED -> CAPABILITIES_SENT -> RUNNING
                                                          |
                                                          v
                                                     DISCONNECTED

The QMP handshake (greeting + qmp_capabilities) is driven transparently
by qmp_client_invoke() through an internal qmp_client_ensure_running()
helper, matching sd-bus's bus_ensure_running() pattern. Callers never
wait for it explicitly.

qmp_client_invoke() is the only command interface: asynchronous, with
per-command callback. Slots are tracked in a Set keyed by id; replies
are dispatched by id match. SCM_RIGHTS fd passing is bundled through
QmpClientArgs and the QMP_CLIENT_ARGS_FD macro.

qmp_client_process() and qmp_client_wait() are exposed publicly,
mirroring sd_varlink_process() and sd_varlink_wait(). Callers that
need to drive the client synchronously — e.g. feature probing before
entering the sd_event main loop — can loop on them exactly like
varlink_call_internal() does on its varlink equivalents.

Other features:

- Buffered stream reader for QMP's \r\n-delimited JSON, handling
  multi-read responses (query-qmp-schema is ~200 KiB).
- Fdset id allocation via qmp_client_next_fdset_id().
- Synthetic SHUTDOWN event on unexpected disconnect.
- Disconnect detection with callback notification and pending-command
  cleanup.
- -ENOBUFS from the 16 MiB input-buffer cap is treated as recoverable
  (not a transport error).

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agojson-stream: expose log helpers for consumers
Christian Brauner [Sat, 11 Apr 2026 12:00:07 +0000 (14:00 +0200)] 
json-stream: expose log helpers for consumers

Move json_stream_description(), json_stream_log(), and
json_stream_log_errno() from json-stream.c into json-stream.h so that
consumers like the QMP client can use the same description-prefixed
logging that json-stream itself uses internally.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agomachined: add controlAddress field to Machine.Register and Machine.List
Christian Brauner [Mon, 30 Mar 2026 11:52:08 +0000 (13:52 +0200)] 
machined: add controlAddress field to Machine.Register and Machine.List

Follow the existing sshAddress pattern to add a controlAddress field
that allows machine registrants (like vmspawn) to advertise a varlink
socket address for direct VM control. machined stores and exposes
the address but never connects to it itself.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agoshared: add varlink interface definitions for machine instance control
Christian Brauner [Mon, 30 Mar 2026 11:51:04 +0000 (13:51 +0200)] 
shared: add varlink interface definitions for machine instance control

Add three varlink interface definitions for the machine instance control
hierarchy:

- io.systemd.MachineInstance: generic operations applicable to both
  containers and VMs (PowerOff, Reboot, Pause, Resume, QueryStatus,
  SubscribeEvents). nspawn could implement this same interface later.

- io.systemd.VirtualMachineInstance: VM-specific but VMM-agnostic
  operations. Empty for now, future home for AddBlockDevice and similar.

- io.systemd.QemuMachineInstance: QEMU-specific operations. Defines
  AcquireQMP() for protocol upgrade to a direct QMP connection.

The "Instance" suffix avoids collision with machined's existing
io.systemd.Machine interface.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2 months agoMerge pull request #41375 from brauner/work.todo.cleanup
Zbigniew Jędrzejewski-Szmek [Wed, 15 Apr 2026 06:09:55 +0000 (08:09 +0200)] 
Merge pull request #41375 from brauner/work.todo.cleanup

[zjs: I did the merge by hand to incorporate the changes that
were made on 'main' in the meantime. That is easier then rebasing
the series.]

2 months agovarious: fix compilation with openssl-4.0.0-beta1
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 16:59:07 +0000 (18:59 +0200)] 
various: fix compilation with openssl-4.0.0-beta1

Various types have been made opaque, so we need to use some accessor
functions.

2 months agojournal-upload: modernize macro wrapping curl_easy_setopt
Zbigniew Jędrzejewski-Szmek [Mon, 9 Feb 2026 11:02:03 +0000 (12:02 +0100)] 
journal-upload: modernize macro wrapping curl_easy_setopt

We cannot use a function, because the type is unknown and we want
to stringify the option name, but we can use a block macro to make
this a bit nicer, with normal code structure in the caller.

2 months agoreport: use the new option and verb macros
Zbigniew Jędrzejewski-Szmek [Tue, 24 Mar 2026 22:30:13 +0000 (23:30 +0100)] 
report: use the new option and verb macros

2 months agomkosi: update fedora commit reference to 207e2d004468bf79a8bd78182d9b10956edf45c7
Luca Boccassi [Tue, 14 Apr 2026 21:01:02 +0000 (22:01 +0100)] 
mkosi: update fedora commit reference to 207e2d004468bf79a8bd78182d9b10956edf45c7

207e2d0044 Stop building support for openssl engines
36a234147f Upload sources
3681163f81 Version 260.1
8f4f0f58e3 Version 260
e3fab23aa0 Version 260~rc4
e4c1c2100b Version 260~rc3
453696813e Fix typo in unit name in %post scriptlet
154edb7cdb Silence false positive "HWID match failed, no DT blob" error (rhbz#2444759)
03b6637c35 riscv64 port has LTO disabled
ce1dec6a40 Version 260~rc2
809049777c Add patch for symlink creation error
6ff27708f7 Enable getty@.service through presets
ba7807fbce Drop scriptlet for upgrades from versions <253
455f277188 Move support for tpm2 to systemd-udev subpackage
0183bc784e Version 260~rc1

2 months agoConvert executor to OPTION macros (#41618)
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 22:09:29 +0000 (00:09 +0200)] 
Convert executor to OPTION macros (#41618)

This was causing failures in CI previously for reasons I couldn't
fathom. So I'm submitting this conversion separately as a draft.

2 months agoresolved: check for reset-statistics polkit action via D-Bus too
Luca Boccassi [Tue, 14 Apr 2026 18:15:48 +0000 (19:15 +0100)] 
resolved: check for reset-statistics polkit action via D-Bus too

The varlink method checks for polkit authorization, so also
update the D-Bus method to match it.

Follow-up for cf01bbb7a45fb1eec28cd0a813bd68fde413410f

2 months agoTEST-75-RESOLVED: Make sure --suppress-sync is not used
Daan De Meyer [Mon, 6 Apr 2026 13:11:08 +0000 (15:11 +0200)] 
TEST-75-RESOLVED: Make sure --suppress-sync is not used

2 months agotest-seccomp: Handle environment where sync() is already suppressed
Daan De Meyer [Sun, 5 Apr 2026 19:29:31 +0000 (21:29 +0200)] 
test-seccomp: Handle environment where sync() is already suppressed

We might be running in an nspawn container booted with --suppress-sync,
so make sure we handle that scenario gracefully.

2 months agoTEST-06-SELINUX: Relabel in the initrd rather than at image build time
Daan De Meyer [Thu, 26 Mar 2026 14:40:07 +0000 (15:40 +0100)] 
TEST-06-SELINUX: Relabel in the initrd rather than at image build time

This gets rid of the requirement to run the image build as root.

2 months agoTEST-64-UDEV-STORAGE: Add missing scsi controllers
Daan De Meyer [Thu, 26 Mar 2026 13:22:43 +0000 (14:22 +0100)] 
TEST-64-UDEV-STORAGE: Add missing scsi controllers

2 months agoTEST-24-CRYPTSETUP: Use virtio-blk-pci
Daan De Meyer [Thu, 26 Mar 2026 12:57:13 +0000 (13:57 +0100)] 
TEST-24-CRYPTSETUP: Use virtio-blk-pci

Doesn't require a controller.

2 months agoTEST-13-NSPAWN: Use timeout --foreground in two more places
Daan De Meyer [Thu, 26 Mar 2026 08:01:58 +0000 (09:01 +0100)] 
TEST-13-NSPAWN: Use timeout --foreground in two more places

2 months agoTEST-07-PID1: Use --foreground with timeout
Daan De Meyer [Thu, 26 Mar 2026 07:41:36 +0000 (08:41 +0100)] 
TEST-07-PID1: Use --foreground with timeout

Otherwise the test fails if a TTY is attached to stdio.

2 months agoTEST-07-PID1: Don't fail in vm without ESP or XBOOTLDR mount
Daan De Meyer [Thu, 26 Mar 2026 07:41:17 +0000 (08:41 +0100)] 
TEST-07-PID1: Don't fail in vm without ESP or XBOOTLDR mount

2 months agodocs: update footer to 2026
roib [Tue, 14 Apr 2026 15:06:34 +0000 (08:06 -0700)] 
docs: update footer to 2026

2 months agotest: do not use nanoseconds width specifier in date command
Nick Rosbrook [Mon, 13 Apr 2026 20:06:23 +0000 (16:06 -0400)] 
test: do not use nanoseconds width specifier in date command

Using the format specifier +%s%6N with GNU date is honored, and only
prints 6 digits of the nanoseconds portion of the seconds since epoch.
The uutils implementation of date does not honor this, and always prints
all 9 digits. This is a known bug[1], but can be worked around by
adapting this test to use nanoseconds instead of microseconds.

[1] https://github.com/uutils/coreutils/issues/11658

2 months agoparse-helpers: Silence coverity warning
Daan De Meyer [Tue, 14 Apr 2026 13:41:21 +0000 (15:41 +0200)] 
parse-helpers: Silence coverity warning

2 months agobasic: resurrect unit_type_to_capitalized_string()
Ivan Kruglov [Fri, 17 Oct 2025 12:11:09 +0000 (05:11 -0700)] 
basic: resurrect unit_type_to_capitalized_string()

2 months ago tree-wide: convert remaining varlink string fields to enum types (#41615)
Lennart Poettering [Tue, 14 Apr 2026 12:04:13 +0000 (14:04 +0200)] 
 tree-wide: convert remaining varlink string fields to enum types (#41615)

Follow-up to #40972. Convert remaining plain string fields to proper
varlink enum types across all interfaces, per the policy that
user-controlled/API fields should be declared as proper enums in the
IDL.

Interfaces converted:
- io.systemd.Manager — LogTarget, DefaultStandardOutput/Error,
DefaultMemory/CPU/IOPressureWatch, DefaultOOMPolicy,
CtrlAltDelBurstAction (8 fields)
- io.systemd.Unit — CPUSchedulingPolicy, IOSchedulingClass, NUMAPolicy,
MountFlags (4 fields)
- io.systemd.Machine — class, whom (2 fields, input dispatch converted
to JSON_DISPATCH_ENUM_DEFINE for automatic dashify fallback)
- io.systemd.oom / io.systemd.ManagedOOM — mode in ControlGroup (1
field)

Shared types moved to varlink-idl-common: ExecOutputType,
CGroupPressureWatch, EmergencyAction, ManagedOOMMode — these are reused
across multiple interfaces.

Each interface change includes a corresponding enum sync test to catch
future drift between C string tables and varlink IDL definitions.

2 months agotree-wide: use JSON_BUILD_PAIR_ENUM() more often
Lennart Poettering [Tue, 14 Apr 2026 10:29:52 +0000 (12:29 +0200)] 
tree-wide: use JSON_BUILD_PAIR_ENUM() more often

2 months agodocs: clarify when to use varlink enum types vs plain strings
Ivan Kruglov [Tue, 14 Apr 2026 09:25:43 +0000 (02:25 -0700)] 
docs: clarify when to use varlink enum types vs plain strings

Add guidance on when a field should use a proper varlink enum type
versus remaining a plain string: user-controlled/API fields should be
enums, engine-internal state fields may stay as strings.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agovarlink: add ManagedOOMMode enum type to io.systemd.oom 41615/head
Ivan Kruglov [Mon, 13 Apr 2026 10:56:48 +0000 (03:56 -0700)] 
varlink: add ManagedOOMMode enum type to io.systemd.oom

Convert the mode field in ControlGroup from plain string to the
ManagedOOMMode enum type from varlink-idl-common. Register
ManagedOOMMode in both io.systemd.oom and io.systemd.ManagedOOM
interfaces since both use the ControlGroup struct.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agovarlink: add enum types for class and whom fields in io.systemd.Machine
Ivan Kruglov [Mon, 13 Apr 2026 10:32:16 +0000 (03:32 -0700)] 
varlink: add enum types for class and whom fields in io.systemd.Machine

Convert the class field (Register input, List output) from plain string
to MachineClass enum type, and the whom field (Kill input) to KillWhom
enum type.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agovarlink: add enum types for scheduling and mount settings in io.systemd.Unit
Ivan Kruglov [Mon, 13 Apr 2026 10:25:21 +0000 (03:25 -0700)] 
varlink: add enum types for scheduling and mount settings in io.systemd.Unit

Convert CPUSchedulingPolicy, IOSchedulingClass, NUMAPolicy and MountFlags
fields from plain strings to proper varlink enum types in the io.systemd.Unit
interface. Update the corresponding serialization code to use
json_underscorify() for correct enum value formatting.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agovarlink: add enum types for configuration settings in io.systemd.Manager
Ivan Kruglov [Mon, 13 Apr 2026 09:53:38 +0000 (02:53 -0700)] 
varlink: add enum types for configuration settings in io.systemd.Manager

Convert 8 string fields in the io.systemd.Manager varlink interface to
proper enum types:

- LogTarget: new enum (console, console_prefixed, kmsg, journal, ...)
- DefaultStandardOutput/Error: reuse ExecOutputType from common
- DefaultMemory/CPU/IOPressureWatch: reuse CGroupPressureWatch from common
- DefaultOOMPolicy: new enum (continue, stop, kill)
- CtrlAltDelBurstAction: reuse EmergencyAction from common

Output serialization updated to use JSON_BUILD_PAIR_ENUM for automatic
underscorification of dash-containing values.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agoexecutor: move reopening of the console after option parsing 41618/head
Zbigniew Jędrzejewski-Szmek [Mon, 13 Apr 2026 12:20:43 +0000 (14:20 +0200)] 
executor: move reopening of the console after option parsing

It seems to be interfering with systemd:check-help-systemd-executor
test in CI. In practice, any messages from parse_argv() are going
to be from manual invocations, since if called from PID1 the option
syntax is going to be correct. So I hope this fixes the redirection
of --help but otherwise is of little consequence.

2 months agoexecutor: do not abort on invalid serialization fd
Zbigniew Jędrzejewski-Szmek [Fri, 10 Apr 2026 21:18:10 +0000 (23:18 +0200)] 
executor: do not abort on invalid serialization fd

E.g. --deserialize=15 would cause the program to abrt in safe_close.
But in fact, we shouldn't try to do the close in any case: if the
fd is not valid, we should return an error without modifying state.
And if it _is_ valid, we set O_CLOEXEC on it, so it'll be closed
automatically later.

2 months agoimportd: harden curl file protocol handling
Luca Boccassi [Fri, 10 Apr 2026 23:15:13 +0000 (00:15 +0100)] 
importd: harden curl file protocol handling

With old libcurl versions file:// can get redirects which can be messy, while
the new version rejects them. Set an option to explicit block them.

2 months agoAssorted cleanups and fixes (#41626)
Zbigniew Jędrzejewski-Szmek [Tue, 14 Apr 2026 07:10:16 +0000 (09:10 +0200)] 
Assorted cleanups and fixes (#41626)

2 months agoNEWS: pre-announce removal of /run/boot-loader-entries/ support in lo… (#41622)
Christian Brauner [Tue, 14 Apr 2026 06:54:33 +0000 (08:54 +0200)] 
NEWS: pre-announce removal of /run/boot-loader-entries/ support in lo… (#41622)

…gind

logind could read UAPI.1 Boot Loader Spec entries from
/run/boot-loader-entries/ in addition to ESP/XBOOTLDR. This was pretty
half-assed, and to my knowledge was never actually used much.

Let's remove support for it and simplify our codebase.

Let's schedule it for removal via NEWS in a future version, to give
people a chance to speak up.

2 months agohwdb: Add extended SteelSeries Arctis headset device support (#41628)
Sriman Achanta [Tue, 14 Apr 2026 00:08:30 +0000 (20:08 -0400)] 
hwdb: Add extended SteelSeries Arctis headset device support (#41628)

Add USB device IDs for additional SteelSeries Arctis headset models to
the sound card hardware database.

Newly added device IDs:

- Arctis Nova 7x v2 (22AD)
- Arctis Nova 7 Diablo IV (22A9)
- Arctis Nova 7X (22A4)
- Arctis Nova 7X (22A5)
- Arctis Nova 7P V2 (22A7)

2 months agojournal-upload: also disable VERIFYHOST when --trust=all is used 41626/head
Luca Boccassi [Mon, 13 Apr 2026 20:02:10 +0000 (21:02 +0100)] 
journal-upload: also disable VERIFYHOST when --trust=all is used

When --trust=all disables CURLOPT_SSL_VERIFYPEER, the residual
CURLOPT_SSL_VERIFYHOST check is ineffective since an attacker can
present a self-signed certificate with the expected hostname. Disable
both for consistency and log that server certificate verification is
disabled.

Follow-up for 8847551bcbfa8265bae04f567bb1aadc7b480325

2 months agomachined: pass user as positional argument in machine_default_shell_args()
Luca Boccassi [Mon, 13 Apr 2026 19:38:27 +0000 (20:38 +0100)] 
machined: pass user as positional argument in machine_default_shell_args()

Instead of interpolating the user name directly into the sh -c script
body via asprintf %s, pass it as a positional parameter ($1) in a
separate argv entry. This avoids the user string being parsed as part
of the shell script syntax.

Also validate the user name in bus_machine_method_open_shell() with
valid_user_group_name(), matching the validation already done on the
Varlink path via json_dispatch_const_user_group_name().

Follow-up for 49af9e1368571f4e423cde0fd45ee284451434d1

2 months agologind: reject wall messages containing control characters
Luca Boccassi [Mon, 13 Apr 2026 19:26:22 +0000 (20:26 +0100)] 
logind: reject wall messages containing control characters

method_set_wall_message() and the property setter only checked the
message length but not its content. Since wall messages are broadcast
to all TTYs, control characters in the message could interfere with
terminal state. Reject messages containing control characters other
than newline and tab.

Follow-up for 9ef15026c0e7e6600372056c43442c99ec53746e
Follow-up for e2fa5721c3ee5ea400b99a6463e8c1c257e20415

2 months agocore: check selinux access on each unit when listing
Luca Boccassi [Mon, 13 Apr 2026 21:11:27 +0000 (22:11 +0100)] 
core: check selinux access on each unit when listing

Units might have different access rules, so check the access on each
unit when querying the full list.

2 months agocore: add missing SELinux access checks when listing units
Luca Boccassi [Mon, 13 Apr 2026 19:21:25 +0000 (20:21 +0100)] 
core: add missing SELinux access checks when listing units

Add mac_selinux_unit_access_check_varlink() to the unit enumeration
loop in vl_method_list_units(), silently skipping units the caller
is not permitted to see, matching the D-Bus ListUnits behavior.
Add mac_selinux_access_check_varlink() to vl_method_describe_manager().

Follow-up for 472abf7bec89caeb1cc413c1de17984ab8ccb5d6
Follow-up for 736349958efe34089131ca88950e2e5bb391d36a

2 months agovmspawn: Support RUNTIME_DIRECTORY again (#41619)
Christian Brauner [Mon, 13 Apr 2026 17:46:55 +0000 (19:46 +0200)] 
vmspawn: Support RUNTIME_DIRECTORY again (#41619)

In ccecae0efd ("vmspawn: use machine name in runtime directory path")
support for RUNTIME_DIRECTORY was dropped which makes it difficult to
run systemd-vmspawn in a service unit which doesn't have write access to
the regular /run but should use its own managed RUNTIME_DIRECTORY. What
worked before was --keep-unit --system but we can't use XDG_RUNTIME_DIR
and --user because then --keep-unit breaks which we need because it
can't create a scope as there is no session. Switch back to
runtime_directory which handles RUNTIME_DIRECTORY and tells us whether
we should use it as is without later cleanup or if we need to use the
regular path where we create and delete the directory ourselves.

2 months agoNEWS: pre-announce removal of /run/boot-loader-entries/ support in logind 41622/head
Lennart Poettering [Mon, 13 Apr 2026 15:46:00 +0000 (17:46 +0200)] 
NEWS: pre-announce removal of /run/boot-loader-entries/ support in logind

logind could read UAPI.1 Boot Loader Spec entries from
/run/boot-loader-entries/ in addition to ESP/XBOOTLDR. This was pretty
half-assed, and to my knowledge was never actually used much.

Let's remove support for it and simplify our codebase.

Let's schedule it for removal via NEWS in a future version, to give
people a chance to speak up.

2 months agodocs: fix capability name, it's CAP_MKNOD not CAP_SYS_MKNOD (#41621)
rusty-snake [Mon, 13 Apr 2026 15:41:33 +0000 (17:41 +0200)] 
docs: fix capability name, it's CAP_MKNOD not CAP_SYS_MKNOD (#41621)

2 months agoci: Two claude-review fixes
Daan De Meyer [Mon, 13 Apr 2026 14:27:10 +0000 (16:27 +0200)] 
ci: Two claude-review fixes

- Use persist-credentials: false for actions/checkout, so we don't
  leak the github token credentials to subsequent jobs.
- Remove one / from the Edit/Write permissions. Currently, with the
  absolute path from github.workspace, we expand to three slashes while
  we only need two.

2 months agovarlink: move shared enum types to varlink-idl-common
Ivan Kruglov [Mon, 13 Apr 2026 09:53:23 +0000 (02:53 -0700)] 
varlink: move shared enum types to varlink-idl-common

Move ExecOutputType, CGroupPressureWatch, EmergencyAction and
ManagedOOMMode enum type definitions from varlink-io.systemd.Unit to
varlink-idl-common, as these types are shared across multiple varlink
interfaces.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agovmspawn: Support RUNTIME_DIRECTORY again 41619/head
Kai Lüke [Mon, 13 Apr 2026 12:21:39 +0000 (21:21 +0900)] 
vmspawn: Support RUNTIME_DIRECTORY again

In ccecae0efd ("vmspawn: use machine name in runtime directory path")
support for RUNTIME_DIRECTORY was dropped which makes it difficult to
run systemd-vmspawn in a service unit which doesn't have write access
to the regular /run but should use its own managed RUNTIME_DIRECTORY.
What worked before was --keep-unit --system but we can't use
XDG_RUNTIME_DIR and --user because then --keep-unit breaks which
we need because it can't create a scope as there is no session.
Switch back to runtime_directory which handles RUNTIME_DIRECTORY and
tells us whether we should use it as is without later cleanup or if we
need to use the regular path where we create and delete the directory
ourselves.

2 months agomany: final final set of coccinelle check-pointer-deref tweaks (#41595)
Zbigniew Jędrzejewski-Szmek [Mon, 13 Apr 2026 11:59:24 +0000 (13:59 +0200)] 
many: final final set of coccinelle check-pointer-deref tweaks (#41595)

I promised in https://github.com/systemd/systemd/pull/41426 that its the
final update for coccinelle pointer deref checks. However it turned out
there is this coccinelle/parsing_hacks.h that I wasn't aware of. The
file missed some important things like _cleanup_(x) that prevented
coccinelle to check a bunch of functions.

This PR adds some missing defines to the parsing_hacks.h and fixes the
missing asserts(). I apologize that its a bit long (and frankly boring)
and that I missed this earlier.

The last commit contains one small behavior change (ret in
sd_varlink_idl_parse() is now really optional) but the big one is very
mechanical.

2 months agoexecutor: convert to the new option parser, define OPTION_COMMON_LOG_*
Zbigniew Jędrzejewski-Szmek [Fri, 10 Apr 2026 16:07:29 +0000 (18:07 +0200)] 
executor: convert to the new option parser, define OPTION_COMMON_LOG_*

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agostat-util: use stat_verify_xyz() and friends more (#41613)
Lennart Poettering [Mon, 13 Apr 2026 11:39:47 +0000 (13:39 +0200)] 
stat-util: use stat_verify_xyz() and friends more (#41613)

2 months agorun: allow setting output format
Arnout Engelen [Mon, 6 Apr 2026 08:00:37 +0000 (10:00 +0200)] 
run: allow setting output format

This is useful when moving from `--pty` or `--pipe` to using
`--verbose`: you can use `--verbose-output=cat` to get similar output on
stdout while still having all of the advantages of `--verbose` over the
other options.

2 months agostat-util: always check S_ISDIR() before S_ISLNK() 41613/head
Lennart Poettering [Mon, 13 Apr 2026 11:14:46 +0000 (13:14 +0200)] 
stat-util: always check S_ISDIR() before S_ISLNK()

Check S_ISDIR() before S_ISLINK() for all stat_verify_xyz() helpers
first, where we check them. Just to ensure we systematically return the
same errors.

2 months agostat-util: also add stat_verify_char() and use it everywhere
Lennart Poettering [Mon, 13 Apr 2026 09:20:57 +0000 (11:20 +0200)] 
stat-util: also add stat_verify_char() and use it everywhere

2 months agosocket-netlink: use stat_verify_socket() more
Lennart Poettering [Mon, 13 Apr 2026 09:10:36 +0000 (11:10 +0200)] 
socket-netlink: use stat_verify_socket() more

2 months agotree-wide: use stat_verify_directory() more
Lennart Poettering [Mon, 13 Apr 2026 09:10:03 +0000 (11:10 +0200)] 
tree-wide: use stat_verify_directory() more

2 months agotree-wide: use stat_verify_regular() more
Lennart Poettering [Mon, 13 Apr 2026 09:09:25 +0000 (11:09 +0200)] 
tree-wide: use stat_verify_regular() more

2 months agostat-util: also introduce stat_verify_block() and use it everywhere
Lennart Poettering [Mon, 13 Apr 2026 08:45:29 +0000 (10:45 +0200)] 
stat-util: also introduce stat_verify_block() and use it everywhere

2 months agostat-util: add shortcut for fd_verify_symlink()
Lennart Poettering [Mon, 13 Apr 2026 08:41:01 +0000 (10:41 +0200)] 
stat-util: add shortcut for fd_verify_symlink()

We have a similar shortcut in the other fd_verify_xyz() calls, let's add
it here too, just for completion's sake.

2 months agotree-wide: make more use of stat_verify_device_node()
Lennart Poettering [Mon, 13 Apr 2026 08:28:54 +0000 (10:28 +0200)] 
tree-wide: make more use of stat_verify_device_node()

2 months agostat-util: introduce a common (stat|fd)_verify_regular_or_block() helper
Lennart Poettering [Mon, 13 Apr 2026 08:26:36 +0000 (10:26 +0200)] 
stat-util: introduce a common (stat|fd)_verify_regular_or_block() helper

We already had one in repart.c, let's generalize it, and use it
everywhere.

2 months agoboot: fix loop bound and OOB in devicetree_get_compatible()
Milan Kyselica [Sat, 11 Apr 2026 08:26:13 +0000 (10:26 +0200)] 
boot: fix loop bound and OOB in devicetree_get_compatible()

The loop used the byte offset end (struct_off + struct_size) as the
iteration limit, but cursor[i] indexes uint32_t words. This reads
past the struct block when end > size_words.

Use size_words (struct_size / sizeof(uint32_t)) which is the correct
number of words to iterate over.

Also fix a pre-existing OOB in the FDT_BEGIN_NODE handler: the guard
i >= size_words is always false inside the loop (since the loop
condition already ensures i < size_words), so cursor[++i] at the
boundary reads one word past the struct block. Use i + 1 >= size_words
to check before incrementing.

Fixes: https://github.com/systemd/systemd/issues/41590