Commit Graph

562 Commits

Author SHA1 Message Date
Lennart Poettering
2251f726b3 bootctl: add --print-efi-architecture switch
This is extremely useful for our own test cases, since acquiring the
right EFI architecture string is otherwise a bit nasty.
2026-04-20 22:21:46 +02:00
Luca Boccassi
2e79f8aa41 systemctl: add --kernel-cmdline= argument
Allows appending kernel command line arguments, like
kexec-tool does. This is especially needed for the integration
tests, as mkosi adds a bunch of options that are needed for the
test suite to work, and it breaks without them.
2026-04-17 13:58:05 +01:00
Christian Brauner
e2af53db04 shell-completion: add bash/zsh completions for machinectl pause/resume
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-04-15 10:14:48 +02:00
Daan De Meyer
4bbdc8a6a2 nspawn: Add --restrict-address-families= option
Add a new --restrict-address-families= command line option and
corresponding RestrictAddressFamilies= setting for .nspawn files to
restrict which socket address families may be used inside a container.

Many address families such as AF_VSOCK and AF_NETLINK are not
network-namespaced, so restricting access to them in containers
improves isolation. The option supports allowlist and denylist modes
(via ~ prefix), as well as "none" to block all families, matching the
semantics of RestrictAddressFamilies= in unit files.

The address family parsing logic is extracted into a shared
parse_address_families() helper in parse-helpers.c, which is now also
used by config_parse_address_families() in load-fragment.c.

This is currently opt-in. In a future version, the default will be
changed to restrict address families to AF_INET, AF_INET6 and AF_UNIX.
2026-04-13 11:14:11 +02:00
Daan De Meyer
e4f535fdca vmspawn: Always enable CXL on supported architectures
Drop the --cxl= option and unconditionally enable cxl=on the QEMU
machine type whenever the host architecture supports it (x86_64 and
aarch64). The flag was only added for testing parity with mkosi's CXL=
setting and there is no reason to leave it as an opt-in toggle: with no
pxb-cxl device or cxl-fmw window attached, enabling it on the machine
only reserves a small MMIO region and emits an empty CEDT, so the cost
is negligible while removing one knob users would otherwise have to
flip explicitly to exercise the CXL code paths in QEMU.
2026-04-07 12:47:31 +02:00
Daan De Meyer
e7fb7296f5 nspawn: rename --user= to --uid= and repurpose --user/--system for runtime scope
Rename nspawn's --user=NAME option to --uid=NAME for selecting the
container user. The -u short option is preserved. --user=NAME and
--user NAME are still accepted but emit a deprecation warning. A
pre-parsing step stitches the space-separated --user NAME form into
--user=NAME before getopt sees it, preserving backwards compatibility
despite --user now being an optional_argument.

Repurpose --user (without argument) and --system as standalone
switches for selecting the runtime scope (user vs system service
manager).

Replace all uses of the arg_privileged boolean with
arg_runtime_scope comparisons throughout nspawn. The default scope
is auto-detected from the effective UID.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 18:49:40 +02:00
Daan De Meyer
1e084aad7d shared: move machine registration to shared machine-register.{c,h}
Move register_machine() and unregister_machine() from
vmspawn-register.{c,h} into shared machine-register.{c,h} so both
nspawn and vmspawn can use the same implementation.

The unified register_machine() uses varlink first (for richer
features like SSH support and unit allocation) with a D-Bus
RegisterMachineWithNetwork fallback for older machined. The
interface adds a class parameter ("vm" or "container") and
local_ifindex for nspawn's network interface support.

The unified unregister_machine() similarly tries varlink first
(io.systemd.Machine.Unregister) before falling back to D-Bus.

Both register_machine() and unregister_machine() only log at debug
level internally, leaving error/notice logging to callers.

Add register_machine_with_fallback() which tries system and/or user
scope registration based on a RuntimeScope parameter
(_RUNTIME_SCOPE_INVALID for both), and
unregister_machine_with_fallback() as its counterpart. Both use
RET_GATHER() to collect errors from each scope.

Make --register= a tristate (yes/no/auto) defaulting to auto. When
set to auto, registration failures are logged at notice level and
ignored. When set to yes, failures are fatal.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 17:13:40 +02:00
Daan De Meyer
6a9888c4c6 vmspawn: add --cxl= option and memory hotplug support
Add --cxl=BOOL option to enable CXL (Compute Express Link) support in
the virtual machine. CXL is a high-speed interconnect standard that
allows CPUs to access memory attached to devices such as accelerators
and memory expanders, enabling flexible memory pooling and expansion
beyond what is physically installed on the motherboard. When enabled,
adds cxl=on to the QEMU machine configuration. Only supported on x86_64
and aarch64 architectures.

This is added for testing purposes and for feature parity with mkosi's
CXL= setting.

Extend --ram= to accept an optional maximum size for memory hotplug,
using the syntax --ram=SIZE[:MAXSIZE] (e.g. --ram=2G:8G). When a
maximum is specified, the maxmem key is added to the QEMU memory
configuration section to enable memory hotplug up to the given limit.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 16:31:42 +02:00
Michael Vogt
0fc3f85d35 varlinkctl: add protocol upgrade support
The varlink spec supports protocol upgrades and they are very
useful to e.g. transfer binary data directly via varlink. So
far varlinkctl/sd-varlink was not supporting this. This commit
adds support for it in varlinkctl by using the new code in
sd-varlink and the generalized socket-forward code.
2026-03-31 18:25:09 +02:00
Daan De Meyer
d6e5fbca73 vmspawn: Add --firmware=describe
It's useful to be able to check what firmware description vmspawn
will select. In particular, this will allow me to figure out the
nvram template file that will be picked up so I can pick it up in
mkosi and operate on it to pass a modified version of it to vmspawn
with --efi-nvram-template=.
2026-03-27 14:22:29 +01:00
Daan De Meyer
5a7d70e807 vmspawn: add --efi-nvram-template= and --firmware-features= options
Add --efi-nvram-template=PATH to specify a custom firmware variables
file to copy and use as the initial EFI NVRAM state instead of the
default template from the firmware definition.

Add --firmware-features=FEATURE[,FEATURE...] to require or exclude
specific firmware features during automatic firmware discovery.
Features prefixed with "!" are excluded. If a feature appears in both
the included and excluded lists, inclusion takes priority. Firmware
with the "enrolled-keys" feature is excluded by default.

Refactor --secure-boot= to operate on the firmware features sets
instead of maintaining a separate tristate. --secure-boot=yes adds
"secure-boot" to the include set, --secure-boot=no adds it to the
exclude set, and --secure-boot=auto removes it from both.

Generalize find_ovmf_config() to accept include/exclude feature sets
instead of a secure boot tristate, removing the special-cased
enrolled-keys and secure-boot filtering logic.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 14:22:29 +01:00
Lennart Poettering
fb17ad1581 vmspawn: add disk type selection for root and extra drives (#41301)
vmspawn previously hardcoded virtio-blk for all drives. This adds
  --image-disk-type= to select the root disk type (virtio-blk,
  virtio-scsi, or nvme) and allows per-drive overrides via a
  colon-separated prefix on --extra-drive=. The format and disk type
  prefixes can appear in any order since their value sets don't overlap.

  For virtio-scsi, a single shared controller is created with drives
  attached as scsi-hd devices. For nvme, each drive gets its own
controller. Both have serial number length limits (30 and 20 characters
  respectively), so long filenames are replaced with a truncated SHA-256
  hex digest.
2026-03-24 21:48:00 +01:00
Daan De Meyer
a8c2aa9e2f vmspawn: Add headless console support 2026-03-24 21:36:19 +01:00
Christian Brauner
b76e1732f7 vmspawn: add nvme disk type support
Extend --image-disk-type= and the --extra-drive= disk type prefix to
support nvme in addition to virtio-blk and virtio-scsi:

  systemd-vmspawn --image-disk-type=nvme --image=image.raw
  systemd-vmspawn --image=image.raw --extra-drive=nvme:data.raw

The NVMe serial number is limited to 20 characters by the NVMe spec.
If the image filename exceeds this, it is hashed with SHA-256 and
truncated to 20 hex characters via the disk_serial() helper introduced
in the previous commit.

Signed-off-by: Christian Brauner <brauner@kernel.org>
2026-03-24 16:53:41 +01:00
Christian Brauner
e4a58c38e9 vmspawn: add virtio-scsi disk type support
Add --image-disk-type= to select the disk type for the root disk, and
allow specifying the disk type as a colon-separated prefix on
--extra-drive=:

  systemd-vmspawn --image-disk-type=virtio-scsi --image=image.raw
  systemd-vmspawn --image=image.raw --extra-drive=virtio-scsi:data.raw

For --extra-drive=, the format and disk type prefixes can appear in any
order since the value sets don't overlap:

  --extra-drive=raw:virtio-scsi:/path
  --extra-drive=virtio-scsi:raw:/path

Extra drives inherit --image-disk-type= by default unless overridden
with an explicit prefix.

vmspawn originally used virtio-scsi for all drives but switched to
virtio-blk in 1f24a954e4 for simplicity and direct kernel boot
compatibility. This makes virtio-scsi available again as an explicit
option for cases where a SCSI storage topology is desired.

For virtio-scsi, a shared virtio-scsi-pci controller is created and
drives are attached as scsi-hd devices. The SCSI serial number is
limited to 30 characters, so filenames exceeding this are hashed with
SHA-256.

Signed-off-by: Christian Brauner <brauner@kernel.org>
2026-03-24 16:53:40 +01:00
Zbigniew Jędrzejewski-Szmek
ec32afd525 shell-completion: add shell completions for systemd-hwdb
Co-developed-by: Claude <claude@anthropic.com>
2026-03-24 14:49:22 +00:00
Lennart Poettering
205b70e328 analyze: add "identify-tpm2" command that shows TPM2 chip information 2026-03-04 08:28:29 +01:00
Zbigniew Jędrzejewski-Szmek
d90858544c systemctl: rename enqueue-marked-jobs to enqueue-marked
Closes #40883. As described in the issue, it's not "jobs" that are
marked, and also the name is unnecessarilly long.

I think we don't need any compatibility measures here. At least in the
rpm world, package upgrade scripts go through the helper which is part
of the package so the new systemctl and the new helper are upgraded
together.
2026-03-03 15:26:45 +01:00
Yu Watanabe
ab2bc40dcd bash-completion/systemctl: add enqueue-marked-jobs and deprecate --marked
Follow-up for #40810.
2026-02-24 17:53:53 +00:00
Luca Boccassi
5137d58c22 bash completion: add --user/--system to portablectl 2026-02-18 10:40:12 +00:00
Luca Boccassi
28846f4e62 bash completion: add missing machinectl parameters 2026-02-18 10:40:12 +00:00
Luca Boccassi
3f618b8851 bash completion: fix machinectl completion when mixing machines and files 2026-02-18 10:39:38 +00:00
Luca Boccassi
5b6516f81e bash completion: add --system/--user to machinectl 2026-02-18 10:39:38 +00:00
Lennart Poettering
607152c742 varlinkctl: add 'list-registry' command 2026-02-09 10:54:17 +01:00
Yu Watanabe
8d96a18d90 bash-completion/sysext: add missing candidates for --always-refresh
Follow-up for 23115eeaf1.
2026-02-07 12:51:17 +01:00
Yu Watanabe
b3d73bc68e bash-completion/vmspawn: add -x/--ephemeral
Follow-up for 6e67fc2938.
2026-02-04 11:22:27 +01:00
Kai Lueke
23115eeaf1 sysext: Skip refresh if no changes are found
When the extensions for the final system are already set up from the
initrd we should avoid disrupting the boot process with the remount
(which currently isn't atomic) and the daemon reload for
systemd-confext and systemd-sysext. Similarly, when sysupdate ran and
updated extensions it's best to avoid the remount and daemon reload if
no changes are found.
To do this, encode the current extension state in more detail than
before where only the names of the extensions where encoded in the
overlay mount. This can also be used to provide more details about the
extension origin in "systemd-sysext status (--json=)". During the
refresh add a check whether the old state matches the new state and in
this case skip the refresh unless the user provides a flag to always
refresh. Besides the extension name and the resolved path the best
method for identification is the verity hash but that is not available
for plain image files or directories. Therefore, also include data to
check for file/directory replacements. The creation/modification times
are not always real on reproducible images or extracted archive content.
The file handle together with the unique mount ID is the next best
identifier we can use when we have no verity hash. Fall back to an inode
when we get no handle. With the creation/modification time and the path
this should be good enough. Using a unique mount ID is important (with
a fallback to the regular non-unique mount ID) instead of st_dev because
st_dev gets reused too easily, e.g., by a loop device mount and the
mount ID helps to catch this. For the mount ID to be valid it has to be
resolved before we enter the new mount namespace. Thus, it gets provided
by the image dissect logic and handed over to the sysext subprocess
which runs in a new mount namespace.
Luckily, we can rule out online modification of directories or image
files because this is anyway not well supported with overlay mounts, so
we don't do a file checksum nor do we recurse into a directory to look
for the most recently touched files.  But, as said, with the
always-refresh flag one can force a reload.
2026-02-04 00:05:24 +01:00
Kai Lüke
16b3472b3f vmspawn: Add image format option to support qcow2
A QEMU qcow2 VM image can be internally sparse and compressed.
Support such images in vmspawn for both the main disk and any extra
disks.
2026-01-29 09:02:13 +09:00
Kai Lüke
2e14be9a84 bash-completion/vmspawn: insert missing space between options
Follow-up for 3b18a8795d.
2026-01-28 19:48:48 +09:00
Daan De Meyer
4e805ec152 vmspawn: Add --user/--system and support user session machined registration
The UX of registering with the user session machined
instance is much better as there won't be an authorization
prompt. To make that available for users, let's add --user
and --system switches for vmspawn. For backwards compat, we'll
still try to register with the system machined instance if the
user machined instance is not available.
2026-01-02 08:49:36 +09:00
Guiorgy
f5530c10b8 Support Bash completions for short option group in journalctl (#40214)
Currently, the Bash completions for journalctl tries to match the
previous word _**exactly**_, which leads to the following issue:
`journalctl -u dock` correctly auto completes to `journalctl -u
docker.service`, but `journalctl -eu` provides no completions at all,
which is a shame since I never use the `-u` option alone (almost always
`-eu` or `-efu`, I wish the `-e` option was the default but I digress).

The proposed solution is to assume words that start with only a single
dash and consist of only letters are short option groups and handle them
as if the previous word was the short option using the last character,
e.g. `-efu` -> `-u`.
2025-12-31 14:58:58 +00:00
Luca Boccassi
a2d53619c0 varlinkctl: add support for polkit interactive auth 2025-12-17 23:22:05 +00:00
Luca Boccassi
2abb433ca1 shell-completion: fix portablectl path completion with preceding params
The completion fails to complete to paths for verbs that need them when
a --param is the previous word, e.g.:

portablectl attach --runtime <tab>

fails to complete to paths
2025-12-09 14:39:07 +09:00
Yu Watanabe
d2b8e42742 meson: exit earlier from the subdirectory when bash/zshcompletiondir is 'no' 2025-11-20 14:50:30 +09:00
Yu Watanabe
c74dc8cf14 meson: sort shell completions 2025-11-20 14:48:33 +09:00
Luca Boccassi
f16518ce86 shell-completion: add bash script for varlinkctl 2025-11-20 14:34:40 +09:00
Simon Barth
a049825708 shell-completion: bash: Add systemd-analyze calendar options
Add completion for the systemd-analyze calendar options --iterations and
--base-time.
2025-11-18 23:05:02 +01:00
Simon Barth
62aba7c5cd shell-completion: bash: Add systemd-analyze filesystems 2025-11-17 23:40:58 +01:00
Yu Watanabe
d32ec01223 shell-completion: drop deprecated cgroup controller suggestion 2025-11-17 21:31:51 +09:00
Jelle van der Waa
49ff5ad6e6 shell-completion: bash: add systemd-analyze image-policy completion 2025-11-10 20:09:53 +01:00
Lennart Poettering
d73d369133 analyze: add new verb for determining NvPCR values 2025-11-02 21:14:35 +01:00
Daan De Meyer
5cabeed80b run0: Add --empower
--empower gives full privileges to a non-root user. Currently this
includes all capabilities but we leave the option open to add more
privileges via this option in the future.

Why is this useful? When running privileged development or debugging
commands from your home directory (think bpftrace, strace and such),
you want any files written by these tools to be owned by your current
user, and not by the root user. run0 --empower will allow you to run
all privileged operations (assuming the tools check for capabilities
and not UIDs), while any files written by the tools will still be owned
by the current user.
2025-10-30 15:28:36 +01:00
Daan De Meyer
b1856a6c4a analyze: Add shell completion for dlopen-metadata 2025-10-30 14:11:28 +00:00
Pascal Bachor
9b5f1a6112 bash-completion: update systemd-sysext, systemd-confext 2025-09-26 20:20:49 +02:00
Zbigniew Jędrzejewski-Szmek
86048cce95 journalctl: add -W as short for --no-hostname
--no-hostname is one of the switches I use very often. In particular,
when looking at CI logs, the hostname is almost never interesting.
-H is not yet used in journalctl, because journal operates locally, but
will want it if display of remote journals is implemented. Use -W.
2025-09-17 14:27:00 +02:00
Luca Boccassi
e3f4aa4a75 shell-completion: add missing arguments for journalctl 2025-09-14 09:42:36 +01:00
Antonio Alvarez Feijoo
559da4a509 bash-completion/bootctl: add missing options and verb 2025-09-08 12:37:26 +02:00
Yu Watanabe
5bb434e317 shell-completion: support -i option for journalctl
Follow-up for dde54b8a85.
2025-08-26 19:24:39 +01:00
Zbigniew Jędrzejewski-Szmek
9fa08842b7 shell-completion: drop deprecated systemd-efi-options from suggestions 2025-07-28 19:08:50 +01:00
Yu Watanabe
54820da421 bash-completion/analyze: show candidates for --debugger
This also adds missing completion for --debugger-arguments.

Follow-up for ad6e02e7b4.
2025-07-18 01:47:25 +09:00