On 11/12/2015 12:19 PM, Daniel P. Berrange wrote:
Instead of writing directly to a log file descriptor, change
qemuLogOperation to use qemuDomainLogContextWrite().
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_process.c | 39 ++++++++++++++++-----------------------
1 file changed, 16 insertions(+), 23 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 85ad3a5..f729065 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4064,40 +4064,33 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
static void
qemuLogOperation(virDomainObjPtr vm,
const char *msg,
- int logfd,
- virCommandPtr cmd)
+ virCommandPtr cmd,
+ qemuDomainLogContextPtr logCtxt)
{
char *timestamp;
- char *logline;
qemuDomainObjPrivatePtr priv = vm->privateData;
int qemuVersion = virQEMUCapsGetVersion(priv->qemuCaps);
const char *package = virQEMUCapsGetPackage(priv->qemuCaps);
- char ebuf[1024];
if ((timestamp = virTimeStringNow()) == NULL)
- goto error;
-
- if (virAsprintf(&logline, "%s: %s %s, qemu version: %d.%d.%d%s\n",
- timestamp, msg, VIR_LOG_VERSION_STRING,
- (qemuVersion / 1000000) % 1000, (qemuVersion / 1000) % 1000,
qemuVersion % 1000,
- package ? package : "") < 0)
- goto error;
+ goto cleanup;
- if (safewrite(logfd, logline, strlen(logline)) < 0)
- goto error;
+ if (qemuDomainLogContextWrite(logCtxt, "%s: %s %s, qemu version:
%d.%d.%d%s\n",
+ timestamp, msg, VIR_LOG_VERSION_STRING,
+ (qemuVersion / 1000000) % 1000,
+ (qemuVersion / 1000) % 1000,
+ qemuVersion % 1000,
+ package ? package : "") < 0)
+ goto cleanup;
- if (cmd)
- virCommandWriteArgLog(cmd, logfd);
+ if (cmd) {
+ char *args = virCommandToString(cmd);
+ qemuDomainLogContextWrite(logCtxt, "%s", args);
Should this be "%s\n"? Seems virCommandWriteArgLog will print one at
the end and I see callers to virCommandToString will add the '\n'
character...
ACK with the "expected result"...
John
+ VIR_FREE(args);
+ }
cleanup:
VIR_FREE(timestamp);
- VIR_FREE(logline);
- return;
-
- error:
- VIR_WARN("Unable to write banner to logfile: %s",
- virStrerror(errno, ebuf, sizeof(ebuf)));
- goto cleanup;
}
int qemuProcessStart(virConnectPtr conn,
@@ -4518,7 +4511,7 @@ int qemuProcessStart(virConnectPtr conn,
goto error;
}
- qemuLogOperation(vm, "starting up", logfile, cmd);
+ qemuLogOperation(vm, "starting up", cmd, logCtxt);
qemuDomainObjCheckTaint(driver, vm, logCtxt);