From 1f8558cf9a32dea4ec785d060317acc84e485155 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 2 Aug 2023 09:20:24 +0200 Subject: [PATCH] virLXCProcessReadLogOutputData: Refill buffer after filtering out noise 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 Reviewed-by: Martin Kletzander --- 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 d003742fa1..6b79bd737b 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -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;