Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
QEMU with Mac OS 9 guest *and working audio*

QEMU Mac OS 9 Instructions

Here is a short guide on how to build QEMU to run Mac OS 9 with working audio. These instructions work for MacOS High Sierra as the host OS, although with some tweaking they may run under Linux/Windows. You should be comfortable compiling software from source before attempting.

Clone QEMU fork

Adapted from instructions from Cat_7

You may need to install XCode and/or the XCode command line tools. If you do not have them, then this process may prompt you to install them (MacOS will do that).

Start by cloning the fork of QEMU with experimental audio support:

$ git clone -b screamer https://github.com/mcayland/qemu qemu-screamer
$ cd qemu-screamer

Then configure the source to use MacOS CoreAudio. I have also enabled LibUSB, KVM, HyperVirtualization Framework, and the Cocoa UI. In this case I am only compiling the emulator for PPC (32-bit).

$ ./configure --target-list="ppc-softmmu" --audio-drv-list="coreaudio" --enable-libusb --enable-kvm --enable-hvf --enable-cocoa

Then compile:

$ make
$ cd ..

This will create a binary in qemu-screamer/ppc-softmmu/qemu-system-ppc that we can use.

Create HD for Mac OS 9

We will need to have a hard drive image for our emulated system. I made mine 5 GB in size, which is plenty for Mac OS 9.

In our qemu-screamer directory, we will use qemu-img to create the disk image.

$ ./qemu-screamer/qemu-img create -f qcow2 macos92.img 5G

Get a Mac OS 9 Installer

If you have an ISO of a Mac OS 9 install disc (a Mac OS X classic install disc won't work), then you can use that in the next step. If you don't have one, you can download one from Mac OS 9 Lives: Mac OS 9.2.2 Universal Install.

Install Mac OS 9

This won't install quite like Mac OS 9 did, but instead use Apple System Restore to restore an image onto the hard drive.

Start up QEMU with the following options:

$ ./qemu-screamer/ppc-softmmu/qemu-system-ppc -L qemu-screamer/pc-bios -cpu "g4" -M mac99,via=pmu -m 512 -hda macos92.img -cdrom "~/Downloads/Mac OS 9.2.2 Universal Install.iso" -boot d -g 1024x768x32

A breakdown of that command:

  • -L qemu-screamer/pc-bios sets the BIOS. May not actually need this.
  • -cpu "g4" emulate a G4 CPU
  • -M mac99,via=pmu will define the Mac model and enable USB support
  • -m 512 use 512 MB of RAM, could go lower probably
  • -hda macos92.img use our generated disk image for the hard drive
  • -cdrom "~/Downloads/Mac OS 9.2.2 Universal Install.iso" use the ISO for the cdrom
  • -boot d boot from the disk drive
  • -g 1024x768x32 default to 1024x768 resolution and 32 bit colour

Once it starts up, you will be able to run Disk Initializer to format your hard drive image. Go ahead and do that, using Mac OS HFS Extended as the file system. One partition is good.

After initializing the disk, run Apple System Restore with the Mac OS 9 lives disk image as the source and your disk as the destination. This will take a minute to restore. Once done, shut down the emulated system.

Boot Mac OS 9

Similar to the last command, except we start up from the disk we created.

$ ./qemu-screamer/ppc-softmmu/qemu-system-ppc -L qemu-screamer/pc-bios -cpu "g4" -M mac99,via=pmu -m 512 -hda macos92.img -boot c -g 1024x768x32

It should boot up and you will have a running Mac OS 9 with audio!

Tips

When the emulator is shut down, just make a copy of the hard disk image to create a backup. If something breaks your Mac OS 9 installation then you can restore the file.

You can dynamically attach CDs/DVDs to the emulated system by going to the menu bar on your host system for the QEMU application and selecting the option to attach to the CD IDE drive. It will open a dialog letting you select your ISO.

@ccmn98

This comment has been minimized.

Copy link

@ccmn98 ccmn98 commented Apr 2, 2020

Hi, I followed the instructions to allow audio for a Mac virtualized in QEMU but I get this response after I execute the "make' command:

CHK version_gen.h
 LEX convert-dtsv0-lexer.lex.c

make[1]: flex: Command not found
BISON dtc-parser.tab.c
make[1]: bison: Command not found
LEX dtc-lexer.lex.c
make[1]: flex: Command not found
CC audio/coreaudio.o
audio/coreaudio.c:26:10: fatal error: CoreAudio/CoreAudio.h: No such file or directory
#include <CoreAudio/CoreAudio.h>
^~~~~~~~~~~~~~~~~~~~~~~

Are you aware of a way around this? I found downloaded the CoreAudio.h file from here: https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.8.sdk/System/Library/Frameworks/CoreAudio.framework/Versions/A/Headers/CoreAudioTypes.h and changed the CoreAudio.o file to look for the CoreAudio.h file in the same directory as audio.h; however this still resulted in the same message.

Thanks

@mgarcia-org

This comment has been minimized.

Copy link

@mgarcia-org mgarcia-org commented May 22, 2020

^^^^^^ same

@wallacewinfrey

This comment has been minimized.

Copy link

@wallacewinfrey wallacewinfrey commented May 26, 2020

@ccmn98 @mgarcia-org You need to install the Xcode command line developer tools. Run xcode-select --install in the shell (Terminal.app or whatever you prefer). The Xcode developer tools include flex and bison.

@wrenger

This comment has been minimized.

Copy link

@wrenger wrenger commented Jun 6, 2020

With some minor tweaks I got Mac OS 9 also working on Linux including sound support.

After cloning the QEMU fork the necessary build dependencies have to be installed as described here: https://wiki.qemu.org/Hosts/Linux
Including libsdl2-dev for graphics and sound.

The command for configuring QEMU looks as follows. The only things that had to be changed were the audio driver, here sdl, and the UI Library from cocoa to gtk.

./configure --target-list="ppc-softmmu" --audio-drv-list="sdl" --enable-kvm --enable-hvf --enable-gtk

Don't forget compile it with make.

All other steps for installing and running Mac OS 9 remain the same.

@joaquimds

This comment has been minimized.

Copy link

@joaquimds joaquimds commented Nov 14, 2020

I'm getting this error on 10.15.7 (Catalina):

Makefile.ninja:2381: *** multiple target patterns. Stop.

I don't know enough about makefiles to debug it, but it seems like the generated Makefile.ninja is invalid?

@theosche

This comment has been minimized.

Copy link

@theosche theosche commented Dec 29, 2020

I'm getting this error on 10.15.7 (Catalina):

Makefile.ninja:2381: *** multiple target patterns. Stop.

I don't know enough about makefiles to debug it, but it seems like the generated Makefile.ninja is invalid?

I faced the same issue on Mojave. The solution (found here) was to use a newer (>= 3.82) make version (see here)

@fredhope2000

This comment has been minimized.

Copy link

@fredhope2000 fredhope2000 commented Mar 6, 2021

Sharing a couple of issues I found with the ./configure step and how I solved them. MacOS 10.14.16 (Mojave):

Problem:
ERROR: Cannot find Ninja
Solution:
brew install ninja

Problem:
../meson.build:244:2: ERROR: Problem encountered: KVM not available on this platform
Solution:
Remove --enable-kvm from the command. I don't know if this is detrimental, it's just a suggestion I saw online, e.g. https://stackoverflow.com/a/66455140

Problem:
ERROR: Dependency "pixman-1" not found, tried pkgconfig
Solution:
brew install pixman

@fredhope2000

This comment has been minimized.

Copy link

@fredhope2000 fredhope2000 commented Mar 6, 2021

Also, the make command for me put its output into a build directory within qemu-screamer (not sure if this is a setting specific to my make; I'm using gmake because the built-in make is not a high enough version, per theosche's comment above).

So for example, instead of ./qemu-screamer/qemu-img, it would be ./qemu-screamer/build/qemu-img and so on.

@cat7

This comment has been minimized.

Copy link

@cat7 cat7 commented Mar 6, 2021

The build system was overhauled some time ago. Ninja is required, and indeed builds are now in the /build folder.
--enable-kvm will only work when host and guest are the same architecture which clearly is not the case. But also on a PPC host, --enable-kvm will not work for 32 bit qemu-system-ppc.

@filipe-maia

This comment has been minimized.

Copy link

@filipe-maia filipe-maia commented Mar 8, 2021

Managed to compile on Ubuntu 20.04 with the following:
./configure --target-list="ppc-softmmu" --audio-drv-list="sdl" --enable-kvm --enable-gtk
make

Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment