tpm.py: make MODEL_SPAPR the default when running in ppc64

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.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
CC: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
CC: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Daniel Henrique Barboza 2020-06-03 10:14:36 -03:00 committed by Cole Robinson
parent 721108002d
commit ae3e92f0f5
3 changed files with 41 additions and 0 deletions

View File

@ -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>

View File

@ -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)

View File

@ -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