]> xenbits.xensource.com Git - libvirt.git/commitdiff
virLXCProcessReportStartupLogError: Strip trailing newline from error
authorPeter Krempa <pkrempa@redhat.com>
Wed, 2 Aug 2023 07:25:22 +0000 (09:25 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 4 Aug 2023 08:04:21 +0000 (10:04 +0200)
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@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/lxc/lxc_process.c

index 6b79bd737bf9d65e83bddf8b6808f45ff41b36f5..04642b56ddb0bcef20b139525234a2602b74d8ff 100644 (file)
@@ -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);