[PATCH 7/7] tpm.py: make MODEL_SPAPR the default when running in ppc64

Daniel Henrique Barboza danielhb413 at gmail.com
Tue Jun 2 20:39:38 UTC 2020


Users are fond of using "--tpm /dev/tpm0" to create a TPM device
for their VMs. ppc64 users, however, are experiencing errors because
the default TPM model is 'tpm-tis', which does not work in ppc64, and
they need to specify 'model=tpm-spapr' to work around that.

This patch makes the default TPM model change to 'tpm-spapr' when
running virt-install on a ppc64 host. A new test was added in test_cli.py
to test this new condition. This also keeps the 100% coverage of
the tpm.py file.

CC: Satheesh Rajendran <sathnaga at linux.vnet.ibm.com>
CC: Stefan Berger <stefanb at linux.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 .../virt-install-ppc64-pseries-tpm.xml        | 37 +++++++++++++++++++
 tests/test_cli.py                             |  1 +
 virtinst/devices/tpm.py                       |  3 ++
 3 files changed, 41 insertions(+)
 create mode 100644 tests/data/cli/compare/virt-install-ppc64-pseries-tpm.xml

diff --git a/tests/data/cli/compare/virt-install-ppc64-pseries-tpm.xml b/tests/data/cli/compare/virt-install-ppc64-pseries-tpm.xml
new file mode 100644
index 00000000..bf82d1d7
--- /dev/null
+++ b/tests/data/cli/compare/virt-install-ppc64-pseries-tpm.xml
@@ -0,0 +1,37 @@
+<domain type="qemu">
+  <name>vm-ppc64</name>
+  <uuid>00000000-1111-2222-3333-444444444444</uuid>
+  <memory>65536</memory>
+  <currentMemory>65536</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch="ppc64" machine="pseries">hvm</type>
+    <boot dev="network"/>
+  </os>
+  <clock offset="utc"/>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <disk type="file" device="disk">
+      <driver name="qemu" type="qcow2"/>
+      <source file="/dev/default-pool/testvol1.img"/>
+      <target dev="vda" bus="virtio"/>
+    </disk>
+    <controller type="usb" model="qemu-xhci" ports="15"/>
+    <console type="pty"/>
+    <channel type="unix">
+      <source mode="bind"/>
+      <target type="virtio" name="org.qemu.guest_agent.0"/>
+    </channel>
+    <input type="tablet" bus="usb"/>
+    <input type="keyboard" bus="usb"/>
+    <tpm model="tpm-spapr">
+      <backend type="passthrough">
+        <device path="/dev/tpm0"/>
+      </backend>
+    </tpm>
+    <graphics type="vnc" port="-1"/>
+    <video>
+      <model type="vga"/>
+    </video>
+  </devices>
+</domain>
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 740e390c..90b5ba35 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -963,6 +963,7 @@ c.add_compare("--os-variant fedora20 --nodisks --boot network --graphics default
 c.add_compare("--arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)s --disk device=cdrom --os-variant fedora20 --network none", "ppc64-pseries-f20")
 c.add_compare("--arch ppc64 --boot network --disk %(EXISTIMG1)s --os-variant fedora20 --network none", "ppc64-machdefault-f20")
 c.add_compare("--connect %(URI-KVM-PPC64LE)s --import --disk %(EXISTIMG1)s --os-variant fedora20 --panic default", "ppc64le-kvm-import")
+c.add_compare("--arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)s --graphics vnc --network none --tpm /dev/tpm0", "ppc64-pseries-tpm")  # default TPM for ppc64
 
 # s390x tests
 c.add_compare("--arch s390x --machine s390-ccw-virtio --connect %(URI-KVM-S390X)s --boot kernel=/kernel.img,initrd=/initrd.img --disk %(EXISTIMG1)s --disk %(EXISTIMG3)s,device=cdrom --os-variant fedora21", "s390x-cdrom", prerun_check=has_old_osinfo)
diff --git a/virtinst/devices/tpm.py b/virtinst/devices/tpm.py
index 82b64479..03907e2b 100644
--- a/virtinst/devices/tpm.py
+++ b/virtinst/devices/tpm.py
@@ -41,3 +41,6 @@ class DeviceTpm(Device):
             self.type = self.TYPE_PASSTHROUGH
         if not self.model:
             self.model = self.MODEL_TIS
+
+            if guest.os.is_ppc64():
+                self.model = self.MODEL_SPAPR
-- 
2.26.2




More information about the virt-tools-list mailing list