[virt-manager] [PATCH 3/7] virtinst/guest: Use tpm 1.2 if 2.0 isn't in domcapabilities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


The swtpm(tpm emulator) advertises the TPM version since v0.7.0.
Libvirt reports this information in domcaps since v8.6.0.

By commit eb58c09f, virt-install adds an emulated TPM device if UEFI is
If the tpm emulator isn't capable of 2.0, We should use tpm 1.2 instead
of the default(2.0), Otherwise it fails with this error message:

libvirt.libvirtError: unsupported configuration: TPM version '2.0' is not supported

Signed-off-by: Lin Ma <lma@xxxxxxx>
 tests/data/cli/compare/virt-install-amd-sev.xml | 4 ++--
 virtinst/guest.py                               | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/data/cli/compare/virt-install-amd-sev.xml b/tests/data/cli/compare/virt-install-amd-sev.xml
index 68b236dd..3d9bcd53 100644
--- a/tests/data/cli/compare/virt-install-amd-sev.xml
+++ b/tests/data/cli/compare/virt-install-amd-sev.xml
@@ -66,8 +66,8 @@
       <target type="virtio" name="com.redhat.spice.0"/>
     <input type="tablet" bus="usb"/>
-    <tpm model="tpm-crb">
-      <backend type="emulator"/>
+    <tpm>
+      <backend type="emulator" version="1.2"/>
     <graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
       <image compression="off"/>
diff --git a/virtinst/guest.py b/virtinst/guest.py
index 123abfb2..2408d5d4 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -1059,6 +1059,8 @@ class Guest(XMLBuilder):
         log.debug("Adding default TPM")
         dev = DeviceTpm(self.conn)
         dev.type = DeviceTpm.TYPE_EMULATOR
+        if not self.lookup_domcaps().supports_tpm_v2():
+            dev.version = DeviceTpm.VERSION_1_2
     def _add_default_memballoon(self):

[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux