On 5/3/25 02:21, Philippe Mathieu-Daudé wrote:
From: Alexander Graf <g...@amazon.com>

Apple defines a new "vmapple" machine type as part of its proprietary
macOS Virtualization.Framework vmm. This machine type is similar to the
virt one, but with subtle differences in base devices, a few special
vmapple device additions and a vastly different boot chain.

This patch reimplements this machine type in QEMU. To use it, you
have to have a readily installed version of macOS for VMApple,
run on macOS with -accel hvf, pass the Virtualization.Framework
boot rom (AVPBooter) in via -bios, pass the aux and root volume as pflash
and pass aux and root volume as virtio drives. In addition, you also
need to find the machine UUID and pass that as -M vmapple,uuid= parameter:

$ qemu-system-aarch64 -accel hvf -M vmapple,uuid=0x1234 -m 4G \
     -bios 
/System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin
     -drive file=aux,if=pflash,format=raw \
     -drive file=root,if=pflash,format=raw \
     -drive file=aux,if=none,id=aux,format=raw \
     -device vmapple-virtio-blk-pci,variant=aux,drive=aux \
     -drive file=root,if=none,id=root,format=raw \
     -device vmapple-virtio-blk-pci,variant=root,drive=root

With all these in place, you should be able to see macOS booting
successfully.

Known issues:
  - Currently only macOS 12 guests are supported. The boot process for
    13+ will need further investigation and adjustment.

Signed-off-by: Alexander Graf <g...@amazon.com>
Co-authored-by: Phil Dennis-Jordan <p...@philjordan.eu>
Signed-off-by: Phil Dennis-Jordan <p...@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.od...@daynix.com>
Tested-by: Akihiko Odaki <akihiko.od...@daynix.com>
Message-ID: <20241223221645.29911-15-p...@philjordan.eu>
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
  MAINTAINERS                 |   1 +
  docs/system/arm/vmapple.rst |  65 ++++
  docs/system/target-arm.rst  |   1 +
  hw/vmapple/vmapple.c        | 618 ++++++++++++++++++++++++++++++++++++
  contrib/vmapple/uuid.sh     |  12 +
  hw/vmapple/Kconfig          |  21 ++
  hw/vmapple/meson.build      |   1 +
  7 files changed, 719 insertions(+)
  create mode 100644 docs/system/arm/vmapple.rst
  create mode 100644 hw/vmapple/vmapple.c
  create mode 100755 contrib/vmapple/uuid.sh


+static void vmapple_machine_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->init = mach_vmapple_init;
+    mc->max_cpus = 32;
+    mc->block_default_type = IF_VIRTIO;
+    mc->no_cdrom = 1;
+    mc->pci_allow_0_address = true;
+    mc->minimum_page_bits = 12;
+    mc->possible_cpu_arch_ids = vmapple_possible_cpu_arch_ids;
+    mc->cpu_index_to_instance_props = vmapple_cpu_index_to_props;
+    mc->default_cpu_type = ARM_CPU_TYPE_NAME("host");

Not sure how I missed that earlier, but I'm now getting:

$ make check-qtest-aarch64
qemu-system-aarch64: The 'host' CPU type can only be used with KVM or HVF

+    mc->get_default_cpu_node_id = vmapple_get_default_cpu_node_id;
+    mc->default_ram_id = "mach-vmapple.ram";
+    mc->desc = "Apple aarch64 Virtual Machine";
+
+    compat_props_add(mc->compat_props, vmapple_compat_defaults,
+                     G_N_ELEMENTS(vmapple_compat_defaults));
+}


Reply via email to