[libvirt] [PATCH] nwfilter: improved logging during driver initialization

Eric Blake eblake at redhat.com
Thu Feb 16 21:53:21 UTC 2012


On 02/16/2012 01:55 PM, Stefan Berger wrote:
> Improve the logging during nwfilter driver initialization when testing the
> command line tools.
> 
> ---
>  src/nwfilter/nwfilter_ebiptables_driver.c |   41
> +++++++++++++++++++++---------
>  1 file changed, 29 insertions(+), 12 deletions(-)
> 
> @@ -4056,8 +4057,14 @@ ebiptablesDriverInit(bool privileged)
>                            "%s",
>                            CMD_STOPONERR(1));
> 
> -        if (ebiptablesExecCLI(&buf, NULL, NULL) < 0)
> -             VIR_FREE(ebtables_cmd_path);
> +        if (ebiptablesExecCLI(&buf, NULL, &errmsg) < 0) {
> +            VIR_FREE(ebtables_cmd_path);
> +            VIR_ERROR(_("Testing of ebtables command failed%s%s."),

I'd drop the trailing '.' here and the other two instances (you have no
idea if errmsg already has its own trailing '.'.  And while we are not a
GNU project, the GNU Coding Standards recommend error messages that do
not end in a period)

> +                      errmsg ? ": " : "",
> +                      errmsg ? errmsg : "");
> +        }
> +    } else {
> +        VIR_WARN(_("Could not find 'ebtables' executable."));
>      }
> 
>      iptables_cmd_path = virFindFileInPath("iptables");
> @@ -4070,8 +4077,14 @@ ebiptablesDriverInit(bool privileged)
>                            "%s",
>                            CMD_STOPONERR(1));
> 
> -        if (ebiptablesExecCLI(&buf, NULL, NULL) < 0)
> -             VIR_FREE(iptables_cmd_path);
> +        if (ebiptablesExecCLI(&buf, NULL, &errmsg) < 0) {

I had to check ebiptablesExecCLI to make sure you didn't have a memory
leak if two back-to-back calls both populate errmsg (thankfully, you are
safe).

ACK with the '.' nits fixed.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list