Daan De Meyer [Tue, 28 May 2024 13:21:55 +0000 (15:21 +0200)]
Pass arguments that look like env variables as env to systemd-nspawn
The kernel passes unknown parameters as environment variables to pid1.
Let's do the same for systemd-nspawn. Of course we don't know what is
known and unknown so let's take advantage of the fact that kernel cmdline
arguments are (usually) lower case and environment variables are (usually)
upper case and use that to determine whether to pass something as an argument
or an environment variable.
bwrap is used for many many different things, so I just added a blanket
check that requires is to be always required if use any of the verbs that
call check_tools().
Daan De Meyer [Fri, 17 May 2024 11:32:54 +0000 (13:32 +0200)]
mkosi-initrd: Don't remove sanitizer libraries from initrd
Let's not unconditionally remove sanitizer libraries and their
dependencies from the initrd as it turns out running software with
sanitizers in the initrd isn't that far fetched.
Jörg Behrmann [Tue, 14 May 2024 13:20:35 +0000 (15:20 +0200)]
Don't die when images already exist
We already check whether outputs exist when looping over all image configs and
skip the build if the output exists. This way one can just "mkosi build" after
adding a new image and the missing ones will be built.
Daan De Meyer [Tue, 14 May 2024 10:36:38 +0000 (12:36 +0200)]
Drop check for workspace directory relative to cwd
The current working directory check is only relevant if the current
working directory is used as a build source, which means it's also
handled by the second check so let's drop it.
Daan De Meyer [Sun, 12 May 2024 14:01:06 +0000 (16:01 +0200)]
Add optional file ID for qemu drives
For testing multipath in systemd's integration tests, we need multiple
qemu drives backed by the same file. Let's allow specifying an additional
file ID to make this possible with QemuDrive=.
Daan De Meyer [Fri, 10 May 2024 10:55:23 +0000 (12:55 +0200)]
Chroot for depmod and modinfo
modinfo cannot always work with output from newer or different depmod.
Specifically, this fixes the case where modinfo sch_fq_codel fails with
"module not found" on CentOS Stream 9 images built from Fedora 40. When
depmod from Fedora 40 is used, modinfo in the image fails with "module
not found". When depmod from inside the image is used, modinfo succeeds
as expected.
We'd rather not do this but in this case there's no other option.
Daan De Meyer [Fri, 10 May 2024 09:27:50 +0000 (11:27 +0200)]
Only run configure scripts for verbs that need a build
In systemd, we want to use configure scripts to determine whether
qemu was built with support for specific devices and skip running
a test if it wasn't, or otherwise add the device to the qemu arguments.
To make this work, we need to run the configure scripts with the
default tools tree available if one is configured.
Let's change the behavior of configure scripts to only run for verbs
that need a build and run them after building the default tools tree
so that they can be run with the tools tree mounted.
Daan De Meyer [Wed, 8 May 2024 12:41:06 +0000 (14:41 +0200)]
Only use a single default tools tree per build
Currently, if multiple images are defined, each with a default tools
tree, if they use the same distribution, all the various ToolsTreeXXX=
settings for the later images will be ignored since we'll only build
one tools tree.
Also, if any of the images set Incremental=no, we will remove the default
tools tree outputs even if Incremental=yes is enabled for other images.
To keep ourselves sane, let's avoid dealing with multiple defaults tools
trees and only look at the last image to figure out whether we should
build a default tools tree and what to put in it.
Allow the update command to continue downloading data from a repository which changed its information of the release contained in the repository indicating e.g a new major release. APT will fail at the update command for such repositories until the change is confirmed to ensure the user is prepared for the change.
Jörg Behrmann [Tue, 7 May 2024 15:24:52 +0000 (17:24 +0200)]
doc: move [Match] and [Config] section further down
Both topics are more advanced and since the entries in the [Match] section have
the same names as the the things they match, they are the first hit when
searching the document.
Daan De Meyer [Mon, 6 May 2024 15:11:21 +0000 (17:11 +0200)]
Be more conservative in what we copy from package directories
Let's make sure we only copy packages from package directories so
that PackageDirectories= can be pointed at a directory containing
more than just packages without copying everything.
Daan De Meyer [Mon, 6 May 2024 07:05:40 +0000 (09:05 +0200)]
Don't use scopes for virtiofs when using older unshare
unshare 2.37 is still shipped in Ubuntu Jammy and CentOS Stream 9
which doesn't have --map-users= and --map-groups=. In this case, let's
not use scopes for virtiofsd to make sure that booting using virtiofsd
still works.
Also add a missing preexec_fn to become root if we're not using a scope.
To make this work we have to move all the logic to decide whether we use
a scope or not outside of run() as we need to conditionalize other arguments
we provide to run() based on whether we use a scope or not.
--map-users= and --map-groups= were added in util-linux 2.38 but
Ubuntu 22.04 and CentOS Stream 9 only ships util-linux 2.37 so
let's at least make sure --ephemeral keeps working on those
distributions.
Daan De Meyer [Fri, 3 May 2024 21:33:58 +0000 (23:33 +0200)]
qemu: Use systemd-run to allocate scopes
This doesn't drastically change behavior, but will open the way for
adding a RuntimeProperties= setting to allow configuring various
properties of the scope unit.
Since allocating a scope with systemd-run involves communicating with
a daemon running on the host, there's no point in running it from the
sandbox so we run it from the host instead.
Because systemd-run needs to run as the uid that started mkosi, we can't
use preexec_fn anymore to allocate the user namespace for virtiofsd.
Instead, we reimplement what become_root() does on top of unshare and
chain execute into that which then itself chain executes virtiofsd.
Daan De Meyer [Fri, 3 May 2024 14:24:50 +0000 (16:24 +0200)]
qemu: Configure caching properly
For the scratch device, we can use unsafe caching as it's thrown
away immediately after the machine shuts down. For the root disk,
we can use unsafe caching only if --ephemeral is enabled.
The default home directory for system users created with sysusers.d is /.
Which will automatically be mounted inside sync scripts, causing a lot of
headaches, since we're essentially trying to run on the host then.
E.g. /proxy.cacert cannot be created.
Don't look in --extra-search-paths for qemu and virt-fw-vars
These take as input a file that might be in or out of the tools tree.
Because find_ovmf_firmware() will return a file in the tools tree
regardless of whether virt-fw-vars and qemu will be executed on the
host or not, let's disable the --extra-search-paths= integration for
these two for now.
Tobias Fleig [Tue, 26 Mar 2024 12:46:00 +0000 (05:46 -0700)]
Call ukify with --ucode if supported
This is the companion change to https://github.com/systemd/systemd/pull/31872.
If both systemd-stub and ukify are version `256~devel` or greater, mkosi
will put the microcode initrd in the new `.ucode` UKI section by using
the `--ucode` flag in ukify. Otherwise it will put the microcode initrd
as first regular initrd (same as before).
In systemd we want to (optionally) make sure all mkosi output is
written to the meson build directory. To make this work, we want to
write a mkosi.conf to the meson build directory so that developers
can do "mkosi -C build". Currently this doesn't work because "build"
is interpreted as a verb. Let's make sure that doesn't happen.
We need a better solution for this hack but for now this is the best
I can come up with.
Don't build the image automatically for boot/qemu verbs without --force
Let's insist on --force to build the image if boot/qemu are used to
give users an easy way to insist that an image has already been built
when booting it.
mkosi might be invoked from a terminal but redirected to a file, in
that case we should ignore $TERM from the environment, so let's make
sure we handle that properly.
Let's make sure the limits are configured so we can always write at
least 4G of logs. We also enable compact mode again in all cases to
reduce the size used by journal files as for example Github Actions
machines aren't exactly swimming in free space.
(We pick 4G because that's the max journal file size when the compact
mode is used)
(We'll probably have to revisit this again at some point but for now
this should do the trick)
We want to support users writing to these directories from the host
so --cache=always is not an option as that assumes virtiofsd has
exclusive write access.
If we find a binary in any path configured with ExtraSearchPaths=,
we prefer using it over the tools tree.
This commit also gets rid of all the find_binary() for "btrfs" in
tree.py and stops passing in the tools tree to those functions.
Instead, we rely on the new behavior of run() to not fail hard
when check=False and the btrfs binary is not found.