10.4. Emulating the Mac

 < Day Day Up > 

10.3. Emulators on Mac OS X

Emulation has been a hot area of the past few years. It's emerged as a way to defeat obsolescence by letting you run software for obsolete computers. Have a favorite Atari 800 game but your old Atari won't boot? You can download the emulator, point it at the disk image containing that old game, and start playing. Repeat as necessary for Apple II, Commodore 64, Atari VCS, and more.

Copyrights and Vintage Games

If your favorite old game isn't shareware or in the public domain, there are some legal issues involved with obtaining copies of your old game, but at the time of this writing, there weren't any effective barriers that would keep you from finding and running them.

There are a several sites with information about vintage game and computer emulators for the Mac, including:

  • http://www.zophar.net/mac/mac.phtml

  • http://www.macemu.com

  • http://www.emaculation.com

  • http://www.emulation.net

  • http://www.bannister.org/software/emu.htm

Given the speeds of today's Macs, it's not surprising that you can easily emulate a 1 MHz computer from the old days. But what's fantastic is how you can emulate near-current PC hardware on your Mac. Microsoft's Virtual PC is capable of running even the resource-hungry Windows XP quite comfortably on current Macintoshes, and the open source QEMU comes close, although it's not quite as fast as Virtual PC. Both are capable of running Linux comfortably.

10.3.1. Virtual PC

Microsoft's Virtual PC, formerly Connectix Virtual PC, has been letting Mac users run Windows and DOS on their Macs for years. You can also run dozens of other operating systems some are easier to install than others including Linux, Darwin, and Net/Free/OpenBSD.

Virtual PC 7 is available without an operating system (it's basically a bare-metal virtual machine) for approximately $129. If you're planning to run Windows on it, you could splurge on one of the editions of Virtual PC that is bundled with a Windows operating system (Windows 2000, Windows XP Home, or Windows XP Professional).

Once you've got Virtual PC up and running, you can install an operating system. You can install from an ISO image, CD-ROM, or DVD. For example, here's how to install Ubuntu Linux from an ISO image:

  1. Select File New. Youll be prompted to select a setup method.

  2. Select Install Your Own Operating System, and then click Begin.

  3. You're prompted to choose an operating system and hard disk format (see Figure 10-4). One of the choices you'll notice that is missing is the size of the drive. Virtual PC defaults to a 15 GB drive, but it doesn't use up all the space at once. Instead, it grows as you add files to the drive. Select Linux for the operating system and Unformatted for the hard disk format and click Continue.

  4. Now you need to choose a filename for the virtual machine, as well as a location, as shown in Figure 10-5.

    The file that gets created is actually a bundle, so if you locate it in the Finder, right-click on it and select Show Package Contents from the contextual menu and you'll see all sorts of files, including configuration data, the hard disk image, and any saved states.

  5. Next, Virtual PC prompts you to start the PC. Click Start PC to begin. When the Virtual PC starts up, the first thing you'll see is an annoying help document and an error message in the virtual machine (see Figure 10-6).

  6. You now need to "capture" the CD-ROM and reboot the virtual machine. Select Drives Capture CD Image and choose the CD-ROM ISO image. If you want to capture a CD-ROM thats sitting in your optical drive, you can select Drives Capture Disc.

After you've captured the drive, select PC Reset to reboot the PC. Youll be launched into the installer. In theory, everything should go smoothly, and probably will for most operating systems. However, here are some troubleshooting hints: Linux doesn't find the network adapter

If Linux doesn't detect your network hardware, you can try to force its hand. Virtual PC emulates a DECChip Ethernet adapter that Linux is happy to support with the de2104x driver. For example, here's how you can get Ubuntu to recognize the network hardware and proceed as though nothing's gone wrong. First, wait for the Ubuntu installer to complain about its failure to detect the network interface, then:

  1. Switch to virtual console (Option-F2).

  2. Press Enter to activate the console and get a root prompt.

  3. Run the command modprobe de2104x.

    Figure 10-4. Create your virtual hard drive

    Figure 10-5. Choose a location and name for your virtual machine

    Figure 10-6. This DOS-style error message reminds you to insert a CD-ROM

  4. Return to the first virtual console (Option-F1).

  5. Select Go Back.

  6. When you get to the menu, select Detect Network Hardware, and setup will resume.

With other Linux distributions, such as Mandrake, you can safely wait until after installation is complete to configure the network hardware. For example, under Mandrake 10.0 Community Edition, you can add de2104x (on a line by itself) to /etc/modprobe.preload (/etc/modules under 2.4 and earlier kernels) and reboot the virtual machine. You may also find that the tulip driver works just fine. Linux can't configure TCP/IP

After you install Linux, one of the first things you'll need to do is fetch updates from the network. Under Debian, Ubuntu, and other apt-based distributions, your operating system will make decisions during installation about which package repositories to use. If the network isn't working at this point, you may have to manually configure things later. So, the first thing you should do after that first reboot is to check the network.

As soon as you reboot, switch to an alternate console (Option-F2 if you are at a text console, Control-Option-F2 if you are in X11) and log in.

Wait a minute if your Linux distribution hasn't let you set up a new user or set the root password, you won't be able to log in. If so, wait until the installer lets you create the root user or a user who can use sudo, and then switch to the alternate console and log in.

Try to FTP or SSH to a known good host (don't use ping, since ICMP may be discarded by some NAT routers, and Virtual PC's default configuration puts an additional NAT layer between the virtual machine and the network). If you can't reach any hosts, you can manually configure networking in the virtual machine. You'll need to set the network as shown in Table 10-1.

Table 10-1. Network Settings for Virtual PC



IP Address


DNS Servers,

For example, under Debian, you can edit /etc/network/interfaces and change:

     iface eth0 inet dhcp 


     iface eth0 inet static             address             netmask             gateway 

and then set /etc/resolv.conf to read:

     nameserver     nameserver 

Now restart networking with /etc/init.d/networking restart. Make sure you can reach something with FTP or SSH, and return to the post-install setup with Option-F1 (for the main text console) or Option-F7 (for X11-based setups).

With many other Linux distributions, you can wait until installation is complete to configure the network. For example, under Mandrake 10.0 Community Edition, replace the contents of /etc/sysconfig/network-scripts/ifcfg-eth0 with:

     DEVICE=eth0     IPADDR=     NETMASK=     GATEWAY=     ONBOOT=yes 

And configure /etc/resolv.conf as shown for Debian earlier in this section. Then restart networking with /etc/init.d/network restart.

Even after these changes, you may still see a [FAILED] status next to "Bringing up interface eth0." However, the network may still be working, so test it before you give up.

For more information, see Microsoft's knowledge base entry on troubleshooting Virtual PC's network at http://support.microsoft.com/kb/825372. Launching X11 displays garbage on the screen

Virtual PC's emulated S3 Trio64 graphics adapter doesn't play well with X11 in 24/32-bit color. Reconfigure X11 to use 16-bit or lower color. In a Debian-based system, you can use the command dpkg-reconfigure xserver-xfree86. You can also edit /etc/X11/XF86Config-4 on most Linux distributions and set the color depth to 16 (look for Depth and DefaultDepth settings in that file). Figure 10-7 shows how to configure this during the installation of Mandrake 10.

Figure 10-7. Setting color depth in Mandrake 10

10.3.2. QEMU

QEMU (http://fabrice.bellard.free.fr/qemu) is a state-of-the-art open source emulator. Like Bochs (http://bochs.sourceforge.net), QEMU can emulate an x86 CPU. However, QEMU is significantly faster than Bochs, and can also emulate a number of other CPUs, including SPARC and PowerPC. Most important, QEMU is fast enough for day-to-day use, although for top performance, you'll find that Virtual PC wins (see the sidebar "Virtual PC Versus QEMU," later in this chapter).

To get started with QEMU, you can either grab a binary package from http://www.freeoszoo.org/download.php, or download the source from QEMU's web page (noted earlier) and compile it yourself. If you're chasing the latest release, you may need to compile it yourself. You'll also need to compile a Mac OS X native build of SDL; see http://www.libsdl.org/index.php.

Once you've got QEMU installed, you should have at least qemu-img and qemu in someplace such as /usr/local/bin or /opt/local/bin. You may also have qemu-system-ppc and qemu-system-sparc (the Power PC and SPARC system emulators). Now you're ready to either run one of the pre-packaged virtual machines from http://www.freeoszoo.org/download.php, or install one by hand. Installing an operating system

To create a virtual machine with QEMU:

  1. Create a new blank disk image with qemu-img. For example, to create a 4 GB image named ubuntu.img:

         $ qemu-img create ubuntu.img 4G 

  2. It's best if you have your installation media available as ISO images. Don't even bother to burn them to CD. Instead, keep them handy on some kind of secondary storage, such as a FireWire drive or heck, even burn a few of them to a DVD-R.

  3. Make sure you have time. If you are installing the operating system from scratch, it could take hours, unless you have the fastest, latest, and greatest. So, open up System Preferences Energy Saver and tell your Mac not to sleep. This might be a good time to consider going to FreeOSZoo for a pre-built image.

    If you have a fast x86 Linux machine, you should perform the initial setup there, since x86 emulation on an x86 machine is faster than on PowerPC. You can move QEMU disk images between the Linux, Windows, and Mac OS X versions of QEMU without hassle. The disk images get big, so we suggest you use Fast Ethernet, Gigabit Ethernet, or FireWire to transfer the images between machines. As fast as AirPort Extreme is, it still takes a painfully long time to transfer a 4 GB or larger disk image.

  4. Once you've got everything set up, you'll have an ISO image and a blank QEMU disk image sitting around:

         $ ls -l     total 9459264     -rw-r--r--  1 bjepson  unknown  4294967296  2 Feb 22:05 ubuntu.img     -rwxr-xr-x  1 bjepson  unknown   548175872  2 Feb 22:01 warty-install-     i386.iso 

  5. Launch qemu with the ISO image as your CD-ROM drive (boot -d tells QEMU to boot from the second IDE device, which happens to be the CD-ROM). Use the disk image as the first hard drive. Use the -monitor option to give you a console from which you can control QEMU, and use -localtime to use the local system time:

         $ qemu -m128 -cdrom  warty-install-i386.iso  -hda  ubuntu.img  -boot d \          -monitor stdio -localtime

In a matter of seconds, you'll see the installation splash screen as shown in Figure 10-8.

Once you're done installing the virtual machine, you'll need to make a change to the command line when you want to reboot it; change the -boot d option to -boot c to boot from the first virtual hard drive instead of the CD-ROM image.

Figure 10-8. Ubuntu is ready to install

If you switch back to the Terminal window from which you launched QEMU, you'll see the console up and running. Type help and press Return to see a list of the commands that are available:

     QEMU 0.6.1 monitor - type 'help' for more information     (qemu) help     help|? [cmd] -- show the help     commit  -- commit changes to the disk images (if -snapshot is used)     info subcommand -- show various information about the system state     q|quit  -- quit the emulator     eject [-f] device -- eject a removable media (use -f to force it)     change device filename -- change a removable media     screendump filename -- save screen into PPM image 'filename'     log item1[,...] -- activate logging of the specified items to '/tmp/qemu.     log'     savevm filename -- save the whole virtual machine state to 'filename'     loadvm filename -- restore the whole virtual machine state from 'filename'     stop  -- stop emulation     c|cont  -- resume emulation     gdbserver [port] -- start gdbserver session (default port=1234)     x /fmt addr -- virtual memory dump starting at 'addr'     xp /fmt addr -- physical memory dump starting at 'addr'     p|print /fmt expr -- print expression value (use $reg for CPU register     access)     i /fmt addr -- I/O port read     sendkey keys -- send keys to the VM (e.g. 'sendkey ctrl-alt-f1')     system_reset  -- reset the system     (qemu) 

You'll need to use this console to switch CD-ROMs during installation. Use eject to eject the ISO, and change to insert a new one:

     (qemu) eject cdrom     (qemu) change cdrom warty-install-i386.iso 

You can now install your operating system as you would on an actual PC (follow the prompts, partition your virtual disk, select packages, and then go drink a long slow cup of coffee). Suspending and resuming

The user interface may not be as fancy as Virtual PC's, but you can suspend (pause and save state to disk) and resume your virtual machines under QEMU. However, if you mix any of this up, such as forgetting to stop before you issue the savevm command, you could get the contents of the saved memory and your hard disk image out of sync.

To save state, stop the virtual machine, save the memory, and quit:

     (qemu) stop      (qemu) savevm  savedstate.sav      (qemu) quit  

To resume where you left off, start QEMU as you normally would, but use the -loadvm option to specify the saved state:

     $ qemu -m128 -cdrom  warty-install-i386.iso  -hda  ubuntu.img  -boot c \         -monitor stdio -localtime -loadvm  savedstate.sav Networking

QEMU sets up a NAT network for your virtual machine, so if the operating system cooperates, you won't need to do anything special to get networking working correctly. QEMU emulates a PCI NE2000 adapter, so you should be able to use a generic NE2000 driver for that card.

If you try to use ping to test the network, it probably won't work due to the NAT implementation. Use ftp, ssh, or a web browser to test the network.

Virtual PC Versus QEMU

At the time of this writing, Virtual PC 7 is significantly faster than QEMU. But Virtual PC 7 is pretty fast to begin with QEMU is fast enough for light usage, but we wouldn't recommend it for day-to-day tasks such as running office applications, surfing the web, email, or instant messenger. Use your Mac for that.

We tested Virtual PC and QEMU with Ubuntu Warty. We used the w3c-libwww-5.4.0 source code from http://www.w3.org/Library for testing. We ran make three times on each emulator, and took the average. We ran this under the lightweight icewm Window manager rather than the text console, so as to stress the GUI a bit while we ran the tests.

The Mac OS X tests were performed on a 1.25 GHz G4 PowerBook with 1 GB of RAM and 128 MB allocated to the virtual machine. The virtual disk image was located on an external FireWire drive.

The Linux tests were performed on a 2.4 GHz Pentium IV system with 512 MB of RAM running Xandros 2.5 and 128 MB allocated to the virtual machine. The virtual disk image was located on an internal SATA drive.


Host operating system



Mac OS X

1 hour, 41 minutes



38 minutes

Virtual PC

Mac OS X

1 hour, 11 minutes

     < Day Day Up > 

    Mac OS X Tiger for Unix Geeks
    Mac OS X Tiger for Unix Geeks
    ISBN: 0596009127
    EAN: 2147483647
    Year: 2006
    Pages: 176

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net