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@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 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; -- 2.41.0