Jump to content

kode54

kode54

Member Since 20 Jul 2011
Offline Last Active Private
-----

Posts I've Made

In Topic: Insanely fast virtual Mac (QEMU, OVMF, Clover and native graphics)

10 February 2018 - 07:06 AM

I managed to get it working, both with the distribution stock OVMF and the repository supplied OVMF. The issue with that was replacing the VARS image with the one matching the correct CODE image, or else it wouldn't boot at all.

 

My XML:

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <name>macOS High Sierra</name>
  <uuid>420e255f-cd8c-4938-a9a5-6d0d423c0d57</uuid>
  <memory unit='KiB'>16777216</memory>
  <currentMemory unit='KiB'>16777216</currentMemory>
  <memoryBacking>
    <hugepages/>
  </memoryBacking>
  <vcpu placement='static'>8</vcpu>
  <os>
    <type arch='x86_64' machine='pc-q35-2.10'>hvm</type>
    <loader readonly='yes' type='pflash'>/var/lib/libvirt/images/OVMF_CODE-pure-efi.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/macOS_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>Penryn</model>
    <topology sockets='1' cores='4' threads='2'/>
    <feature policy='require' name='invtsc'/>
    <feature policy='require' name='aes'/>
    <feature policy='require' name='xsave'/>
    <feature policy='require' name='avx'/>
    <feature policy='require' name='xsaveopt'/>
    <feature policy='require' name='smep'/>
  </cpu>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/clover.qcow2'/>
      <target dev='hda' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/mac_hdd.qcow2'/>
      <target dev='hdb' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0' model='piix3-uhci'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
    </controller>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'/>
    <controller type='pci' index='1' model='dmi-to-pci-bridge'>
      <model name='i82801b11-bridge'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
    </controller>
    <controller type='pci' index='2' model='pci-bridge'>
      <model name='pci-bridge'/>
      <target chassisNr='2'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </controller>
    <controller type='pci' index='3' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='3' port='0x10'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
    </controller>
    <controller type='pci' index='4' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='4' port='0x11'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
    </controller>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x14' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x1a' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x1d' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/>
    </hostdev>
    <memballoon model='none'/>
  </devices>
  <qemu:commandline>
    <qemu:arg value='-device'/>
    <qemu:arg value='isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc'/>
    <qemu:arg value='-smbios'/>
    <qemu:arg value='type=2'/>
    <qemu:arg value='-cpu'/>
    <qemu:arg value='Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+aes,+xsave,+avx,+xsaveopt,+smep'/>
  </qemu:commandline>
</domain>

Note the overriding CPU flags. I also had to leave out AVX2, since my CPU doesn't support that.

 

It boots, it gets past hardware enumeration if I set Clover to boot in verbose mode, but when it gets to loading the hardware drivers, it fails to attach either my display or my USB interfaces, leaving them in a seemingly detached state. The displays shut off, the USB mouse disconnects, but my USB keyboard appears to recognize caps lock and toggles its state LED. There doesn't appear to be much I can do with the machine at that point.

 

E: I managed to get it to boot, by configuring Clover with Graphics > RadeonDeInit, but now I have stuttering audio that I did not experience under my Windows VM. I assume that this stupid thing is too sensitive and needs CPU core isolation, which is total bullpucky.

In Topic: Insanely fast virtual Mac (QEMU, OVMF, Clover and native graphics)

07 February 2018 - 02:23 AM

I have created a 10.13.3 install image, and installed to a 128GiB qcow2 image, using the Kholia/OSX-KVM boot-macOS-HS.sh script, doctored to use a bridge network interface, but I can't boot with a passthrough, and the libvirt image doesn't want to boot, either.

 

The script I used:

#!/bin/bash

MY_OPTIONS="+aes,+xsave,+avx,+xsaveopt,+smep"

qemu-system-x86_64 -enable-kvm -m 3072 -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,$MY_OPTIONS\
          -machine pc-q35-2.9 \
          -smp 4,cores=2 \
          -usb -device usb-kbd -device usb-tablet \
          -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
          -drive if=pflash,format=raw,readonly,file=OVMF_CODE-pure-efi.fd \
          -drive if=pflash,format=raw,file=OVMF_VARS-pure-efi-1024x768.fd \
          -smbios type=2 \
          -device ich9-intel-hda -device hda-duplex \
          -device ide-drive,bus=ide.2,drive=Clover \
          -drive id=Clover,if=none,snapshot=on,format=qcow2,file=./'Clover.qcow2' \
          -device ide-drive,bus=ide.1,drive=MacHDD \
          -drive id=MacHDD,if=none,file=./mac_hdd.img,format=qcow2 \
          -device ide-drive,bus=ide.0,drive=MacDVD \
          -drive id=MacDVD,if=none,snapshot=on,media=cdrom,file=./'HighSierra-10.13.3.iso' \
          -netdev bridge,id=net0,br=br0,"helper=/usr/lib/qemu/qemu-bridge-helper" -device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \
          -monitor stdio

The boot-passthrough.sh script, doctored to pass in my AMD RX 480, 01:00.0 and 01:00.1, and my USB interfaces, 00:14.0 00:1a.0 and 00:1d.0, using separate device lines, fails:

qemu-system-x86_64: -device vfio-pci,host=01:00.0: vfio: error opening /dev/vfio/1: No such file or directory

The non-working boot-passthrough.sh script I produced:

#!/bin/bash


qemu-system-x86_64 -enable-kvm -m 16384 -mem-prealloc -mem-path /dev/hugepages/macos -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on \
          -machine pc-q35-2.9 \
          -smp 8,cores=4 \
          -vga none \
          -device vfio-pci,host=01:00.0,id=hostdev0,bus=pcie.0,multifunction=on \
          -device vfio-pci,host=01:00.1,id=hostdev1,bus=pcie.0 \
          -device vfio-pci,host=00:14.0,id=hostdev2,bus=pcie.0 \
          -device vfio-pci,host=00:1d.0,id=hostdev3,bus=pcie.0 \
          -device vfio-pci,host=00:1a.0,id=hostdev4,bus=pcie.0 \
          -usb -device usb-kbd -device usb-tablet \
          -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
          -drive if=pflash,format=raw,readonly,file=OVMF_CODE-pure-efi.fd \
          -drive if=pflash,format=raw,file=OVMF_VARS-pure-efi-1024x768.fd \
          -smbios type=2 \
          -device ide-drive,bus=ide.2,drive=MacHDD \
          -drive id=MacHDD,if=none,file=./mac_hdd.img \
          -netdev bridge,id=net0,br=br0,"helper=/usr/lib/qemu/qemu-bridge-helper" -device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \
          -monitor stdio

And the libvirt script fails to boot it. I modified it to use 4 core, 8 thread, host CPU (i7 3770), no virtual graphics, passing through all of the devices mentioned above, and it simply boots to the Tianocore logo, spinning all 8 threads, then eventually getting stuck spinning only one core, without actually hitting Clover.

 

I notice the libvirt scripts have been updated, but the boot-passthrough.sh script hasn't been updated in a few months.

 

I would prefer to get this working with the libvirt method, as that's what I use to maintain my other virtual machines, including automatic startup on system boot, and automatic shutdown on host reboot or shutdown.

© 2017 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy