Skip to content

Commit a5e798a

Browse files
author
neil
committed
fix for macos
1 parent ffe08e7 commit a5e798a

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

anyvm.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3023,7 +3023,10 @@ def find_image_link(releases, target_zst, target_xz):
30233023
if config['nc']:
30243024
net_card = config['nc']
30253025
else:
3026-
net_card = "e1000"
3026+
if config['arch'] == "aarch64":
3027+
net_card = "virtio-net-pci"
3028+
else:
3029+
net_card = "e1000"
30273030
if config['os'] == "openbsd" and config['release']:
30283031
release_base = config['release'].split('-')[0]
30293032
if release_base in OPENBSD_E1000_RELEASES:
@@ -3075,20 +3078,25 @@ def find_image_link(releases, target_zst, target_xz):
30753078
accel = "kvm"
30763079
else:
30773080
log("Warning: /dev/kvm exists but is not writable. Falling back to TCG.")
3078-
elif platform.system() == "Darwin" and hvf_supported():
3079-
accel = "hvf"
3081+
elif platform.system() == "Darwin":
3082+
# On Apple Silicon, HVF is available if we're on aarch64 host AND the system supports it
3083+
if host_arch == "aarch64" and hvf_supported():
3084+
accel = "hvf"
3085+
else:
3086+
# Intel Mac trying to run aarch64 -> TCG, or HVF not supported
3087+
accel = "tcg"
30803088

30813089
if config['cputype']:
30823090
cpu = config['cputype']
30833091
else:
3084-
cpu = "cortex-a72"
3085-
3086-
if accel == "kvm":
3087-
cpu = "host"
3092+
if accel in ["kvm", "hvf"]:
3093+
cpu = "host"
3094+
else:
3095+
cpu = "max"
30883096

3089-
vga_type = config['vga'] if config['vga'] else "virtio-gpu"
3090-
if vga_type == "virtio":
3091-
vga_type = "virtio-gpu"
3097+
vga_type = config['vga'] if config['vga'] else "virtio-gpu-pci"
3098+
if vga_type in ["virtio", "virtio-gpu"]:
3099+
vga_type = "virtio-gpu-pci"
30923100

30933101
args_qemu.extend([
30943102
"-machine", "virt,accel={},gic-version=3,usb=on".format(accel),
@@ -3229,7 +3237,11 @@ def find_image_link(releases, target_zst, target_xz):
32293237
disp = port - 5900
32303238
# Add audio support if the vnc driver is available
32313239
if check_qemu_audio_backend(qemu_bin, "vnc"):
3232-
args_qemu.extend(["-device", "intel-hda", "-device", "hda-duplex"])
3240+
if config['arch'] == "aarch64":
3241+
# Use usb-audio on aarch64 to avoid intel-hda driver issues
3242+
args_qemu.extend(["-device", "usb-audio,audiodev=vnc_audio"])
3243+
else:
3244+
args_qemu.extend(["-device", "intel-hda", "-device", "hda-duplex"])
32333245
args_qemu.extend(["-audiodev", "vnc,id=vnc_audio"])
32343246
args_qemu.append("-display")
32353247
args_qemu.append("vnc={}:{},audiodev=vnc_audio".format(addr, disp))

0 commit comments

Comments
 (0)