]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: add support for 'debug' parameter on TPM emulator
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 4 Jul 2024 11:08:55 +0000 (12:08 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 5 Jul 2024 13:43:15 +0000 (14:43 +0100)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
docs/formatdomain.rst
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/schemas/domaincommon.rng
tests/qemuxmlconfdata/tpm-emulator-tpm2.xml

index 5c09b87d2b05b15022fc739a03ee5f361b1f8aa7..fbd05e089dd6f844b97bd8fabd3f5402ac8c58a5 100644 (file)
@@ -8097,7 +8097,7 @@ Example: usage of the TPM Emulator
      ...
      <devices>
        <tpm model='tpm-tis'>
-         <backend type='emulator' version='2.0'>
+         <backend type='emulator' version='2.0' debug='5'>
            <encryption secret='6dd3e4a5-1d76-44ce-961f-f119f5aad935'/>
            <active_pcr_banks>
                <sha256/>
@@ -8141,7 +8141,9 @@ Example: usage of the TPM Emulator
    ``emulator``
       For this backend type the 'swtpm' TPM Emulator must be installed on the
       host. Libvirt will automatically start an independent TPM emulator for
-      each QEMU guest requesting access to it.
+      each QEMU guest requesting access to it. :since:`10.6.0`, the ``debug``
+      parameter can be used to enable logging in the emulator backend, and
+      accepts non-zero integer values. 
 
 ``version``
    The ``version`` attribute indicates the version of the TPM. This attribute
index 7033b4e9fe258d93cc26dba390fba610954fee89..6080f4f90a540dee06bea2a203242b026e1449bf 100644 (file)
@@ -10800,6 +10800,10 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt,
                            &def->data.emulator.version) < 0)
             goto error;
 
+        if (virXMLPropUInt(backends[0], "debug", 10, VIR_XML_PROP_NONE,
+                           &def->data.emulator.debug) < 0)
+            goto error;
+
         if (!(def->data.emulator.source = virDomainChrSourceDefNew(xmlopt)))
             goto error;
         secretuuid = virXPathString("string(./backend/encryption/@secret)", ctxt);
@@ -24882,6 +24886,9 @@ virDomainTPMDefFormat(virBuffer *buf,
         }
         if (def->data.emulator.persistent_state)
             virBufferAddLit(&backendAttrBuf, " persistent_state='yes'");
+        if (def->data.emulator.debug != 0)
+            virBufferAsprintf(&backendAttrBuf, " debug='%u'",
+                              def->data.emulator.debug);
         if (def->data.emulator.hassecretuuid) {
             char uuidstr[VIR_UUID_STRING_BUFLEN];
 
index 2818a9f1f5631407ca48f43e222416b223cf7ded..1b9d07f1a426b3ab2e7fddab109f186c5ea6e1b5 100644 (file)
@@ -1476,6 +1476,7 @@ struct _virDomainTPMDef {
             virDomainChrSourceDef *source;
             char *storagepath;
             char *logfile;
+            unsigned int debug;
             unsigned char secretuuid[VIR_UUID_BUFLEN];
             bool hassecretuuid;
             bool persistent_state;
index 33e34255f483151118d9f47e4bda9e07fe503b2b..b163e4eece0939ab2554bfb6ac06a01bbbf8e204 100644 (file)
               <ref name="virYesNo"/>
             </attribute>
           </optional>
+          <optional>
+            <attribute name="debug">
+              <ref name="uint8"/>
+            </attribute>
+          </optional>
         </group>
         <group>
           <attribute name="type">
index 79acde218b66445dededd79035c18e6d621be509..8a613db456a431e63220e7aa4d6a4a2f73e324c1 100644 (file)
@@ -28,7 +28,7 @@
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <tpm model='tpm-tis'>
-      <backend type='emulator' version='2.0'>
+      <backend type='emulator' version='2.0' debug='3'>
         <encryption secret='b4a117f1-8af2-44a4-91b8-7f0d2d4d68a3'/>
         <active_pcr_banks>
           <sha256/>