[PATCH v2 10/13] qemu: convert qemuLogOperation to take a qemuDomainLogContextPtr

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

 



Instead of writing directly to a log file descriptor, change
qemuLogOperation to use qemuDomainLogContextWrite().

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 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);
+        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);
 
-- 
2.5.0

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



[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]