]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virLXCProcessReadLogOutputData: Refill buffer after filtering out noise
authorPeter Krempa <pkrempa@redhat.com>
Wed, 2 Aug 2023 07:20:24 +0000 (09:20 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 4 Aug 2023 08:04:21 +0000 (10:04 +0200)
The caller passes in a 1k buffer, which when debug logging is in use is
easily filled with debug messages only. Thus after the first pass which
is common if the controller process already terminated the buffer will
not contain the real error, but rather a truncated debug message,
which will result in an error such as:

  error: internal error: guest failed to start: 2023-08-01 12:58:31.948+0000: 798195: i

instead of the proper error:

 error: internal error: guest failed to start: Failure in libvirt_lxc startup: Failed to create /home/rootfs/.oldroot: Permission denied

To fix the above retry the reading loop if the filtering function made
space in the buffer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/lxc/lxc_process.c

index d003742fa1748c356d7acc2f8bb5c2aac9a7a010..6b79bd737bf9d65e83bddf8b6808f45ff41b36f5 100644 (file)
@@ -1011,6 +1011,7 @@ virLXCProcessReadLogOutputData(virDomainObj *vm,
     int retries = 10;
     int got = 0;
     char *filter_next = buf;
+    bool filtered;
 
     buf[0] = '\0';
 
@@ -1036,11 +1037,13 @@ virLXCProcessReadLogOutputData(virDomainObj *vm,
         buf[got] = '\0';
 
         /* Filter out debug messages from intermediate libvirt process */
+        filtered = false;
         while ((eol = strchr(filter_next, '\n'))) {
             *eol = '\0';
             if (virLXCProcessIgnorableLogLine(filter_next)) {
                 memmove(filter_next, eol + 1, got - (eol - buf));
                 got -= eol + 1 - filter_next;
+                filtered = true;
             } else {
                 filter_next = eol + 1;
                 *eol = '\n';
@@ -1054,6 +1057,9 @@ virLXCProcessReadLogOutputData(virDomainObj *vm,
             return -1;
         }
 
+        if (filtered)
+            continue;
+
         if (isdead)
             return got;