22 Nov 2017 — by Yu Ning
In this post, I’m going to introduce a useful technique to people who are using,or are interested in using, QEMU on Windows. Basically, you can make the most ofyour hardware to accelerate QEMU virtual machines on Windows: starting with its2.9.0 release, QEMU is able to take advantage ofIntel HAXM to run x86 and x86_64 VMs with hardware acceleration.
If you have used QEMU on Linux, you have probably enjoyed the performance boostbrought by KVM: the same VM runs a lot faster when you launchQEMU with the -accel kvm
(or -enable-kvm
) option, thanks tohardware-assisted virtualization. On Windows, you can achieve a similar speed-upwith -accel hax
(or -enable-hax
), after completing a one-time setup process.
First, make sure your host system meets the requirements of HAXM:
- An Intel CPU that supportsIntel VT-x with Extended Page Tables (EPT).
- Intel CPUs that do not support the said feature are almost extinct now. Ifyou have a Core i3/i5/i7, you should be good to go.
- Windows 7 or later.
- HAXM works on both 32-bit and 64-bit versions of Windows. For the rest ofthis tutorial, I’ll assume you are running 64-bit Windows, which is far morepopular than 32-bit nowadays.
Next, check your BIOS (or UEFI boot firmware) settings, and make sure VT-x(or Virtualization Technology, depending on your BIOS) is enabled. If there isalso a setting for Execute Disable Bit, make sure that one is enabled as well.In most cases, both settings are enabled by default.
- If your system is protected against changes to BIOS, e.g. you have enabledBitLocker Drive Encryption or any other tamper protection mechanism, you mayneed to take preventive measures to avoid being locked out after changing thesaid BIOS settings.
After that, if you are on Windows 8 or later, make sure Hyper-V is disabled.This is especially important for Windows 10, which enables Hyper-V by default.The reason is that Hyper-V makes exclusive use of VT-x, preventing HAXM andother third-party hypervisors (such as VMware and VirtualBox) from seeing thathardware feature. There are a number of ways to disable Hyper-V; one of them isto bring up the Start menu, type Windows Features and Enter, uncheckHyper-V in the resulting dialog, and click on OK to confirm.
- Note that changing the Hyper-V setting could also trigger the alarm of thetamper protection mechanism (e.g. BitLocker) that may be enabled on your system.Again, make sure you won’t be locked out after the reboot.
Now you’re ready to install HAXM, which needs to run as a kernel-mode driver onWindows so as to execute the privileged VT-x instructions. Simply download thelatest HAXM release for Windows here, unzip, and runintelhaxm-android.exe
to launch the installation wizard. (Despite the filename, Android is not the only guest OS that can be accelerated by HAXM.)
If you haven’t installed QEMU, now is the time to do it. I recommend getting thelatest stable release from here. At the time of thiswriting, the latest stable release is 2.10.1 (build 20171006), so I downloadedqemu-w64-setup-20171006.exe
, which is an easy-to-use installer.
With all that, we’re ready to launch a real VM in QEMU. You can use yourfavorite QEMU disk image, provided that the guest OS installed there iscompatible with the x86 (i386) or x86_64 (amd64) architecture. My choice forthis tutorial is debian_wheezy_amd64_standard.qcow2
, which contains a freshinstallation of the standard Debian Wheezy system for x86_64, availablehere. To boot it, open a new command prompt window, switchto your QEMU installation directory (e.g. cd "C:\Program Files\qemu"
), andrun:
qemu-system-x86_64.exe -hda X:\path\to\debian_wheezy_amd64_standard.qcow2 -accel hax
You don’t have to leave the screen as the VM boots up, because soon you’ll beable to see the Debian shell and log in.
To feel the difference made by HAXM acceleration, shut down the VM, and relaunchit without -accel hax
:
qemu-system-x86_64.exe -hda X:\path\to\debian_wheezy_amd64_standard.qcow2
If you’re still not impressed, try a more sophisticated VM image such asdebian_wheezy_amd64_desktop.qcow2
, which boots to a desktop environment. VMslike this are hardly usable without hardware acceleration.
That’s it! I hope HAXM gives you a more enjoyable QEMU experience on Windows.You may run into issues at some point, because there are, inevitably, bugs inHAXM (e.g. booting an ISO image from CD-ROM doesn’t work at the moment). But thegood news is that HAXM is now open source on GitHub, so everyonecan help improve it. Please create an issue on GitHub if you have a question,bug report or feature request.
- tutorials
- HAXM