DEV Community

loading...

Qemu Windows Using Qemu on Windows 10 Home Edition

whaleshark271 profile image whaleshark ・3 min read

Recently I had an assignment that asked us to use Qemu. It took me some trouble to get it running on Windows so I thought I could document it here in case I need it in the future. It would be nice if this helps someone, too!

  1. Download Qemu and .iso
  2. Add Qemu path to environment variables settings
  3. Create an image
  4. Starting the VM
  5. Some problems you might encounter

1. Download Qemu and .iso

Click here to download Qemu and download your desired .iso file. After installing Qemu, open Windows Powershell and type qemu-img. Now you might see that it does not recognize the command. This takes us to number 2.

2. Add Qemu path to environment variables settings

Copy the Qemu path (should be C:\Program Files\qemu if you didn't change anything) and open environment variables settings by Right click on "This PC" -> Properties -> Advanced system settings -> Environment Variables.
Click on path once and click "Edit...". Click "New" and paste the Qemu path.

Here's the youtube video that taught me how to do this. Otherwise, I'd stuck here forever :P.

3. Create an image

Now you can create an image by typing qemu-img create -f qcow2 [name].qcow2 30G.

Alt Text

4. Starting the VM

When starting the VM, you would want to use an accelerator, or else it is going to take a lot of time installing the OS. It took me more than an hour to install Ubuntu 16.04 without the accelerator.

For Windows, there are two options: HAXM and whpx. Note that HAXM can only be used on Windows Enterprise/Pro/Education so I'm not going to introduce it here. Although I did get it working for whatever reason and after a Windows update, it just stopped working.🤔

Go to Windows Features and tick Windows Hypervisor Platform. After that, restart the computer and type this command in the powershell (in the directory where the image and .iso resides): qemu-system-x86_64 -accel whpx -hda .\[name].qcow2 -m 512 -net nic,model=virtio -net user -cdrom .\[name].iso -vga std -boot strict=on. It should start up and you can proceed to install the OS.

The second time you start up the machine you don't need to type -cdrom anymore. Just qemu-system-x86_64 -accel whpx -hda .\[name].qcow2 -m 512 -net nic,model=virtio -net user -vga std -boot strict=on should do it.

Alt Text

5. Some problems you might encounter

  • You might get stuck when rebooting after installing the OS
    My friend and I both encountered the problem and we both used Ubuntu 16.04 for the VM. Just close the window and restart it and it should work fine. Pretty sure this is not best practice, though.

  • You can't seem to do migration using whpx
    I got this error when trying to do migration. I found this Github code and I think it has something to do with whpx. I'm not sure how to resolve this. My TA simply allowed me to do migration on the server.

Alt Text

  • Untick Windows Hypervisor Platform when using VirtualBox You might get an error from VirtualBox when starting the machine if you keep it ticked. Remember to untick it.

Discussion (2)

pic
Editor guide
Collapse
aloyanren profile image
Ren Aloyan

qemu-system-x86_64: -accel whpx: Could not load library WinHvPlatform.dll.
qemu-system-x86_64: -accel whpx: failed to initialize whpx: Function not implemented

Collapse
burntmelon profile image
burnt-melon

Just run the command without it, I got the error
PS C:\Users\user\Downloads\isofiles> qemu-system-x86_64 -accel whpx -hda ....qcow2 -m 512 -net nic,model=virtio -net user -cdrom ....iso -vga std -boot strict=on
C:\Program Files\qemu\qemu-system-x86_64.exe: -accel whpx: WHPX: No accelerator found, hr=00000000
C:\Program Files\qemu\qemu-system-x86_64.exe: -accel whpx: failed to initialize whpx: No space left on device.
until I removed that part and it worked perfectly fine.