qemu_swtpm: ConfigFeature
qemu_cdrom: bool
qemu_firmware: QemuFirmware
+ qemu_firmware_variables: Optional[Path]
qemu_kernel: Optional[Path]
qemu_drives: list[QemuDrive]
qemu_args: list[str]
help="Set qemu firmware to use",
choices=QemuFirmware.values(),
),
+ MkosiConfigSetting(
+ dest="qemu_firmware_variables",
+ metavar="PATH",
+ section="Host",
+ parse=config_make_path_parser(),
+ help="Set the path to the qemu firmware variables file to use",
+ ),
MkosiConfigSetting(
dest="qemu_kernel",
metavar="PATH",
QEMU Use Swtpm: {config.qemu_swtpm}
QEMU Use CD-ROM: {yes_no(config.qemu_cdrom)}
QEMU Firmware: {config.qemu_firmware}
+ QEMU Firmware Variables: {none_to_none(config.qemu_firmware_variables)}
QEMU Extra Arguments: {line_join_list(config.qemu_args)}
"""
notifications: dict[str, str] = {}
with contextlib.ExitStack() as stack:
- if firmware == QemuFirmware.uefi and ovmf_supports_sb:
+ if firmware == QemuFirmware.uefi:
ovmf_vars = stack.enter_context(tempfile.NamedTemporaryFile(prefix="mkosi-ovmf-vars"))
- shutil.copy2(find_ovmf_vars(config), Path(ovmf_vars.name))
+ shutil.copy2(config.qemu_firmware_variables or find_ovmf_vars(config), Path(ovmf_vars.name))
# Make sure qemu can access the ephemeral vars.
os.chown(ovmf_vars.name, INVOKING_USER.uid, INVOKING_USER.gid)
- cmdline += [
- "-global", "ICH9-LPC.disable_s3=1",
- "-global", "driver=cfi.pflash01,property=secure,value=on",
- "-drive", f"file={ovmf_vars.name},if=pflash,format=raw",
- ]
+ cmdline += ["-drive", f"file={ovmf_vars.name},if=pflash,format=raw"]
+ if ovmf_supports_sb:
+ cmdline += [
+ "-global", "ICH9-LPC.disable_s3=1",
+ "-global", "driver=cfi.pflash01,property=secure,value=on",
+ ]
if config.qemu_cdrom and config.output_format in (OutputFormat.disk, OutputFormat.esp):
# CD-ROM devices have sector size 2048 so we transform disk images into ones with sector size 2048.
`QemuFirmware=`, `--qemu-firmware=`
-: When used with the `qemu` verb, this option which firmware to use.
- Takes one of `uefi`, `bios`, `linux`, or `auto`. Defaults to `auto`.
- When set to `uefi`, the OVMF firmware is used. When set to `bios`, the
- default SeaBIOS firmware is used. When set to `linux`, direct kernel
- boot is used. See the `QemuKernel=` option for more details on which
- kernel image is used with direct kernel boot. When set to `auto`,
- `linux` is used if a cpio image is being booted, `uefi` otherwise.
+: When used with the `qemu` verb, this option specifies which firmware
+ to use. Takes one of `uefi`, `bios`, `linux`, or `auto`. Defaults to
+ `auto`. When set to `uefi`, the OVMF firmware is used. When set to
+ `bios`, the default SeaBIOS firmware is used. When set to `linux`,
+ direct kernel boot is used. See the `QemuKernel=` option for more
+ details on which kernel image is used with direct kernel boot. When
+ set to `auto`, `linux` is used if a cpio image is being booted, `uefi`
+ otherwise.
+
+`QemuFirmwareVariables=`, `--qemu-firmware-variables=`
+
+: When used with the `qemu` verb, this option specifies the path to the
+ the firmware variables file to use. Currently, this option is only
+ taken into account when the `uefi` firmware is used. If not specified,
+ mkosi will search for the default variables file and use that instead.
+
+: `virt-fw-vars` from the
+ [virt-firmware](https://gitlab.com/kraxel/virt-firmware) project can
+ be used to customize OVMF variable files.
`QemuKernel=`, `--qemu-kernel=`
}
],
"QemuFirmware": "linux",
+ "QemuFirmwareVariables": "/foo/bar",
"QemuGui": true,
"QemuKernel": null,
"QemuKvm": "auto",
qemu_cdrom = False,
qemu_drives = [QemuDrive("abc", 200, Path("/foo/bar"), "abc,qed"), QemuDrive("abc", 200, None, "")],
qemu_firmware = QemuFirmware.linux,
+ qemu_firmware_variables = Path("/foo/bar"),
qemu_gui = True,
qemu_kernel = None,
qemu_kvm = ConfigFeature.auto,