Using Qemu

I get notes every now and then about people not being able to use Qemu.  While Qemu is great, cross platform, and free it can be a little crazy to use, esp to people who are scared of the command line.

But rest assured it really isn’t that bad, once when you see the order of its seeming chaos.

Take this string for example:

C:\qemu\NTwalk>..\qemu-1.0.1\qemu-system-i386.exe -L ..\qemu-1.0.1\pc-bios -m 64
-cpu pentium -drive file=nt31disk,if=ide,index=0,media=disk,cache=writeback -ne
t nic,model=pcnet -net user -cdrom “Windows NT 3.1, Win32 SDK.iso” -fda “\temp\extensions.img” -soundhw sb16,adlib

Lets break it down as follows:

C:\qemu\NTwalk>..\qemu-1.0.1\qemu-system-i386.exe

First I specify the Qemu emulator I’m going to use.  I’m using the i386 one here, and as you can see, I’m running this from a different directory than where I’m working with disk images.

-L ..\qemu-1.0.1\pc-bios

Next is where I tell Qemu where it can find the needed BIOS files.  I think there is some global install path, but I tend to run all kinds of versions of Qemu all at once so this will *not* work for me, and it is just easier to tell it where to find them.

-m 64

I’ve set my VM to a maximum of sixty four megabytes of RAM.  The default is 128MB, but  sometimes you want less, as some OS’s can’t use more than 8/16/64 anyways and they may have issues finding RAM where they aren’t expecting it.

-cpu pentium

Most OS’s will run and boot on a modern CPU, this includes MS-DOS 3.30 which I have booted via a USB floppy controller on my 8core AMD processor.  However some OS’s fell into the trap of how to identify the processor, and configure themselves accordingly.  All was well until the Pentium 4, Itanium, and the CORE CPU’s came into existence.

 -drive file=nt31disk,if=ide,index=0,media=disk,cache=writeback

With a lot of experimentation I’ve found that this combination works best for qcow2 disk images.  While a lot more complicated than “-hda nt31disk” it does perform significantly quicker.  Another ‘tip’ I like is that you can have Qemu mount a directory (as long as it is under 500MB) and it’ll create a virtual FAT-16 formatted disk.  The flags are [ -hdb fat:<path> ]  this is a great way to copy in things like device drivers, and even programs.  However this disk is read only, so you cannot copy data out.

-net nic,model=pcnet -net user

This enables the AMD PCNet PCI network card, and sets it to User mode NAT.  I like the AMD card as it has really good support.  With that in mind, Qemu supports the following models:

  • ne2k_pci
  • ne2k_isa
  • i82551
  • i82557b
  • i82559er
  • rtl8139
  • e1000
  • pcnet
  • virtio

I’ve never really messed with the tun/tap stuff as you can only have one host on it, so its kind of useless to me.  With the usermode NAT the VM should be configured the following way if it doesn’t support DHCP:

Address 10.0.2.15
NetMask 255.255.255.0
Gateway 10.0.2.2
DNS 10.0.2.3

If you have DNS issues, you may want to try a DNS server that you are using on your physical computer, or perhaps 4.2.2.4/8.8.8.8 . Also you will *NOT* be able to ping outside of the VM, but you *CAN* ping the gateway, 10.0.2.2 .

-cdrom “Windows NT 3.1, Win32 SDK.iso”

Just as it appears, this adds an ISO image into the VM which is typically located on the second IDE interface, on the primary port. To force the VM to boot from CD, add the flag ‘-boot d’ and the BIOS will attempt to boot from the CD-ROM.

-fda “extensions.img”

And like the CD-ROM, this is for the floppy disk.  Sizes can be 360k, 720k, 1.2M and 1.4M. If you wish to boot from the floppy disk you simply add the flag ‘-boot a’  Older floppies will not contain a boot check sum, so to force them to boot, you’ll need the additional flag ‘-no-fd-bootchk’ to ignore the check sum that later diskettes used.  In my above example I’m just using a disk image, not booting from it.

-soundhw sb16,adlib

And finally I’m enabling both the SoundBlaster 16 & Adlib emulation.  By default in the builds of Qemu the adlib is turned off, but I just turn it back on when I build Qemu.  Other sound cards include the recent HDA & AC97 chipsets.

Remember the Sound Blaster is configured for an IO base of 0×220, IRQ 5, DMA 1 and High DMA 5.

 

I hope this gives some insight to users on how to effectively use QEMU.

4 thoughts on “Using Qemu

    • I’ve just noticed this… I only used 1.0 for non networking things…!

      I even went as far to build my own Glib on Windows but now I think I’ve hopelessly broken my build environment 🙁

    • the 1.0 turned out to be horrible for windows with user mode networking being broken, along with some disk error stuff..

      I’d probably stick with 0.15.1 …

      That said I don’t know about ARM you may have to try them all…..

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.