Set up a virtual TPM for use in qemu/libvirt on Fedora 23+

Step-by-step guide

  1. Install the @virtualization package group in fedora to install libvirt
  2. If you want to use the packages already compiled, skip to Step 4.
  3. a. Initialize a clean mock chroot: 


    b. Install the following dependencies, taken from https://github.com/stefanberger/swtpm/blob/master/INSTALL

     

    c. Enter the chroot and clone the swtpm repo:

     

    d. Compile and install swtpm:

     

    e. If everything succeeded thusfar, create the srpm and rpm and install:

  4. To install our pre-compiled rpms:

  5. To install our pre-compiled qemu:

  6. Run the swtpm setup script (sudo or as root) to initialize and create a virtual TPM device.  Note default parameters will create /dev/vtpm0.  You must run this script and load a TPM every time you use it in libvirt, because it self-destructs after it detects that it isn't being used anymore. You may also have to disable SElinux for now until a workaround is found.

     

  7. Add the generated XML from step 6 to your virtual machine's XML file and create it!