QEMU (on Windows)

Some notes and tips on how to build and run virtual machines (VMs) with the Quick Emulator (QEMU) on Windows.

Preparation

  1. Download and install QEMU: “QEMU is a generic and open source machine emulator and virtualizer”.

  2. Performance tip for a Windows host: Open PowerShell (as Administrator!) and activate the Windows Hypervisor Platform feature (called “whpx” in QEMU):
    (At the end, you will be asked to reboot the computer to apply the changes.)

    > Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -All
    

Create an empty disk image file for a VM

Use the program qemu-img (usually installed in C:\Program Files\qemu) with the command create to generate an empty disk image file (i.e. the “hard-disk” of the future VM).

Example (for a Haiku VM):

> qemu-img.exe create -f qcow2 C:\VMs\haiku.img 8G

Install an operating system to a VM

The program qemu-system-x86_64.exe (usually installed in C:\Program Files\qemu) is the main executable of QEMU for a x86-64-bit System running Windows: It provides the means to run a guest operating system on a Windows host.

Example: Install Haiku on a virtual x86-64-bit-PC

A virtual machine that represents a standard (x86-64-bit) PC and boots the Haiku ISO on boot from the “CD-ROM drive”:
(should all be on one line!)

> qemu-system-x86_64.exe -machine q35
                         -cpu host
                         -accel whpx
                         -drive file="C:\<path>\haiku.img"
                         -smp 4
                         -m 8G
                         -name Haiku
                         -usb
                         -device usb-tablet
                         -net user
                         -cdrom "C:\<path>\haiku-...-anyboot.iso" # only needed for installation
                         -boot menu=on                            # only needed for installation

Optional:

Run the VM

After the OS is installed in the disk image file, run the same command as above (but without the parameters for the boot medium (-cdrom) and or boot order (-boot)) to start the VM (for daily use, either put it in a script, or use a GUI front-end).

Check (with Haiku R1b6) and conclusion (for now)

Maybe I haven’t yet found that one magic trick, but for now, I think I will leave it at that:
I know now how to create and run a VM with QEMU (in general), have documented the basics (for future endeavors) here, in my KB.
But my original plan, to use Haiku more often, in a VM, sadly doesn’t look so appealing at the moment…