@@ -47,7 +47,7 @@ def __init__(self, xtarget: CrossCompileTarget, want_debugger=False) -> None:
47
47
self .memory_size = "2048"
48
48
self .has_default_nic = False
49
49
if xtarget .is_hybrid_or_purecap_cheri ([CPUArchitecture .AARCH64 ]):
50
- self .qemu_arch_sufffix = "morello"
50
+ self ._qemu_arch_suffix = "morello"
51
51
self .can_boot_kernel_directly = False # boot from disk
52
52
# XXX: Use a CHERI-aware firmware. EL3 is disabled by default for
53
53
# virt, so CPTR_EL3 doesn't exist and CheriBSD can enable
@@ -56,19 +56,19 @@ def __init__(self, xtarget: CrossCompileTarget, want_debugger=False) -> None:
56
56
self .machine_flags = ["-M" , "virt,gic-version=3" , "-cpu" , "morello" , "-bios" , "edk2-aarch64-code.fd" ]
57
57
elif xtarget .is_mips (include_purecap = True ):
58
58
# Note: we always use the CHERI QEMU
59
- self .qemu_arch_sufffix = "mips64cheri128"
59
+ self ._qemu_arch_suffix = "mips64cheri128"
60
60
self .machine_flags = ["-M" , "malta" ]
61
61
self .virtio_disk = False # broken for MIPS?
62
62
self .can_boot_kernel_directly = True
63
63
self .has_default_nic = True # MALTA board has a default pcnet at 0x0b
64
64
elif xtarget .is_riscv (include_purecap = True ):
65
65
# Note: we always use the CHERI QEMU
66
- self .qemu_arch_sufffix = "riscv32cheri" if xtarget .is_riscv32 (include_purecap = True ) else "riscv64cheri"
66
+ self ._qemu_arch_suffix = "riscv32cheri" if xtarget .is_riscv32 (include_purecap = True ) else "riscv64cheri"
67
67
self .machine_flags = ["-M" , "virt" ]
68
68
self .can_boot_kernel_directly = True
69
69
elif xtarget .is_any_x86 ():
70
70
# We boot i386 FreeBSD in a x86_64 QEMU. This avoids having to build another version of QEMU.
71
- self .qemu_arch_sufffix = "x86_64"
71
+ self ._qemu_arch_suffix = "x86_64"
72
72
self .can_boot_kernel_directly = False # boot from disk
73
73
# Try to use KVM instead of TCG if possible to speed up emulation
74
74
if not want_debugger :
@@ -83,11 +83,11 @@ def __init__(self, xtarget: CrossCompileTarget, want_debugger=False) -> None:
83
83
# We have to use the ancient default instead to avoid kernel panics.
84
84
# See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253617 for details.
85
85
elif xtarget .is_aarch64 (include_purecap = False ):
86
- self .qemu_arch_sufffix = "aarch64"
86
+ self ._qemu_arch_suffix = "aarch64"
87
87
self .can_boot_kernel_directly = False # boot from disk
88
88
self .machine_flags = ["-M" , "virt,gic-version=3" , "-cpu" , "cortex-a72" , "-bios" , "edk2-aarch64-code.fd" ]
89
89
elif xtarget .is_arm32 (include_purecap = False ):
90
- self .qemu_arch_sufffix = "arm"
90
+ self ._qemu_arch_suffix = "arm"
91
91
self .can_boot_kernel_directly = False # boot from disk
92
92
self .machine_flags = ["-M" , "virt" , "-cpu" , "cortex-15" ]
93
93
else :
@@ -156,9 +156,15 @@ def user_network_args(self, extra_options) -> "list[str]":
156
156
network_device_kind = self ._qemu_network_config ()[0 ]
157
157
return ["-device" , network_device_kind + ",netdev=net0" , "-netdev" , "user,id=net0" + extra_options ]
158
158
159
- def get_qemu_binary (self ) -> "Optional[Path]" :
160
- found_in_path = shutil .which ("qemu-system-" + self .qemu_arch_sufffix )
161
- return Path (found_in_path ) if found_in_path is not None else None
159
+ def get_qemu_binary (self , search_dirs : "Optional[list[Path]]" = None ) -> "Optional[Path]" :
160
+ if search_dirs is None :
161
+ found_in_path = shutil .which ("qemu-system-" + self ._qemu_arch_suffix )
162
+ return Path (found_in_path ) if found_in_path is not None else None
163
+ for d in search_dirs :
164
+ candidate = d / f"qemu-system-{ self ._qemu_arch_suffix } "
165
+ if candidate .exists ():
166
+ return candidate
167
+ return None
162
168
163
169
def get_commandline (
164
170
self ,
0 commit comments