Qemu Ubuntu For Mac

Qemu Ubuntu For Mac

Thom Holwerda 2020-11-11 Mac OS X 9 Comments I booted the arm64e kernel of macOS 11.0.1 beta 1 kernel in QEMU up to launchd. It’s completely useless, but may be interesting if you’re wondering how an Apple Silicon Mac will boot. QEMU is a generic and open source machine emulator and virtualizer. Full-system emulation. Run operating systems for any machine, on any supported architecture.

Running Mac OS X as a QEMU/KVM Guest

Gabriel L. Somlo

See the old version of this page here.FINAL UPDATE (2018-10-21):
I no longer have the cycles to work on this project. At this point QEMU and KVM are mostly capable of supporting OS X (up to Sierra), and the largest portion of the effort still required lies with edk2/ovmf (start with my fork on github as indicated below, and go from there).
Additionally, since Apple machines have become increasingly lockeddown and end-userunfriendly, I can't continue considering them for any upcoming hardware refresh (which is too bad, they used to make almost perfect Linux machines for the last 20 years!).

NOTE: Installer .iso images prepared based on Sierra 10.12.4 or later will hang during boot. However, guest images installed with 10.12.3 or earlier can successfully be upgraded, assuming the applesmc fix mentioned above is applied. The cause for this is as of yet unknown (to me, at least).

1. Prerequisites

You will need the following:
  • Tools: git, gcc[-c++], nasm, [auto]make, iasl, kernel-devel, etc.
  • Linux kernel ≥ 4.7
  • QEMU ≥ 2.6.0
  • Patched OVMF firmware, built from source
I currently use Fedora 26. Anything close to it in terms of 'freshness' should likely do just fine.To build the patched OVMF firmware blob, follow these instructions:The result of this process is a firmware blob named OVMF.fd, which will be copied to your home directory by the last command shown above. A binary OVMF blob built by applying my patches on top of the current edk2 master branch (as indicated by the abbreviated commit ID in the file name) is available to help speed things up, but you're strongly encouraged to build your own :)

2. Creating an OS X boot DVD iso image

SnowLeopard (10.6) was the last OS X version released in DVD format. Starting with Lion (10.7), an install DVD (.iso) image may be generated on an OS X machine by following the steps below (Thanks Dick Marinus for pointing out the Yosemite-specific updates!):First, create an empty hard drive image:Using the following command line, install OS X from the boot media created earlier (Thanks Jim Burns for the Penryn hint, which is needed instead of core2duo as of Sierra):In addition to the OVMF.fd firmware blob, the DVD image, and a blank hard drive image, you'll need to provide the value of OSK0 and OSK1, as a single concatenated 64-character string. If you own a Mac and run Linux on it natively (the license-compliant use case for the application of these instructions), you can retrieve them by compiling and running SmcDumpKey.c.Finally, to start your freshly installed guest, run:NOTE: If using qemu ≤ 2.8, substitute '-device usb-mouse' instead of '-device usb-tablet'. A patch to make the latter work with OS X (thanks to Phil Dennis-Jordan) only became available starting with version 2.9.0.

4. Is This Legal?

Let me start with the obligatory disclaimer: I am not a lawyer, and this is not legal advice!We know that OS X is supported on commercial virtualization solutions such as VMWare Fusion and Parallels. Reading through Apple's EULA (which states that '[...] you are granted a [...] license to install, use and run one (1) copy of the Apple Software on a single Apple-Branded computer at any one time'), it appears everything is OK as long as the underlying hardware is made by Apple.What if the hypervisor OS is different than OS X? (both Fusion and Parallels both use OS X as the hypervisor OS). Well, it appears VMWare ESXi allows running OS X guests (presumably only if the hardware is, once again, manufactured by Apple). This is clearly an example of OS X running as guest on top of a Qemu Ubuntu For Macnon-OS X hypervisor, on top of Apple-manufactured hardware.So, it is my belief that, as long as I'm running a Linux/KVM hypervisor on a genuine Mac computer (which I've personally been doing exclusively since cca. 2006, btw), the license does not forbid me from running OS X as a VM guest on top of it.In terms of advice, all I can say is: Check with the legal and/or moral authorities in your local jurisdiction before trying this at home! :)

5. Future Work

A few things still need work:
  • OS X High Sierra (10.13) doesn't boot at this time. No idea yet if (and how) the new Apple filesystem (APFS) plays into this.
  • None of QEMU's current audio devices appear to have native OS X driver support
  • Screen resolution / resizing doesn't work
  • Most importantly, the HFS+ EDK2 patches (and the OS X boot support ones which depend on HFS+) are rather far from being palatable to the upstream EDK2 project. A major refactoring of the HFS+ support is needed first; Then, cleaning up and upstreaming the OS X boot support work originally done by Reza Jelveh would be needed.
    • Additional details on https://github.com/gsomlo/edk2 are needed for those interested. The repository contains three branches, stacked on top of each other: On top of the master branch (which tracks upstream, there's gls-hfsplus, containing the HFS+ driver in its current, fsw-based form. On top of that, there's gls-macboot containing Reza's hacks to get OS X to load, which will need to be cleaned up once we have a reliable upstream HFS+ filesystem. Finally, on top of everything, there's gls-miscopt, containing convenient hacks for everyday OSX use (e.g. forcing the default screen size to something a bit more useful). I (re)structured my clone of edk2 this way so that I can easily rebase things on top of upstream, while at the same time being able to bounce between filesystem driver development in gls-hfsplus and using OSX.
  • 1QEMU on OS X (macOS) hosts

Qemu Kvm Mac

While QEMU's main host platform is Linux, it is also supported on operating systems for Apple's Mac computers (known as OS X or macOS). The official support policy covers the last two released versions of OSX; QEMU might work on older versions, but it is not guaranteed and it might not even compile on older versions.

Please note that fewer developers work on QEMU for Mac hosts, so it might be less stable (but I don't think it is). If you can replicate a bug on a Linux hosted QEMU before reporting it, this is helpful as it means a wider set of people might look into it.

Some system emulations on Linux use KVM, a special emulation mode which claims to reach nearly native speed.KVM is mainly used for x86 (32 and 64 bit) emulation on x86 hosts running Linux. Should you want to run Qemu with KVM support on a G5, depending on your distribution, you might have to compile your own kernel with KVM support.There exists a port of QEMU to Hypervisor.framework (a kernel module from Apple which is similar in spirit to KVM), but unfortunately it is not included in upstream QEMU.

Mac

Building QEMU for OS X

The system requirements are:

  • One of the last two most recent versions of OS X (currently that's 10.13 or 10.14)
  • The clang compiler shipped with the version of Xcode for that OS X. GCC might also work, but we recommend clang

Additional build requirements are:

You may find it easiest to get these from a third-party packagersuch as Homebrew, Macports, or Fink.

After downloading the QEMU source code, double-click it to expand it.

Then configure and make QEMU. The target-list option is used to build only the machine or machines you want. If you don't specify it, all machines would be built. Probably not what you want.

This way doesn't require you to wait for the configure command to complete:

If your system has the 'say' command, you can use it to tell you when QEMU is done

You can use './configure --help' to see a full list of options.

Here are all the currently available machines:

  • aarch64-softmmu
  • alpha-softmmu
  • arm-softmmu
  • cris-softmmu
  • i386-softmmu
  • lm32-softmmu
  • m68k-softmmu
  • microblaze-softmmu
  • microblazeel-softmmu
  • mips-softmmu
  • mips64-softmmu
  • mips64el-softmmu
  • mipsel-softmmu
  • moxie-softmmu
  • or32-softmmu
  • ppc-softmmu
  • ppc64-softmmu
  • ppcemb-softmmu
  • s390x-softmmu
  • sh4-softmmu
  • sh4eb-softmmu
  • sparc-softmmu
  • sparc64-softmmu
  • tricore-softmmu
  • unicore32-softmmu
  • x86_64-softmmu
  • xtensa-softmmu
  • xtensaeb-softmmu
Qemu on mac os


We recommend building QEMU with the -default compiler provided by Apple, for your version of Mac OS X (which will be 'clang'). The configure script will automatically pick this.

Errors on old compilers

Install Mac Os On Qemu

Note: If after the configure step you see a message like this:

you may have to install your own version of gcc. You can build it from source (expect that to take several hours) or obtain third party binaries of gcc available from Homebrew or MacPorts.

You can have several versions of GCC on your system. To specify a certain version, use the --cc and --cxx options.

Build with LLVM/Clang 7

Qemu Ubuntu For Mac Virtualbox

If you need to compile with newer versions of clang (to get f.i. AVX/AVX2 support), you can install llvm through e.g., brew.

Note that building for machines with CPUs supporting such extensions will exclude running your binary on earlier machines.

Compile with:

Qemu On Mac Os

Contacts

If there are any issues with this web page, please let me know.

Retrieved from 'https://wiki.qemu.org/index.php?title=Hosts/Mac&oldid=9274'