How to run Hyper-V/Docker on Windows 10 in qemu/libvirt/kvm

Hyper-V on Windows requires nested virtualization, since it runs linux in a virtual machine. You need Hyper-V to run docker. Windows 10 does not allow virtualization when it is run in kvm. If you open the task manager, it does not even show “Virtualization: Not available”.

The trick is to make Windows 10 think it is running on real hardware, with virtualization enabled. So you need hypervisor off but vmx on; on the qemu command line this would be –cpu -hypervisor,+vmx.

In Virtual Manager, you have to edit the xml. Go to Edit -> Preferences -> Enable XML editting. Now in the CPU xml for your Windows 10 machine, change your cpu element to:

<cpu mode="custom" match="exact" check="partial">
<model fallback="allow">IvyBridge</model>
<feature policy="disable" name="hypervisor"/>
<feature policy="require" name="vmx"/>

You can download a time-limited Windows 10 VM from Microsoft. The VirtualBox and vmware downloads contain a .vmdk file, which can be converted to qcow2 using qemu-img.

The hypervisor hack was inspired by a similar hack for vmware.