QEMU/QEMU Hello World: Installing QEMU and getting it up and running

Installing QEMU

edit

The most surefire way to get QEMU working is to build QEMU from its source. To do so, enter the following commands in a command line environment:

  1. git clone git://git.qemu.org/qemu.git (The git link here is provided by the QEMU download page)
  2. cd qemu
  3. git checkout stable-2.9 (As of writing this, the stable branch version is 2.9. Change 2.9 to the number of current stable version when you are applying these steps)
  4. git submodule init
  5. git submodule update --recursive (Credit for steps 3,4 and 5)
  6. git submodule status --recursive
  7. mkdir build
  8. cd build
  9. ../configure (If you want to build QEMU only for a specific target (say, only for 32-bit x86) instead of for all targets, use ../configure --target-list=i386-softmmu instead)
  10. make

NOTE: All these steps should work seamlessly on all platforms, except for the step 9 on Windows. To get step 9 working on Windows, you need MinGW or a similar solution. That is, to get this working on Windows, you need MinGW (or a similar solution).

You may find further platform specific instructions on compiling QEMU from source here.

Testing the QEMU Installation

edit

If no error has occurred while running the commands above, QEMU is now ready. QEMU is installed in a directory named build which is a sub directory of the directory that contains your local copy of the QEMU source code repository. Your command line environment should currently be inside this build directory.

QEMU provides sample disk images to test the installation here. We will test QEMU for the first two images provided in the link.

Testing QEMU using the Linux image

edit
  1. Download the Linux image which is the first image given in the link. For convenience, I am providing a copy of the link here.
  2. The image is provided as a bzip2 compressed archive (that is, the file you have downloaded is a bzip2 compressed archive). So, you need to decompress it before obtaining the image file, which is what we want. To learn how to decompress a bzip2 archive, you may search the web for 'decompress bzip2'.
  3. After decompressing, go to the 32-bit x86 target of QEMU by writing cd i386-softmmu. i386-softmmu is a subdirectory of the build directory.
  4. Run QEMU using this image. For example, if the image is in /home/your_username/Downloads/linux-0.2.img, run QEMU by typing ./qemu-system-i386 /home/your_username/Downloads/linux-0.2.img

Testing QEMU using the FreeDOS image

edit
  1. Download the FreeDOS image which is the second image given in the link. For convenience, I am providing a copy of the link here.
  2. Unlike the Linux image above, this image is not compressed. Hence, we can use it as is.
  3. Go to the 32-bit x86 target of QEMU by writing cd i386-softmmu. i386-softmmu is a subdirectory of the build directory.
  4. Run QEMU using this image. For example, if the image is in /home/your_username/Downloads/odin1440.img, run QEMU by typing ./qemu-system-i386 -fda /home/your_username/Downloads/odin1440.img. Note that this time, we needed to use -fda option. -fda option inserts the disk image in the floppy drive A (that is: A:\ drive). We need this option because the FreeDOS image is a floppy disk image, instead of a (hard) disk image. Had it been a hard disk image (like the Linux image in the previous example), we could have simply written ./qemu-system-i386 /home/your_username/Downloads/odin1440.img, just like what we did to run the Linux image.