From: Daan De Meyer Date: Fri, 1 Sep 2023 12:51:15 +0000 (+0200) Subject: Add QemuKernel= option X-Git-Tag: v16~22^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=139172b70ed7455bc8586eb1255624dfc49edbcc;p=thirdparty%2Fmkosi.git Add QemuKernel= option This allows specifying the kernel to use for direct kernel boot via an explicit option instead of having to rely on the QemuArgs= option. --- diff --git a/mkosi/config.py b/mkosi/config.py index a2c3e3733..2da833d8c 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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", diff --git a/mkosi/qemu.py b/mkosi/qemu.py index 52fcf6cf3..b6defb77e 100644 --- a/mkosi/qemu.py +++ b/mkosi/qemu.py @@ -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)] diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index f645fddb4..9f7af025b 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -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