]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add QemuKernel= option
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 1 Sep 2023 12:51:15 +0000 (14:51 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 1 Sep 2023 14:03:56 +0000 (16:03 +0200)
This allows specifying the kernel to use for direct kernel boot
via an explicit option instead of having to rely on the QemuArgs=
option.

mkosi/config.py
mkosi/qemu.py
mkosi/resources/mkosi.md

index a2c3e3733cfe97ed82a8924d1ec567e85e612f1c..2da833d8cf9b7db72977a5efb416096b9e029bf7 100644 (file)
@@ -731,6 +731,7 @@ class MkosiConfig:
     qemu_swtpm: ConfigFeature
     qemu_cdrom: bool
     qemu_firmware: QemuFirmware
+    qemu_kernel: Optional[Path]
     qemu_args: Sequence[str]
 
     preset: Optional[str]
@@ -1581,6 +1582,13 @@ SETTINGS = (
         help="Set qemu firmware to use",
         choices=QemuFirmware.values(),
     ),
+    MkosiConfigSetting(
+        dest="qemu_kernel",
+        metavar="PATH",
+        section="Host",
+        parse=config_make_path_parser(),
+        help="Specify the kernel to use for qemu direct kernel boot",
+    ),
     MkosiConfigSetting(
         dest="qemu_args",
         metavar="ARGS",
index 52fcf6cf3b9f08e0b6c03d2f1089df91c85c1624..b6defb77e61213439a59cb23e8bfa42db13f9356 100644 (file)
@@ -305,11 +305,16 @@ def run_qemu(args: MkosiArgs, config: MkosiConfig) -> None:
                  fname])
 
         if config.qemu_firmware == QemuFirmware.direct or config.output_format == OutputFormat.cpio:
-            if "-kernel" not in args.cmdline:
+            if config.qemu_kernel:
+                kernel = config.qemu_kernel
+            elif "-kernel" not in args.cmdline:
                 kernel = config.output_dir / config.output_split_kernel
                 if not kernel.exists():
                     die("No kernel found, please install a kernel in the image or provide a -kernel argument to mkosi qemu")
+            else:
+                kernel = None
 
+            if kernel:
                 cmdline += ["-kernel", kernel]
 
             cmdline += ["-append", " ".join(config.kernel_command_line + config.kernel_command_line_extra)]
index f645fddb439e93744010e6402a011b71e8b6490a..9f7af025b75fea7482156fc687d3c3670d957917 100644 (file)
@@ -1053,10 +1053,15 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
   Takes one of `uefi`, `bios` or `direct`. Defaults to `uefi`. When set
   to `uefi`, the OVMF firmware is used. When set to `bios`, the default
   SeaBIOS firmware is used. When set to `direct`, direct kernel boot is
-  used. The kernel used for direct kernel boot can either be provided by
-  passing qemu's `-kernel` option on the mkosi command line or by
-  installing a kernel into the image, in which case it will be picked up
-  automatically.
+  used. See the `QemuKernel=` option for more details on which kernel
+  image is used with direct kernel boot.
+
+`QemuKernel=`, `--qemu-kernel=`
+
+: Set the kernel image to use for qemu direct kernel boot. If not
+  specified, mkosi will use the kernel provided via the command line
+  (`-kernel` option) or latest the kernel that was installed into
+  the image (or fail if no kernel was installed into the image).
 
 : Note that when the `cpio` output format is used, direct kernel boot is
   used regardless of the configured firmware. Depending on the