Split the QEMU configs by host system and architecture

Replace qemu/<guest>-<arch>.ini with qemu/<guest>-<os>-<arch>.ini, where os is
linux or darwin, the name platform.system() reports. The accelerators move out
of the shared <guest>.ini into these files (KVM on Linux, HVF on macOS, TCG as
the fallback). The launchers pick the file from the host system and
architecture, and reject amd64 guests on macOS hosts, so no darwin-amd64 files
exist.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
GuofangandClaude Sonnet 5.5 committed 2026-10-17 15:05:02 +08:00
1 parent c13ebc7d11
commit fd1d9d651d
24 files changed
+234 -96

No files matched your search

+7 -4
View File
@@ -79,7 +79,10 @@ def normalize_arch(arch):
host_arch = normalize_arch(env("VM_IMAGE_ARCH") or platform.machine())
qemu_binary = "qemu-system-aarch64" if host_arch == "arm64" else "qemu-system-x86_64"
qemu_arch_config = script_dir / "qemu" / f"windows11-{host_arch}.ini"
host_os = platform.system().lower()
if host_os == "darwin" and host_arch == "amd64":
die("amd64 guests are not supported on macOS hosts; use an arm64 image")
qemu_platform_config = script_dir / "qemu" / f"windows11-{host_os}-{host_arch}.ini"
def pick_firmware(override, *candidates):
@@ -136,7 +139,7 @@ If the system disk (DIR/disk.qcow2, see --state-dir) is missing, create it from
the Windows 11 QCOW2 base image.
The VM hardware (accelerator, memory, CPUs, drives, devices) is defined in
qemu/windows11.ini, which is rendered to qemu.ini in the state directory and
loaded with QEMU's -readconfig, followed by qemu/windows11-<arch>.ini (amd64 or arm64, chosen from the host
loaded with QEMU's -readconfig, followed by qemu/windows11-<os>-<arch>.ini (os is linux or darwin, arch is amd64 or arm64, chosen from the host system and
architecture or VM_IMAGE_ARCH). Later QEMU arguments override them, e.g. -- -m 4G -smp 4.
Use --install-from-iso to perform an automatic ISO installation instead.
If it exists, start Windows normally without attaching installation media.
@@ -327,7 +330,7 @@ for key, value in config_values.items():
# QEMU's config file parser has no escape syntax for quoted values.
if any(char in str(value) for char in '"\n'):
die(f"{key} must not contain double quotes or newlines: {value}")
for config_file in (qemu_config_template, qemu_arch_config):
for config_file in (qemu_config_template, qemu_platform_config):
if not config_file.is_file():
die(f"QEMU config file was not found: {config_file}")
try:
@@ -352,7 +355,7 @@ for label, host_port, guest_port in (("RDP", rdp_port, 3389), ("SSH", ssh_port,
qemu_args = [
"-readconfig", str(qemu_config),
"-readconfig", str(qemu_arch_config),
"-readconfig", str(qemu_platform_config),
# "max" is the host CPU under KVM/HVF and the fullest model under TCG.
"-cpu", "max",
# A config file section cannot hold two hostfwd entries, so the network