
On 11/12/2015 12:19 PM, Daniel P. Berrange wrote:
When the qemuProcessAttach/Stop methods write a marker into the log file, they can use qemuDomainLogContextWrite to write a formatted message.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/qemu/qemu_process.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f729065..132b3eb 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -77,9 +77,6 @@
VIR_LOG_INIT("qemu.qemu_process");
-#define ATTACH_POSTFIX ": attaching\n" -#define SHUTDOWN_POSTFIX ": shutting down\n" - /** * qemuProcessRemoveDomainStatus * @@ -4913,7 +4910,6 @@ void qemuProcessStop(virQEMUDriverPtr driver, size_t i; char *timestamp; char *tmppath = NULL; - char ebuf[1024]; virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); qemuDomainLogContextPtr logCtxt = NULL;
@@ -4946,15 +4942,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
if ((logCtxt = qemuDomainLogContextNew(driver, vm, QEMU_DOMAIN_LOG_CONTEXT_MODE_STOP))) { - int logfile = qemuDomainLogContextGetWriteFD(logCtxt); if ((timestamp = virTimeStringNow()) != NULL) { - if (safewrite(logfile, timestamp, strlen(timestamp)) < 0 || - safewrite(logfile, SHUTDOWN_POSTFIX, - strlen(SHUTDOWN_POSTFIX)) < 0) { - VIR_WARN("Unable to write timestamp to logfile: %s", - virStrerror(errno, ebuf, sizeof(ebuf))); - } - + qemuDomainLogContextWrite(logCtxt, "%s: stopping\n", timestamp);
was #define SHUTDOWN_POSTFIX ": shutting down\n", but this changes to "stopping" which is 'different', although perhaps more technically correct w/r/t what's going on here. I have to believe there's scripts out in the wild looking for 'shutting down' that fail with 'stopping'... For some reason I seem to recall tests scripts that would essentially 'tail -f' the log file for that to ensure that whatever shutdown/stop command was sent actually worked. ACK - either way, but I tend to favor shutdown down only because it has precedence. John
VIR_FREE(timestamp); } qemuDomainLogContextFree(logCtxt); @@ -5216,8 +5205,6 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, bool monJSON) { size_t i; - char ebuf[1024]; - int logfile = -1; qemuDomainLogContextPtr logCtxt = NULL; char *timestamp; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -5316,7 +5303,6 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, if (!(logCtxt = qemuDomainLogContextNew(driver, vm, QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH))) goto error; - logfile = qemuDomainLogContextGetWriteFD(logCtxt);
VIR_DEBUG("Determining emulator version"); virObjectUnref(priv->qemuCaps); @@ -5348,11 +5334,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, if ((timestamp = virTimeStringNow()) == NULL) goto error;
- if (safewrite(logfile, timestamp, strlen(timestamp)) < 0 || - safewrite(logfile, ATTACH_POSTFIX, strlen(ATTACH_POSTFIX)) < 0) { - VIR_WARN("Unable to write timestamp to logfile: %s", - virStrerror(errno, ebuf, sizeof(ebuf))); - } + qemuDomainLogContextWrite(logCtxt, "%s: attaching\n", timestamp); VIR_FREE(timestamp);
qemuDomainObjTaint(driver, vm, VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH, logCtxt);