Skip to content

Commit

Permalink
Use KVM when running an x86 image on x86_64
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanDeMeyer committed Mar 13, 2024
1 parent b1df763 commit f92f3f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mkosi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ def supports_fw_cfg(self) -> bool:
def supports_smm(self) -> bool:
return self.is_x86_variant()

def can_kvm(self) -> bool:
return (
self == Architecture.native() or
(Architecture.native() == Architecture.x86_64 and self == Architecture.x86)
)

def default_qemu_machine(self) -> str:
m = {
Architecture.x86 : "q35",
Expand Down
2 changes: 1 addition & 1 deletion mkosi/qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def run_qemu(args: Args, config: Config) -> None:
elif config.runtime_network == Network.none:
cmdline += ["-nic", "none"]

if config.qemu_kvm != ConfigFeature.disabled and have_kvm and config.architecture.is_native():
if config.qemu_kvm != ConfigFeature.disabled and have_kvm and config.architecture.can_kvm():
accel = "kvm"
if qemu_version(config) >= QEMU_KVM_DEVICE_VERSION:
cmdline += ["--add-fd", f"fd={qemu_device_fds[QemuDeviceNode.kvm]},set=1,opaque=/dev/kvm"]
Expand Down

0 comments on commit f92f3f5

Please sign in to comment.