[libvirt] [PATCH] qemu: Ignore libvirt debug messages in qemu log

Eric Blake eblake at redhat.com
Wed Mar 30 19:46:12 UTC 2011


On 03/30/2011 06:17 AM, Jiri Denemark wrote:
> qemu driver uses a 4K buffer for reading qemu log file. This is enough
> when only qemu's output is present in the log file. However, when
> debugging messages are turned on, intermediate libvirt process fills the
> log with a bunch of debugging messages before it executes qemu binary.
> In such a case the buffer may become too small. However, we are not
> really interested in libvirt messages so they can be filtered out from
> the buffer.
> ---
>  src/qemu/qemu_process.c |   47 +++++++++++++++++++++++++++++++++++++----------
>  1 files changed, 37 insertions(+), 10 deletions(-)

>  
> +    if (virAsprintf(&debug, ": %d: debug : ", vm->pid) < 0) {

That's rather hard-coded to our current output style; should we add
comments here and to the place that outputs those lines to be careful to
keep the two places in sync?

> -        got += ret;
> +        got += bytes;
>          buf[got] = '\0';
> +
> +        /* Filter out debug messages from intermediate libvirt process */
> +        while ((eol = strchr(filter_next, '\n'))) {
> +            char *p = strstr(filter_next, debug);

Suppose you have five normal lines before the first debug line.  Is it
any more efficient to use use getline() to read a line at a time, and
just strstr() once per line, rather than reading the entire file and
having strstr() repeatedly scan multiple lines on each iteration (15
lines scanned over 5 iterations)?  Or even if you don't use getline(),
can you temporarily set eol to NUL so that strstr() is bounded to a
given line rather than searching into the rest of the file, since the
filtering is line-based?

> +            if (p && p < eol) {
> +                memmove(filter_next, eol + 1, got - (eol - buf));

Conversely, supposed you have five debug lines followed by five normal
lines.  Doing the memmove() on every debug line encountered results in
moving 25 lines around, whereas if you rewrite the loop to only copy one
line at a time and only if it passed the filter, then you only have to
move 5 lines around.

I like the idea, but I think it can be made more efficient in v2.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110330/666517db/attachment-0001.sig>


More information about the libvir-list mailing list