]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Enable TPM CRB interface in the domain XML
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Thu, 26 Apr 2018 17:42:16 +0000 (13:42 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 3 May 2018 15:28:42 +0000 (11:28 -0400)
Enable the TPM CRB to be specified in the domain XML. This
now allows to describe the TPM device like this:

  <tpm model='tpm-crb'>
    <backend type='passthrough'>
      <device path='/dev/tpm0'/>
    </backend>
  </tpm>

Extend the XML schema to also allow tpm-crb.
Extend the documentation.
Add a test case for testing the XML parser and formatter.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
tests/qemuxml2argvdata/tpm-passthrough-crb.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/tpm-passthrough-crb.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index b65fea084d98139de446415cf6e807b9b7429bdd..6a0110e91dd6aa859ecf0d6adcbc885bb581e92c 100644 (file)
@@ -7625,7 +7625,8 @@ qemu-kvm -net nic,model=? /dev/null
 
     <p>
       The TPM device enables a QEMU guest to have access to TPM
-      functionality.
+      functionality. The TPM device may either be a TPM 1.2 or
+      a TPM 2.
     </p>
     <p>
       The TPM passthrough device type provides access to the host's TPM
@@ -7655,6 +7656,9 @@ qemu-kvm -net nic,model=? /dev/null
           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.
+          <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.
         </p>
       </dd>
       <dt><code>backend</code></dt>
index 7c02edb7f8a3ff5c16ae21115eedc6b0b1152a4a..7bad7dd27b35c0bd687b0c7b769ee6f534cb7e3c 100644 (file)
     <element name="tpm">
       <optional>
         <attribute name="model">
-          <value>tpm-tis</value>
+          <choice>
+            <value>tpm-tis</value>
+            <value>tpm-crb</value>
+          </choice>
         </attribute>
       </optional>
       <ref name="tpm-backend"/>
index b0257068dabba1ffdccbdfd5000a391b8b492905..6a2e28a1e7d92850392ea9c3ec9fde370b8d1643 100644 (file)
@@ -860,7 +860,8 @@ VIR_ENUM_IMPL(virDomainRNGBackend,
               "egd");
 
 VIR_ENUM_IMPL(virDomainTPMModel, VIR_DOMAIN_TPM_MODEL_LAST,
-              "tpm-tis")
+              "tpm-tis",
+              "tpm-crb")
 
 VIR_ENUM_IMPL(virDomainTPMBackend, VIR_DOMAIN_TPM_TYPE_LAST,
               "passthrough")
@@ -12606,8 +12607,6 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("Unknown TPM frontend model '%s'"), model);
         goto error;
-    } else {
-        def->model = VIR_DOMAIN_TPM_MODEL_TIS;
     }
 
     ctxt->node = node;
index 3e135c63640fbf2bcbf27a4a85ac647444660923..4c4c50488797e5744370817baa4a93b8e681fecf 100644 (file)
@@ -1279,6 +1279,7 @@ struct _virDomainHubDef {
 
 typedef enum {
     VIR_DOMAIN_TPM_MODEL_TIS,
+    VIR_DOMAIN_TPM_MODEL_CRB,
 
     VIR_DOMAIN_TPM_MODEL_LAST
 } virDomainTPMModel;
diff --git a/tests/qemuxml2argvdata/tpm-passthrough-crb.xml b/tests/qemuxml2argvdata/tpm-passthrough-crb.xml
new file mode 100644 (file)
index 0000000..2fce5ca
--- /dev/null
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+  <name>TPM-VM</name>
+  <uuid>11d7cd22-da89-3094-6212-079a48a309a1</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>512288</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-i440fx-2.12'>hvm</type>
+    <boot dev='hd'/>
+    <bootmenu enable='yes'/>
+  </os>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <tpm model='tpm-crb'>
+      <backend type='passthrough'>
+        <device path='/dev/tpm0'/>
+      </backend>
+    </tpm>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/tpm-passthrough-crb.xml b/tests/qemuxml2xmloutdata/tpm-passthrough-crb.xml
new file mode 100644 (file)
index 0000000..67ada46
--- /dev/null
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+  <name>TPM-VM</name>
+  <uuid>11d7cd22-da89-3094-6212-079a48a309a1</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>512288</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-i440fx-2.12'>hvm</type>
+    <boot dev='hd'/>
+    <bootmenu enable='yes'/>
+  </os>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <tpm model='tpm-crb'>
+      <backend type='passthrough'>
+        <device path='/dev/tpm0'/>
+      </backend>
+    </tpm>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
index 4b5aa2315e5d61d46f8a2840aba09f7470ce4bbd..21fb4112471be5a8b34394e94c996979d036b224 100644 (file)
@@ -672,6 +672,7 @@ mymain(void)
     DO_TEST("usb-ich9-ehci-addr", NONE);
     DO_TEST("disk-copy_on_read", NONE);
     DO_TEST("tpm-passthrough", NONE);
+    DO_TEST("tpm-passthrough-crb", NONE);
 
     DO_TEST("metadata", NONE);
     DO_TEST("metadata-duplicate", NONE);