Actually booting Windows 11 using a KVM virtual machine

Hello,

I have been trying (unsuccessfully) to use libvirt to run a Windows 11 (on ARM) virtual machine. Rock 5b 16 GB RAM.

Everything seems to work up to the point of trying to boot the system. This is the error:

Unable to complete install: 'internal error: qemu unexpectedly closed the monitor: 2023-11-22T22:25:37.427436Z qemu-system-aarch64: device requires 67108864 bytes, block backend provides 131072 bytes'

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 72, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/createvm.py", line 2008, in _do_async_install
    installer.start_install(guest, meter=meter)
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 695, in start_install
    domain = self._create_guest(
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 637, in _create_guest
    domain = self.conn.createXML(initial_xml or final_xml, 0)
  File "/usr/lib/python3/dist-packages/libvirt.py", line 4400, in createXML
    raise libvirtError('virDomainCreateXML() failed')
libvirt.libvirtError: internal error: qemu unexpectedly closed the monitor: 2023-11-22T22:25:37.427436Z qemu-system-aarch64: device requires 67108864 bytes, block backend provides 131072 bytes

The UEFI files are provided by the package qemu-efi-aarch64 and are decidedly 64 MB in size. I added the SPICE server and video output. I tried using other UEFI images (padded OVMF, padded self-compiled edk2 for aarch64, images copied from an amd64 version of the qemu-efi-aarch64 package for Mantic) with the same results. I used the guides available online to pad the images with dd, same result every time.

QEMU emulation of x86_64 systems works fine.

The host system is Armbian (Ubuntu Jammy), kernel:
Linux rock-5b 5.10.110-rockchip-rk3588 #23.02.2 SMP Fri Feb 17 23:59:20 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

Any ideas will be appreciated. Also, do I have to disable the first 4 cores for the KVM virtualization to work - and otherwise it will be qemu?

This: https://blog.csdn.net/weixin_42758299/article/details/115460776 suggests you need to add an additional line in your config.

1 Like

Thanks, it seems to have gone further. Now the error is:

Property 'host-arm-cpu.hv-relaxed' not found

full log:

Unable to complete install: 'internal error: qemu unexpectedly closed the monitor: 2023-11-24T21:52:51.720096Z qemu-system-aarch64: can't apply global host-arm-cpu.hv-relaxed=on: Property 'host-arm-cpu.hv-relaxed' not found'

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 72, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/createvm.py", line 2008, in _do_async_install
    installer.start_install(guest, meter=meter)
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 695, in start_install
    domain = self._create_guest(
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 637, in _create_guest
    domain = self.conn.createXML(initial_xml or final_xml, 0)
  File "/usr/lib/python3/dist-packages/libvirt.py", line 4400, in createXML
    raise libvirtError('virDomainCreateXML() failed')
libvirt.libvirtError: internal error: qemu unexpectedly closed the monitor: 2023-11-24T21:52:51.720096Z qemu-system-aarch64: can't apply global host-arm-cpu.hv-relaxed=on: Property 'host-arm-cpu.hv-relaxed' not found

Does this mean I can’t use KVM virtualization? (hmm, this also happens on QEMU TCG)

EDIT:

OK, I turned these options in the xml file:

    <hyperv>
      <relaxed state="on"/>
      <vapic state="on"/>
      <spinlocks state="on" retries="8191"/>
    </hyperv>

to “off” and the machine actually started! With KVM virtualization - but there is nothing on the display so far. It does not seem to load any data from the installer cd-rom that I supplied (either SCSI or USB)

Before you spend any more time on this, are you aware that Windows 11 requires TPM 2.0 and thus running it in a VM requires encryption and some additional setup? Maybe check this first: https://macroform-node.medium.com/building-a-windows-11-vm-with-qemu-using-tpm-emulation-for-research-malware-analysis-part-1-8846378b9582

1 Like

You can add an emulated TPM 2.0 in qemu with no problem - I use virt-manager, it has an option to do this.

I kinda hate how all the guides use super long console commands to describe how to run the VM…

Try compiling latest qemu from source. Maybe the CPU/SoC is too recent and unsupported by Qemu in Ubuntu provided version? I myself am trying that approach to see if it works.

1 Like

Yeah, I will try this. I also tried compiling libvirt from source (9.9.0) which was successful, but when I try to run it, it shows me that it doesn’t support TPM version 2.0 (libvirt from the Ubuntu Jammy package doesn’t have this issue).

I tried it. It still shows same error. I tried to edit libvirt machine xml to this:
...
<relaxed state="off"/>
<vapic state="off"/>
<spinlocks state="off"/>
...
(because disabling just “relaxed” results in complaints about missing other two features)
It prompts for “press any key to boot from CD/DVD”, i press the key and it starts booting up, and immediately freezes with one cpu core at 100% usage.

Oh, so you get display output? I get absolutely nothing. Could you share your full xml? (I also turned all these to “off”, I thought this was clear). I think the win11 default xml was made just for x86_64 and these options shouldn’t even exist for ARM processors - or do they have Hyper-V?

OK. I gave up on recompiling and just tried a bleeding edge image (Mantic on 6.7.0-rc1). The result is similar - I get one core pinned at 100%, but it is at least trying to boot from the CD. I will leave it overnight and see what happens.