[libvirt] [PATCH] dnsmasq: Fix parsing of the version number

Jiri Denemark jdenemar at redhat.com
Thu Dec 6 13:35:24 UTC 2012


On Thu, Dec 06, 2012 at 14:00:00 +0100, Michal Privoznik wrote:
> If debugging is enabled, the debug messages are sent to stderr.
> Moreover, if a command has catching of stderr set, the messages
> gets mixed with stdout output (assuming both outputs are stored
> in the same variable). The resulting string then doesn't
> necessarily have to start with desired prefix then. This bug
> exposes itself when parsing dnsmasq output:
> 
> 2012-12-06 11:18:11.445+0000: 18491: error :
> dnsmasqCapsSetFromBuffer:664 : internal error cannot parse
> /usr/sbin/dnsmasq version number in '2012-12-06
> 11:11:02.232+0000: 18492: debug : virFileClose:72 : Closed fd 22'
> 
> We can clearly see that the output of dnsmasq --version doesn't
> start with expected "Dnsmasq version " string but a libvirt debug
> output.
> ---
>  src/util/dnsmasq.c |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/dnsmasq.c b/src/util/dnsmasq.c
> index de0293a..a627ed2 100644
> --- a/src/util/dnsmasq.c
> +++ b/src/util/dnsmasq.c
> @@ -715,7 +715,6 @@ dnsmasqCapsRefreshInternal(dnsmasqCapsPtr caps, bool force)
>  
>      cmd = virCommandNewArgList(caps->binaryPath, "--version", NULL);
>      virCommandSetOutputBuffer(cmd, &version);
> -    virCommandSetErrorBuffer(cmd, &version);
>      virCommandAddEnvPassCommon(cmd);
>      virCommandClearCaps(cmd);
>      if (virCommandRun(cmd, NULL) < 0) {
> @@ -727,7 +726,6 @@ dnsmasqCapsRefreshInternal(dnsmasqCapsPtr caps, bool force)
>  
>      cmd = virCommandNewArgList(caps->binaryPath, "--help", NULL);
>      virCommandSetOutputBuffer(cmd, &help);
> -    virCommandSetErrorBuffer(cmd, &help);
>      virCommandAddEnvPassCommon(cmd);
>      virCommandClearCaps(cmd);
>      if (virCommandRun(cmd, NULL) < 0) {

ACK, this looks like the right solution.

Jirka




More information about the libvir-list mailing list