Jump to content

QEMU/Installing QEMU

From Wikibooks, open books for an open world

Installing from a repository (Unix)

[edit | edit source]

Most GNU/Linux distributions have package repositories that carry precompiled binaries of QEMU. This is a much simpler installation process when compared to compiling it from source. It's often best to use these repositories when installing QEMU, as you can be confident that it will install and run without problems. This table outlines the minimum commands to perform in order to install QEMU from your repository.

Distribution Install command
Fedora[1] yum install qemu
Debian[2] apt install qemu qemu-kvm libvirt-bin[3]
SUSE yast -i qemu
Gentoo emerge -av app-emulation/qemu
Arch sudo pacman -S qemu
Mac (Homebrew) brew install qemu

If in the event that you can't install QEMU from a package repository, you can go to the QEMU website to download the latest source code and follow the instructions given.

Installing on Windows

[edit | edit source]

If you're hesitant to work with the command-line, there's a GUI front-end called QEMU Manager. However, this program has been abandoned. Its last release (7.0) was in 2010, the creator's website has disappeared, and it doesn't appear to have its source available; this means that (should you use it) you would be stuck with the very old version of QEMU it provides (0.11), causing conflicts with newer builds severely. And if you're looking for an x86 virtualization tool that has a graphical interface, then VirtualBox is recommended.

If you're comfortable with the command-line interface, there are two builders providing downloads of QEMU for use with the command line. One compiles QEMU with Cygwin, and they warn that you need to download MinGW packages as a result. The other is as recent as possible with his builds and doesn't require Cygwin. His builds are linked by the QEMU website.

Building from source

[edit | edit source]

The most surefire way to get QEMU working is to build it from its source. To do so, make sure you have git (and if you're on Windows, get MinGW), and enter the following commands into a terminal/command-line environment:

  1. git clone git://git.qemu-project.org/qemu.git[4]
  2. cd qemu
  3. git submodule init
  4. git submodule update --recursive[5]
  5. git submodule status --recursive
  6. git checkout stable-2.9[6]
  7. mkdir build
  8. cd build
  9. ../configure[7]
  10. make -j$(nproc)

After QEMU is installed, you may find platform-specific instructions in the documentation.

Native x86 acceleration with KVM

[edit | edit source]

QEMU by itself does a lot of emulation even when running on guest-compatible hardware. To make it perform better, QEMU has a kernel module called KVM that allows much of the guest OS's code to run directly on the host processor when running on x86 or x86-64 processors with virtualisation extensions under GNU/Linux. For example, if the host is x86 GNU/Linux and the guest is Windows XP, then KVM can run most of the Windows XP code directly on the processor without emulation.

QEMU-KVM requires a GNU/Linux or BSD Unix host, and a CPU with virtualisation extensions -- either Intel VT or AMD-V. To determine whether your CPU has this support on GNU/Linux, run the following command from a shell:

egrep '(vmx|svm)' /proc/cpuinfo

If you get nothing back, your CPU does not support the required virtualisation extensions.

Many modern GNU/Linux distros have simple installation processes based on package repositories. It is often best to use the repository approach for installing QEMU-KVM, as you can be confident that QEMU-KVM will just install and run. Here are some common GNU/Linux distros and their QEMU-KVM install commands:

Distribution Install command
Fedora[1] yum install @virtualization or yum install qemu-kvm
Debian[2] apt install kvm qemu-kvm libvirt-bin[3]
SUSE yast -i kvm

More details are available on the KVM website. If you can't install QEMU-KVM from a package repository, go to the QEMU-KVM website and download the latest source code and follow the instructions given.

Notes

[edit | edit source]
  1. a b Also valid for other RPM-based distributions (e.g. RedHat, CentOS).
  2. a b Also valid for other dpkg-based distributions (e.g. Ubuntu, Mepis, Mint).
  3. a b apt-get works the same as apt in newer releases.
  4. This is the git link provided by QEMU's download page.
  5. To prevent the problem that this solves.
  6. But don't put 2.9 if it's no longer the current stable version. If the current is higher, change it accordingly.
  7. If you want to build QEMU only for a specific target (say, only for x86 which is 32-bit) instead of for all targets, use ../configure --target-list=i386-softmmu instead.