foxlet / macOS-Simple-KVM

Tools to set up a quick macOS VM in QEMU, accelerated by KVM.
13.55k stars 1.14k forks source link

Centos 7 install goes to Shell instead of boot #110

Open emilorol opened 4 years ago

emilorol commented 4 years ago

I am trying to run this project in Centos 7 and I modified the basic script as need it:

#!/bin/bash

OSK="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VMDIR=$PWD
OVMF=$VMDIR/firmware
#export QEMU_AUDIO_DRV=pa
#QEMU_AUDIO_DRV=pa

qemu-system-x86_64 \
    -enable-kvm \
    -m 2048 \
    -machine pc,accel=kvm \
    -smp 4,cores=2 \
    -cpu Penryn,vendor=GenuineIntel,+sse3,+sse4.2,+aes,+xsave,+avx,+avx2,+bmi2,+smep,+bmi1,+fma,+movbe \
    -device isa-applesmc,osk="$OSK" \
    -smbios type=0 \
    -drive if=pflash,format=raw,readonly,file="$OVMF/OVMF_CODE.fd" \
    -drive if=pflash,format=raw,file="$OVMF/OVMF_VARS-1024x768.fd" \
    -vga qxl \
    -device ich9-intel-hda -device hda-output \
    -usb -device usb-kbd -device usb-mouse \
    -netdev user,id=net0 \
    -device e1000,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \
    -device ich9-ahci,id=sata \
    -drive id=ESP,if=none,format=qcow2,file=ESP.qcow2 \
    -device ide-hd,bus=sata.2,drive=ESP \
    -drive id=InstallMedia,format=raw,if=none,file=BaseSystem.img \
    -device ide-hd,bus=sata.3,drive=InstallMedia \
    -drive id=SystemDisk,if=none,file=OSX.img \
    -device ide-hd,bus=sata.4,drive=SystemDisk \

And QEMU start, but instead of booting it goes to the UEFI Interactive Shell and I don't know what command to run from there. I don't know if I am missing something on the process either.

qemu

kentinchen commented 4 years ago

I have same problem,follow is my start shell

!/bin/bash

OSK="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" VMDIR=$PWD OVMF=$VMDIR/firmware

export QEMU_AUDIO_DRV=pa

QEMU_AUDIO_DRV=pa

qemu-system-x86_64 \ -enable-kvm \ -m 2G \ -machine q35,accel=kvm \ -smp 4,cores=2 \ -cpu Penryn,vendor=GenuineIntel,+sse3,+sse4.2,+aes,+xsave,+avx,+xsaveopt,+xsavec,+xgetbv1,+avx2,+bmi2,+smep,+bmi1,+fma,+movbe,+invtsc \ -device isa-applesmc,osk="$OSK" \ -drive if=pflash,format=raw,readonly,file="$OVMF/OVMF_CODE.fd" \ -drive if=pflash,format=raw,file="$OVMF/OVMF_VARS-1024x768.fd" \ -vga qxl \ -device ich9-intel-hda -device hda-output \ -usb -device usb-kbd -device usb-mouse \ -netdev user,id=net0 \ -device e1000,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \ -device ich9-ahci,id=sata \ -drive id=ESP,if=none,format=qcow2,file=ESP.qcow2 \ -device ide-hd,bus=sata.2,drive=ESP \ -drive id=InstallMedia,format=raw,if=none,file=BaseSystem.img \ -device ide-hd,bus=sata.3,drive=InstallMedia \ -drive id=SystemDisk,if=none,file=Mac.qcow2 \ -device ide-hd,bus=sata.4,drive=SystemDisk \

I had remove CPU parameter "kvm=on", and delete row "-smbios type=2 \"

kentinchen commented 4 years ago

qemu-system-x86_64: Property '.kvm' not qemu-system-x86_64: -smbios type=2: Don't know how to build fields for SMBIOS type 2 qemu-system-x86-2.0.0-1.el7.6.x86_64, is need update qemu-system?

emilorol commented 4 years ago

I tried upgrading the qemu-ev without luck and it seems the BIOS is super important. Did you got it to boot or did you get the same error as I?

kentinchen commented 4 years ago

My computer still can't boot mac, my computer is HP Gen8 Micro Server,CPU is E3-1230V2,video card is nvidia GTX 740.

laramy2020 commented 4 years ago

I got everything but mouse and full keyboard support on centos 7.7 and the ovirt 4.3 repo for libvirt still using qemu 2.0.0. A lot of the work was moving the qemu commands to libvirt. Some how libvirt understands them but the older qemu does not. Because of that i can not install Catalina. Any more suggestions. I am about to test the installed image i have from arch. but i would like the installer to work for future centos users


<domain type='kvm' id='219'>
  <name>MacOS-Simple-KVM</name>
  <uuid>6877664a-44e6-4a14-a335-d1a21a69ce3e</uuid>
  <title></title>
  <memory unit='KiB'>8388608</memory>
  <currentMemory unit='KiB'>8388608</currentMemory>
  <vcpu placement='static'>6</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-q35-rhel7.3.0'>hvm</type>
    <loader readonly='yes' type='pflash'>/var/lib/libvirt/MiscStorage/macOS-Simple-KVM-master/firmware/OVMF_CODE.fd</loader>
    <nvram>/var/lib/libvirt/MiscStorage/macOS-Simple-KVM-master/firmware/OVMF_VARS-1024x768.fd</nvram>
    <bootmenu enable='yes'/>
  </os>
  <features>
    <acpi/>
    <hyperv>
      <relaxed state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='whatever'/>
    </hyperv>
    <kvm>
      <hidden state='on'/>
    </kvm>
    <vmport state='off'/>
  </features>
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>Penryn</model>
    <vendor>Intel</vendor>
    <topology sockets='1' cores='3' threads='2'/>
    <feature policy='require' name='vme'/>
    <feature policy='require' name='ss'/>
    <feature policy='require' name='f16c'/>
    <feature policy='require' name='rdrand'/>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='arat'/>
    <feature policy='require' name='tsc_adjust'/>
    <feature policy='require' name='xsaveopt'/>
    <feature policy='require' name='pdpe1gb'/>
    <feature policy='require' name='abm'/>
    <feature policy='require' name='invtsc'/>
    <feature policy='require' name='x2apic'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
    <timer name='hypervclock' present='yes'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='cdrom'>
      <driver name='qemu'/>
      <target dev='sda' bus='sata'/>
      <readonly/>
      <alias name='sata0-0-0'/>
      <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/MiscStorage/macOS-Simple-KVM-master/ESP.qcow2'/>
      <backingStore/>
      <target dev='sdb' bus='sata'/>
      <boot order='1'/>
      <alias name='sata0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/MiscStorage/macOS-Simple-KVM-master/BaseSystem.img'/>
      <backingStore/>
      <target dev='sdc' bus='sata'/>
      <boot order='2'/>
      <alias name='sata0-0-2'/>
      <address type='drive' controller='0' bus='0' target='0' unit='2'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/MiscStorage/OSX-KVM/mac_hdd_ng.img'/>
      <backingStore/>
      <target dev='sdd' bus='sata'/>
      <alias name='sata0-0-3'/>
      <address type='drive' controller='0' bus='0' target='0' unit='3'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb'/>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <alias name='usb'/>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x2'/>
    </controller>
    <controller type='sata' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'>
      <alias name='pcie.0'/>
    </controller>
    <controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='1' port='0x10'/>
      <alias name='pci.1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
    </controller>
    <controller type='pci' index='2' model='pcie-to-pci-bridge'>
      <model name='pcie-pci-bridge'/>
      <alias name='pci.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='0x11'/>
      <alias name='pci.3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
    </controller>
    <interface type='direct'>
      <mac address='52:54:00:92:d4:7b'/>
      <source dev='enp0s25' mode='bridge'/>
      <target dev='macvtap7'/>
      <model type='e1000'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/9'/>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/9'>
      <source path='/dev/pts/9'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='mouse' bus='usb'>
      <alias name='input0'/>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='keyboard' bus='usb'>
      <alias name='input1'/>
      <address type='usb' bus='0' port='2'/>
    </input>
    <input type='mouse' bus='ps2'>
      <alias name='input2'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input3'/>
    </input>
    <graphics type='spice' port='5907' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
      <image compression='off'/>
    </graphics>
    <sound model='ich9'>
      <alias name='sound0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1b' function='0x0'/>
    </sound>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
    <redirdev bus='usb' type='spicevmc'>
      <alias name='redir0'/>
      <address type='usb' bus='0' port='3'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <alias name='redir1'/>
      <address type='usb' bus='0' port='4'/>
    </redirdev>
    <memballoon model='none'/>
  </devices>
  <seclabel type='dynamic' model='selinux' relabel='yes'>
    <label>system_u:system_r:svirt_t:s0:c671,c679</label>
    <imagelabel>system_u:object_r:svirt_image_t:s0:c671,c679</imagelabel>
  </seclabel>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+107:+107</label>
    <imagelabel>+107:+107</imagelabel>
  </seclabel>
</domain>

image

laramy2020 commented 4 years ago

see this bug for the applesmc issue when using the default qemu-kvm over qemu-system-x86-64 https://bugs.centos.org/view.php?id=16672 qemu-kvm gets me to the boot screen, but that is it. it is missing isa_applesmc qemu-system-x86-64 fails to get to the boot screen (not sure why) but has isa_applesmc This will be an issue for all centos users untill they remove that patch.

So work around will be my next config with a recompiled build of qemu-kvm-ev https://cbs.centos.org/koji/buildinfo?buildID=26484

Otherwise centos 7 is not supported

laramy2020 commented 4 years ago

I have recompiled the binary with the applesmc support. i can now boot into the install medium. just having issues with the nic image i hope the nic used is one that i can enable by rebuilding the package

emilorol commented 4 years ago

@laramy2020 Amazing work. Add the following change to the network interface:

    <interface type='bridge'>
      <mac address='52:54:00:92:d4:7b'/>
      <source bridge='br0'/>
      <model type='vmxnet3'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
    </interface>

Check out this video in case you haven't https://www.youtube.com/watch?v=YWT4oOz2VK8

laramy2020 commented 4 years ago

i will have to recompile for vmxnet3 support

emilorol commented 4 years ago

According to the video explanation the card vmxnet3 is supported natively by MacOS, that will give you some edge. Also check on the video the qemu commands he adds to the end of the XML.

laramy2020 commented 4 years ago

Enabling vmxnet is gona be fun. Currently building for the 3rd time.

laramy2020 commented 4 years ago

so i was getting file not found issues after building for vmxnet3 found the rom in the source files and added a line to point to it

<interface type="direct">
  <mac address="52:54:00:92:d4:7b"/>
  <source dev="enp0s25" mode="bridge"/>
  <target dev="macvtap7"/>
  <model type="vmxnet3"/>
  <alias name="net0"/>
  <rom file="/path/to/efi-vmxnet3.rom"/>
  <address type="pci" domain="0x0000" bus="0x02" slot="0x01" function="0x0"/>
</interface>

IT INSTALLS! image

laramy2020 commented 4 years ago

I want to cry. This is 3 times in a row. image

emilorol commented 4 years ago

Me too!!!!!! ok, did you include the qemu commands from the video?

Note: I was searching about the error and the main consensus is:

This error has been reported to occur during installation of MacOS Catalina 
if the internet connection is disrupted or disconnected.

Insure that the Mac has an active wi-fi or ethernet connection and that the 
internet works as expected, and then try installing MacOS Catalina again.
emilorol commented 4 years ago

https://discussions.apple.com/thread/250713303

Can you try an earlier version, let's said Mojave?

laramy2020 commented 4 years ago

I saw that too. thinking it was my pi-hole. still fails. I will try that shortly. i am gona move my working install from arch to centos real quick

emilorol commented 4 years ago

I saw some post about filters or firewall blocking the download. Can you just for the test on installing on CentOS bypass the pi-hole?

You can also open the admin console of the pi-hole and see what might have been block or hit a blacklisted domain or url, I still believe bypassing will be faster. Use Google DNS or Cloudflare ones.

laramy2020 commented 4 years ago

i tested with pi-hole fully disabled. i still got the failure

emilorol commented 4 years ago

https://apple.stackexchange.com/questions/372785/pkdownloaderror-error-8-upon-catalina-update#374584 is the message that talks about the block connections.

emilorol commented 4 years ago

I believe you got the setup right and a if it was not for the connection you will be in the configuration face. Step back for a sec, maybe take a break and clear you head. I really think you got this.

laramy2020 commented 4 years ago

my copied working install booted image

emilorol commented 4 years ago

Nice, very nice. This prove your setup works.

Do you mind sharing the steps you follow?

laramy2020 commented 4 years ago

So something is wrong. Time gets horridly out of sync fast my clock is at 10:34, it started at 9:34 (10:34 host) it is now 10:12 host and it thinks it is 10:34 macos i think that may be the issue. Will have to look into that. i think one of the cpu features i removed because it was not available is causing the issue

laramy2020 commented 4 years ago

and now it thinks it is 10:55 something is very wrong.

emilorol commented 4 years ago

I have had similar clock issues with qemu and windows images to the point I have batch file in one of them forcing the clock to sync on boot. Try disabling the automatic time sync and then enable it again.

laramy2020 commented 4 years ago

So this is how macos runs faster Peek 2019-11-08 22-36

emilorol commented 4 years ago

even if you set it manually without automatic sync?

laramy2020 commented 4 years ago

Yes even when set manually

laramy2020 commented 4 years ago

Mojave is gona have the same issue. i can tell because the cursor was blinking just as fast as catalina

laramy2020 commented 4 years ago

It is the xml i currently have for those who want to work on it and figure out why the cpu clock is being dumb please go at it. MacOS-Simple-KVM.log

laramy2020 commented 4 years ago

there are only 2 missing settings between the 2 hosts avx and vmware-cpu-freq=on i can enable avx but clover kernel panics on centos, works fine on arch vmware-cpu-freq is not available to me in centos

I am not sure of the importance of these.

laramy2020 commented 4 years ago

I have kinda givven up on this issue. i think it is related to invtsc which i can not get to be recognized with ovirt's qemu-kvm emulator.

emilorol commented 4 years ago

I will take another swing at it next week.

prghix commented 4 years ago

Hello guys. What about the Centos 8?

the default qemu-kvm from Appstream of course doesnt have the isa-applesmc compiled in.. but the (future) qemu-system-x86 from EPEL8 could have.

~# /usr/libexec/qemu-kvm -device isa-applesmc qemu-kvm: -device isa-applesmc: 'isa-applesmc' is not a valid device model name

~# /usr/libexec/qemu-kvm --version QEMU emulator version 2.12.0 (qemu-kvm-2.12.0-65.module_el8.0.0+189+f9babebb.5) Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers