Re: [PATCH 1/5] conf: Add support for tpm-spapr to domain XML

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

 



On Fri, Jan 31, 2020 at 04:17:39PM -0500, Stefan Berger wrote:
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>
---
docs/formatdomain.html.in     |  4 +++-
docs/schemas/domaincommon.rng |  4 ++++
src/conf/domain_conf.c        | 24 +++++++++++++++++-------
src/conf/domain_conf.h        |  1 +
src/qemu/qemu_domain.c        |  6 ++++--
5 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 60a103d7c6..5a9835fbfe 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -8508,7 +8508,9 @@ 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. For ppc64/pseries guests, <code>tpm-spapr</code>

<span class="since">Since 6.1.0</span>, ...

+          is the default.
          <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.

@@ -13242,7 +13243,8 @@ static virDomainTPMDefPtr
virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
                        xmlNodePtr node,
                        xmlXPathContextPtr ctxt,
-                        unsigned int flags)
+                        unsigned int flags,
+                        virArch arch)
{
    virDomainTPMDefPtr def;
    VIR_XPATH_NODE_AUTORESTORE(ctxt);
@@ -13258,11 +13260,17 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
        return NULL;

    model = virXMLPropString(node, "model");
-    if (model != NULL &&
-        (def->model = virDomainTPMModelTypeFromString(model)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+    if (model != NULL) {
+        if ((def->model = virDomainTPMModelTypeFromString(model)) < 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                       _("Unknown TPM frontend model '%s'"), model);
-        goto error;
+            goto error;
+        }
+    } else {
+        if (ARCH_IS_PPC64(arch))
+            def->model = VIR_DOMAIN_TPM_MODEL_SPAPR;
+        else
+            def->model = VIR_DOMAIN_TPM_MODEL_TIS;
    }

Default models should be set in qemuDomainDeviceDefPostParse.
(that might require a new VIR_DOMAIN_TPM_MODEL_DEFAULT, since so far we
 relied on VIR_DOMAIN_TPM_MODEL_TIS having the value of 0)
The parser should just translate XML into libvirt structs.

    ctxt->node = node;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d3045b4bcd..ace611909d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7756,9 +7756,10 @@ qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm,

    switch (tpm->version) {
    case VIR_DOMAIN_TPM_VERSION_1_2:
-        /* only TIS available for emulator */
+        /* only TIS available for emulator (non-ppc64 case) */
        if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR &&
-            tpm->model != VIR_DOMAIN_TPM_MODEL_TIS) {
+            tpm->model != VIR_DOMAIN_TPM_MODEL_TIS &&

+            !ARCH_IS_PPC64(def->os.arch)) {

  tpm->model != VIR_DOMAIN_TPM_MODEL_SPAPR

no need to mention the architecture here.

Alternatively, are the comment and the condition just trying to say
1.2 + tpm-crb + emulator do not mix?

That might be shorter to write.

Jano

            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                           _("Unsupported interface %s for TPM 1.2"),
                           virDomainTPMModelTypeToString(tpm->model));
@@ -7793,6 +7794,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);
--
2.17.1


Attachment: signature.asc
Description: PGP signature


[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