qemu failed to passthrough a tpm device

Hi i'd like to install windows 11 on kvm.

I have tpm enabled on my system. ubuntu 21.04 (qemu 5.2+dfsg-9ubuntu3.1)

ls -ls /dev/tpm*

0 crw-rw-rw- 1 root root  10,   224 Sep 25 18:18 /dev/tpm0
0 crw-rw-rw- 1 tss  tss  253, 65536 Sep 25 18:18 /dev/tpmrm0

the w11 xml file contains the passthrough code:

<tpm model="tpm-tis">
  <backend type="passthrough">
    <device path="/dev/tpm0"/>
  </backend>
</tpm>

When starting the vm I get the following error:

Unable to complete install: 'internal error: qemu unexpectedly closed the monitor: 2021-09-26T06:28:55.041197Z qemu-system-x86_64: -tpmdev passthrough,id=tpm-tpm0,path=/dev/fdset/3,cancel-path=/dev/fdset/4: '/dev/fdset/3' is not a TPM device.'

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 65, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/createvm.py", line 2001, in _do_async_install
    installer.start_install(guest, meter=meter)
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 701, in start_install
    domain = self._create_guest(
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 649, in _create_guest
    domain = self.conn.createXML(install_xml or final_xml, 0)
  File "/usr/lib/python3.9/site-packages/libvirt.py", line 4376, in createXML
    raise libvirtError('virDomainCreateXML() failed')
libvirt.libvirtError: internal error: qemu unexpectedly closed the monitor: 2021-09-26T06:28:55.041197Z qemu-system-x86_64: -tpmdev passthrough,id=tpm-tpm0,path=/dev/fdset/3,cancel-path=/dev/fdset/4: '/dev/fdset/3' is not a TPM device.

Any ideas how to properly pass the tpm to the vm.

Thanks


Solution 1:

I have run into the same error.

I refered the next web page and found the Apparmor makes this problem.

I added /dev/tpm0 rw in /etc/apparmor.d/abstractions/libvirt-qemu and restarted apparmor. The error dialog will not show.

I hope this make some help.

Ref. Here’s what you’ll need to upgrade to Windows 11 https://arstechnica.com/gadgets/2021/06/heres-what-youll-need-to-upgrade-to-windows-11/?utm_brand=arstechnica&utm_source=twitter&utm_social-type=owned&utm_medium=social