]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add QemuBios= option
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 13 Aug 2023 22:16:37 +0000 (00:16 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 21 Aug 2023 10:18:57 +0000 (12:18 +0200)
mkosi/config.py
mkosi/qemu.py
mkosi/resources/mkosi.md

index 5c13d11ea88fb6c54f11e156e0e30dd94c44fd67..63b08df02cc37d04f8696418ea52081ee95f46e1 100644 (file)
@@ -745,6 +745,7 @@ class MkosiConfig:
     qemu_vsock: ConfigFeature
     qemu_swtpm: ConfigFeature
     qemu_cdrom: bool
+    qemu_bios: bool
     qemu_args: Sequence[str]
 
     preset: Optional[str]
@@ -1492,6 +1493,14 @@ class MkosiConfigParser:
             parse=config_parse_boolean,
             help="Attach the image as a CD-ROM to the virtual machine",
         ),
+        MkosiConfigSetting(
+            dest="qemu_bios",
+            metavar="BOOLEAN",
+            nargs="?",
+            section="Host",
+            parse=config_parse_boolean,
+            help="Boot QEMU with SeaBIOS instead of EDK2",
+        ),
         MkosiConfigSetting(
             dest="qemu_args",
             metavar="ARGS",
@@ -2302,6 +2311,7 @@ Clean Package Manager Metadata: {yes_no_auto(config.clean_package_metadata)}
                 QEMU Use VSock: {config.qemu_vsock}
                 QEMU Use Swtpm: {config.qemu_swtpm}
                QEMU Use CD-ROM: {yes_no(config.qemu_cdrom)}
+                     QEMU BIOS: {yes_no(config.qemu_bios)}
           QEMU Extra Arguments: {line_join_list(config.qemu_args)}
 """
 
index e055aeb7e24da5b41031edfe735a2b87a3642004..4c6c10fea0effc2553524393374cbabfcb97cbe2 100644 (file)
@@ -212,7 +212,7 @@ def run_qemu(args: MkosiArgs, config: MkosiConfig) -> None:
         accel = "kvm"
 
     firmware, fw_supports_sb = find_qemu_firmware(config)
-    smm = "on" if fw_supports_sb else "off"
+    smm = "on" if fw_supports_sb and not config.qemu_bios else "off"
 
     if config.architecture == Architecture.arm64:
         machine = f"type=virt,accel={accel}"
@@ -253,12 +253,14 @@ def run_qemu(args: MkosiArgs, config: MkosiConfig) -> None:
         cmdline += ["-smbios", f"type=11,value=io.systemd.credential.binary:{k}={base64.b64encode(v.encode()).decode()}"]
     cmdline += ["-smbios", f"type=11,value=io.systemd.stub.kernel-cmdline-extra={' '.join(config.kernel_command_line_extra)}"]
 
-    cmdline += ["-drive", f"if=pflash,format=raw,readonly=on,file={firmware}"]
+    # QEMU has built-in logic to look for the BIOS firmware so we don't need to do anything special for that.
+    if not config.qemu_bios:
+        cmdline += ["-drive", f"if=pflash,format=raw,readonly=on,file={firmware}"]
 
     notifications: dict[str, str] = {}
 
     with contextlib.ExitStack() as stack:
-        if fw_supports_sb:
+        if fw_supports_sb and not config.qemu_bios:
             ovmf_vars = stack.enter_context(tempfile.NamedTemporaryFile(prefix=".mkosi-"))
             shutil.copy2(find_ovmf_vars(config), Path(ovmf_vars.name))
             cmdline += [
@@ -309,7 +311,7 @@ def run_qemu(args: MkosiArgs, config: MkosiConfig) -> None:
                     "-device", "virtio-scsi-pci,id=scsi",
                     "-device", f"scsi-{'cd' if config.qemu_cdrom else 'hd'},drive=mkosi,bootindex=1"]
 
-        if config.qemu_swtpm != ConfigFeature.disabled and shutil.which("swtpm") is not None:
+        if config.qemu_swtpm != ConfigFeature.disabled and shutil.which("swtpm") is not None and not config.qemu_bios:
             sock = stack.enter_context(start_swtpm())
             cmdline += ["-chardev", f"socket,id=chrtpm,path={sock}",
                         "-tpmdev", "emulator,id=tpm0,chardev=chrtpm"]
index 2d9706310259c0c685fada866918edb7c12d101e..abca87ff9d9967e321f4c47e114aeb26087460a7 100644 (file)
@@ -1004,6 +1004,12 @@ they should be specified with a boolean argument: either "1", "yes", or "true" t
   attach the image to the virtual machine as a CD-ROM device. Takes a
   boolean. Defaults to `no`.
 
+`QemuBios=`, `--qemu-bios=`
+
+: When used with the `qemu` verb, this option specifies whether to use
+  the BIOS firmware instead of the UEFI firmware. Takes a boolean.
+  Defaults to `no`.
+
 `QemuArgs=`
 
 : Space-delimited list of additional arguments to pass when invoking