[PATCH 3/3] virLXCProcessReportStartupLogError: Strip trailing newline from error

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

 



Since the error message originates from a log file it contains a
trailing newline. Strip it as all error handling adds it's own newline.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/lxc/lxc_process.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 6b79bd737b..04642b56dd 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1124,6 +1124,7 @@ virLXCProcessReportStartupLogError(virDomainObj *vm,
 {
     size_t buflen = 1024;
     g_autofree char *errbuf = g_new0(char, buflen);
+    char *p;
     int rc;

     if ((rc = virLXCProcessReadLogOutput(vm, logfile, pos, errbuf, buflen)) < 0)
@@ -1132,6 +1133,11 @@ virLXCProcessReportStartupLogError(virDomainObj *vm,
     if (rc == 0)
         return 0;

+    /* strip last newline */
+    if ((p = strrchr(errbuf, '\n')) &&
+        p[1] == '\0')
+        *p = '\0';
+
     virReportError(VIR_ERR_INTERNAL_ERROR,
                    _("guest failed to start: %1$s"), errbuf);

-- 
2.41.0




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

  Powered by Linux