Building QEMU on Mac OS X (old)
The build instructions here are for building QEMU 1.3.1. During testing I had ongoing problems with this version when running Linux as the guest, including the Centos 6.3 (i386 and x86_64) installers hanging when installing from a virtual CD image, segmentation faults of known-good programs (such as awk, gcc, etc.), and programs dying due to impossible signals). I replaced QEMU 1.3.1 with QEMU 1.2.2 and the problems all went away. You can use the instructions below to build QEMU 1.2.2 with the following changes:
|
As my work mainly involves networked servers, it's extremely rare that I need to have a GUI interface on a virtual machine. As such, when I build qemu, what I'm looking for is to be able to build VMs which I can run in the background on my Mac, and to be able to use SSH to connect to them. So, when I build qemu, I really only need the VNC interface when setting up a virtual server because I can turn that off when the server is all set up and not have any windows lying around which I don't need. Once a server is set up and I don't need the console any more, I exit my VNC client and use SSH from then on to configure, administer, test, and use the server. This sort of minimalistic approach is reflected in the build options I use, particularly when configuring the build of qemu itself. |
Requirements
- Latest version of qemu,
- Runnable on Mac OS X by ordinary user,
- VNC interface,
- -daemonize works as expected, and
- i386 and x86_64 emulations
Install into: /Users/Shared/qemu
Environment
- Mac OS X version: 10.8.2 (Mountain Lion)
Preparation
- Install Xcode (v4.6)
- Install command-line tools in Xcode
Packages used for build
Package and source | Version used | Notes |
xz http://tukaani.org/xz/ |
xz-5.0.4 | Used to decompress glib tar file |
libffi http://sourceware.org/libffi/ |
libffi-3.0.11 | |
gettext http://www.gnu.org/software/gettext/ |
gettext-0.18.2 | |
pkg-config http://www.freedesktop.org/wiki/Software/pkg-config |
pkg-config-0.28 | |
glib ftp://ftp.gtk.org/pub/glib/ |
glib-2.34.0 | |
pixman http://cairographics.org/releases/ |
pixman-0.28.2 | |
qemu http://wiki.qemu.org/Main_Page |
qemu-1.3.1 |
Build sequence and commands
When preparing to build qemu, I have two directories under /Users/Shared/qemu:
- downloads, where all the source tar files are kept,
- build, where the build scripts (see files below) are kept, and under which all the different components are built
cd /Users/Shared/qemu/build
tar zxf ../downloads/xz-5.0.4.tar.bz2
cd xz-5.0.4/
./configure --prefix=/Users/Shared/qemu
make
make install
cd ..
tar zxf ../downloads/libffi-3.0.11.tar.gz
cd libffi-3.0.11/
./configure --prefix=/Users/Shared/qemu
make
make install
cd ..
tar zxf ../downloads/gettext-0.18.2.tar.gz
cd gettext-0.18.2/
./configure --prefix=/Users/Shared/qemu --disable-java --disable-native-java --without-emacs
make
make install
cd ..
tar zxf ../downloads/pkg-config-0.28.tar.gz
cd pkg-config-0.28/
./configure --prefix=/Users/Shared/qemu --with-internal-glib
make
make install
cd ..
The glib tar file must already have been decompressed by xz before doing this step. |
tar xf ../downloads/glib-2.34.0.tar
cd glib-2.34.0/
../configure_build_and_install_glib
cd ..
The qemu tar file includes a version of pixman, but this needs additional packages to build---namely autoconf and automake, apparently. It's easier to separately install pixman like this, and then tell the qemu build to use this one, rather than the one it comes with. |
tar zxf ../downloads/pixman-0.28.2.tar.gz
cd pixman-0.28.2/
./configure --prefix=/Users/Shared/qemu
make
make install
cd ..
tar zxf ../downloads/qemu-1.3.1.tar.bz2
cd qemu-1.3.1/
../configure_build_and_install_qemu
cd ..
Now you're ready to go. The binaries---including qemu-img, qemu-system-i386, and qemu-system-x86_64---are all installed under /Users/Shared/qemu/bin. Documentation is under /Users/Shared/qemu/share/doc.