[PATCH v3 2/6] conf: Add support for tpm-spapr to domain XML

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

 



From: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>

This patch adds support for the tpm-spapr device model for ppc64. The XML for
this type of TPM looks as follows:

 <tpm model='tpm-spapr'>
   <backend type='emulator'/>
 </tpm>

Extend the documentation.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 docs/formatdomain.html.in     |  7 +++++--
 docs/schemas/domaincommon.rng |  4 ++++
 src/conf/domain_conf.c        |  1 +
 src/conf/domain_conf.h        |  1 +
 src/qemu/qemu_domain.c        | 19 +++++++++++++------
 5 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 60a103d7c6..44e2062d01 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -8508,10 +8508,13 @@ qemu-kvm -net nic,model=? /dev/null
         <p>
           The <code>model</code> attribute specifies what device
           model QEMU provides to the guest. If no model name is provided,
-          <code>tpm-tis</code> will automatically be chosen.
+          <code>tpm-tis</code> will automatically be chosen for non-PPC64
+          architectures.
           <span class="since">Since 4.4.0</span>, another available choice
           is the <code>tpm-crb</code>, which should only be used when the
-          backend device is a TPM 2.0.
+          backend device is a TPM 2.0. <span class="since">Since 6.1.0</span>,
+          pSeries guests on PPC64 are supported and the default is
+          <code>tpm-spapr</code>.
         </p>
       </dd>
       <dt><code>backend</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ea237a05e5..9577d26c2a 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4383,6 +4383,7 @@
           <choice>
             <value>tpm-tis</value>
             <value>tpm-crb</value>
+            <value>tpm-spapr</value>
           </choice>
         </attribute>
       </optional>
@@ -4390,6 +4391,9 @@
       <optional>
         <ref name="alias"/>
       </optional>
+      <optional>
+        <ref name="address"/>
+      </optional>
     </element>
   </define>
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 040643e78f..51ae520897 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1128,6 +1128,7 @@ VIR_ENUM_IMPL(virDomainTPMModel,
               "default",
               "tpm-tis",
               "tpm-crb",
+              "tpm-spapr",
 );
 
 VIR_ENUM_IMPL(virDomainTPMBackend,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index cb4a0cedf0..2db3c19473 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1255,6 +1255,7 @@ typedef enum {
     VIR_DOMAIN_TPM_MODEL_DEFAULT,
     VIR_DOMAIN_TPM_MODEL_TIS,
     VIR_DOMAIN_TPM_MODEL_CRB,
+    VIR_DOMAIN_TPM_MODEL_SPAPR,
 
     VIR_DOMAIN_TPM_MODEL_LAST
 } virDomainTPMModel;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e152448cc6..39513a726e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7760,9 +7760,9 @@ qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm,
 
     switch (tpm->version) {
     case VIR_DOMAIN_TPM_VERSION_1_2:
-        /* only TIS available for emulator */
+        /* TPM 1.2 + CRB do not work */
         if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR &&
-            tpm->model != VIR_DOMAIN_TPM_MODEL_TIS) {
+            tpm->model == VIR_DOMAIN_TPM_MODEL_CRB) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Unsupported interface %s for TPM 1.2"),
                            virDomainTPMModelTypeToString(tpm->model));
@@ -7797,6 +7797,7 @@ qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm,
     case VIR_DOMAIN_TPM_MODEL_CRB:
         flag = QEMU_CAPS_DEVICE_TPM_CRB;
         break;
+    case VIR_DOMAIN_TPM_MODEL_SPAPR:
     case VIR_DOMAIN_TPM_MODEL_LAST:
     default:
         virReportEnumRangeError(virDomainTPMModel, tpm->model);
@@ -9036,10 +9037,16 @@ qemuDomainHostdevDefPostParse(virDomainHostdevDefPtr hostdev,
 
 
 static int
-qemuDomainTPMDefPostParse(virDomainTPMDefPtr tpm)
+qemuDomainTPMDefPostParse(virDomainTPMDefPtr tpm,
+                          virArch arch)
 {
-    if (tpm->model == VIR_DOMAIN_TPM_MODEL_DEFAULT)
-        tpm->model = VIR_DOMAIN_TPM_MODEL_TIS;
+    if (tpm->model == VIR_DOMAIN_TPM_MODEL_DEFAULT) {
+        if (ARCH_IS_PPC64(arch))
+            tpm->model = VIR_DOMAIN_TPM_MODEL_SPAPR;
+        else
+            tpm->model = VIR_DOMAIN_TPM_MODEL_TIS;
+    }
+
     return 0;
 }
 
@@ -9098,7 +9105,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
         break;
 
     case VIR_DOMAIN_DEVICE_TPM:
-        ret = qemuDomainTPMDefPostParse(dev->data.tpm);
+        ret = qemuDomainTPMDefPostParse(dev->data.tpm, def->os.arch);
         break;
 
     case VIR_DOMAIN_DEVICE_LEASE:
-- 
2.17.1






[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux