[PATCH 1/2] conf: add support for 'debug' parameter on TPM emulator

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

 



Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 docs/formatdomain.rst                       | 6 ++++--
 src/conf/domain_conf.c                      | 7 +++++++
 src/conf/domain_conf.h                      | 1 +
 src/conf/schemas/domaincommon.rng           | 5 +++++
 tests/qemuxmlconfdata/tpm-emulator-tpm2.xml | 2 +-
 5 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 5c09b87d2b..fbd05e089d 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -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
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index cb1154b23f..ab313adf6e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10783,6 +10783,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);
@@ -24865,6 +24869,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];
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 2818a9f1f5..1b9d07f1a4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -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;
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index 844a931deb..981ad10a37 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -5913,6 +5913,11 @@
               <ref name="virYesNo"/>
             </attribute>
           </optional>
+          <optional>
+            <attribute name="debug">
+              <ref name="uint8"/>
+            </attribute>
+          </optional>
         </group>
         <group>
           <attribute name="type">
diff --git a/tests/qemuxmlconfdata/tpm-emulator-tpm2.xml b/tests/qemuxmlconfdata/tpm-emulator-tpm2.xml
index 79acde218b..8a613db456 100644
--- a/tests/qemuxmlconfdata/tpm-emulator-tpm2.xml
+++ b/tests/qemuxmlconfdata/tpm-emulator-tpm2.xml
@@ -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/>
-- 
2.45.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