]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: load 'qemu_fw_cfg' kmod super early, so that we can import credentials from it
authorLennart Poettering <lennart@poettering.net>
Thu, 14 Apr 2022 15:52:55 +0000 (17:52 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 28 Apr 2022 15:54:14 +0000 (17:54 +0200)
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.

src/core/kmod-setup.c

index d054668b8ef5f0f71b42079a5b74069f9f402ddd..f4488dd6924151e2ae8bfc420b6a0f36b89a2f71 100644 (file)
@@ -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;