[libvirt] [PATCH v2 2/4] qemu: introduce chardevStdioLogd to qemu private data

Pavel Hrdina posted 4 patches 7 years, 11 months ago
[libvirt] [PATCH v2 2/4] qemu: introduce chardevStdioLogd to qemu private data
Posted by Pavel Hrdina 7 years, 11 months ago
In QEMU driver we can use virtlogd as stdio handler for source backend
of char devices if current QEMU is new enough and it's enabled in
qemu.conf.  We should store this information while starting a guest
because the config option may change while the guest is running.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---

Notes:
    new in v2

 src/qemu/qemu_domain.c  | 6 ++++++
 src/qemu/qemu_domain.h  | 3 +++
 src/qemu/qemu_process.c | 9 +++++++++
 3 files changed, 18 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 0a85ee9d74..b0e3df7009 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1873,6 +1873,9 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
     virBufferEscapeString(buf, "<channelTargetDir path='%s'/>\n",
                           priv->channelTargetDir);
 
+    if (priv->chardevStdioLogd)
+        virBufferAddLit(buf, "<chardevStdioLogd/>");
+
     return 0;
 }
 
@@ -2141,6 +2144,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
     if (qemuDomainSetPrivatePathsOld(driver, vm) < 0)
         goto error;
 
+    priv->chardevStdioLogd = virXPathBoolean("boolean(./chardevStdioLogd)",
+                                             ctxt) == 1;
+
     return 0;
 
  error:
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index aebd91ad37..9fb7c339a3 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -293,6 +293,9 @@ struct _qemuDomainObjPrivate {
     /* Used when fetching/storing the current 'tls-creds' migration setting */
     /* (not to be saved in our private XML). */
     char *migTLSAlias;
+
+    /* If true virtlogd is used as stdio handler for character devices. */
+    bool chardevStdioLogd;
 };
 
 # define QEMU_DOMAIN_PRIVATE(vm)	\
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index be031b56b9..77c2e5f6d3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5367,6 +5367,7 @@ qemuProcessPrepareDomain(virConnectPtr conn,
     size_t i;
     char *nodeset = NULL;
     qemuDomainObjPrivatePtr priv = vm->privateData;
+    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     virCapsPtr caps;
 
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
@@ -5403,6 +5404,13 @@ qemuProcessPrepareDomain(virConnectPtr conn,
         }
     }
 
+    /* Whether we should use virtlogd as stdio handler for character
+     * devices source backend. */
+    if (cfg->stdioLogD &&
+        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHARDEV_FILE_APPEND)) {
+        priv->chardevStdioLogd = true;
+    }
+
     /*
      * Normally PCI addresses are assigned in the virDomainCreate
      * or virDomainDefine methods. We might still need to assign
@@ -5466,6 +5474,7 @@ qemuProcessPrepareDomain(virConnectPtr conn,
  cleanup:
     VIR_FREE(nodeset);
     virObjectUnref(caps);
+    virObjectUnref(cfg);
     return ret;
 }
 
-- 
2.13.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/4] qemu: introduce chardevStdioLogd to qemu private data
Posted by John Ferlan 7 years, 11 months ago

On 05/29/2017 10:31 AM, Pavel Hrdina wrote:
> In QEMU driver we can use virtlogd as stdio handler for source backend
> of char devices if current QEMU is new enough and it's enabled in
> qemu.conf.  We should store this information while starting a guest
> because the config option may change while the guest is running.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
> 
> Notes:
>     new in v2
> 
>  src/qemu/qemu_domain.c  | 6 ++++++
>  src/qemu/qemu_domain.h  | 3 +++
>  src/qemu/qemu_process.c | 9 +++++++++
>  3 files changed, 18 insertions(+)
> 

FWIW: This wouldn't git am -3 apply on top of tree, I found if I went
"back to" commit '880b1a2e', then I could apply.  I was mainly a random
selection, although I did also try the patch just before jtomko's series
as well.

In any case,

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list