From: Lennart Poettering Date: Thu, 14 Apr 2022 15:52:55 +0000 (+0200) Subject: pid1: load 'qemu_fw_cfg' kmod super early, so that we can import credentials from it X-Git-Tag: v251-rc2~38^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c1d67af465ab6921beec3f864ffdf1670ca4e1e;p=thirdparty%2Fsystemd.git pid1: load 'qemu_fw_cfg' kmod super early, so that we can import credentials from it In one of the next commits we want to add support for importing system credentials from qemu_fw_cfg, very early during boot. (So that we can use the credentials therein for generators and even earlier). But that means udev won#t load these modules for us, we have to load them manually first. --- diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c index d054668b8ef..f4488dd6924 100644 --- a/src/core/kmod-setup.c +++ b/src/core/kmod-setup.c @@ -10,6 +10,7 @@ #include "macro.h" #include "recurse-dir.h" #include "string-util.h" +#include "virt.h" #if HAVE_KMOD #include "module-util.h" @@ -80,6 +81,10 @@ static bool has_virtio_rng(void) { return r > 0; } + +static bool in_qemu(void) { + return IN_SET(detect_vm(), VIRTUALIZATION_KVM, VIRTUALIZATION_QEMU); +} #endif int kmod_setup(void) { @@ -109,6 +114,9 @@ int kmod_setup(void) { #endif /* virtio_rng would be loaded by udev later, but real entropy might be needed very early */ { "virtio_rng", NULL, false, false, has_virtio_rng }, + + /* qemu_fw_cfg would be loaded by udev later, but we want to import credentials from it super early */ + { "qemu_fw_cfg", "/sys/firmware/qemu_fw_cfg", false, false, in_qemu }, }; _cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL; unsigned i;