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(a)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