[PATCH 3/3] lxc: driver: Improve logging when launching emulator

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

 



Log the full command line and a timestamp like we do for QEMU

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 src/lxc/lxc_driver.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 930e445..5e164b6 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -56,6 +56,8 @@
 
 #define VIR_FROM_THIS VIR_FROM_LXC
 
+#define START_POSTFIX ": starting up\n"
+
 #define LXC_NB_MEM_PARAM  3
 
 typedef struct _lxcDomainObjPrivate lxcDomainObjPrivate;
@@ -1254,6 +1256,9 @@ static int lxcControllerStart(lxc_driver_t *driver,
     char *filterstr;
     char *outputstr;
     virCommandPtr cmd;
+    off_t pos = -1;
+    char ebuf[1024];
+    char *timestamp;
 
     cmd = virCommandNewArgList(vm->def->emulator, NULL);
 
@@ -1316,6 +1321,24 @@ static int lxcControllerStart(lxc_driver_t *driver,
             goto cleanup;
     }
 
+    /* Log timestamp */
+    if ((timestamp = virTimestamp()) == NULL) {
+        virReportOOMError();
+        goto cleanup;
+    }
+    if (safewrite(logfile, timestamp, strlen(timestamp)) < 0 ||
+        safewrite(logfile, START_POSTFIX, strlen(START_POSTFIX)) < 0) {
+        VIR_WARN("Unable to write timestamp to logfile: %s",
+                 virStrerror(errno, ebuf, sizeof ebuf));
+    }
+    VIR_FREE(timestamp);
+
+    /* Log generated command line */
+    virCommandWriteArgLog(cmd, logfile);
+    if ((pos = lseek(logfile, 0, SEEK_END)) < 0)
+        VIR_WARN("Unable to seek to end of logfile: %s",
+                 virStrerror(errno, ebuf, sizeof ebuf));
+
     virCommandPreserveFD(cmd, appPty);
     virCommandSetOutputFD(cmd, &logfile);
     virCommandSetErrorFD(cmd, &logfile);
-- 
1.7.4.4

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