[libvirt] [PATCH] lxc: Fix error handlings in lxcContainerRenameAndEnableInterfaces

Daniel P. Berrange berrange at redhat.com
Mon Jun 28 10:29:51 UTC 2010


On Sun, Jun 27, 2010 at 05:59:59AM +0900, Ryota Ozaki wrote:
> The function is expected to return negative value on failure,
> however, it returns positive value when either setInterfaceName
> or vethInterfaceUpOrDown fails. Because the function returns
> the return value of either as is, however, the two functions
> may return positive value on failure.
> 
> The patch fixes the defects and add error messages.
> ---
>  src/lxc/lxc_container.c |   13 ++++++++++---
>  1 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index 018f4d5..4371dba 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -255,13 +255,20 @@ static int lxcContainerRenameAndEnableInterfaces(unsigned int nveths,
>  
>          DEBUG("Renaming %s to %s", veths[i], newname);
>          rc = setInterfaceName(veths[i], newname);
> -        if (0 != rc)
> +        if (0 != rc) {
> +            VIR_ERROR(_("Failed to rename %s to %s (%d)"),
> +                      veths[i], newname, rc);
> +            rc = -1;
>              goto error_out;
> +        }
>  
>          DEBUG("Enabling %s", newname);
> -        rc =  vethInterfaceUpOrDown(newname, 1);
> -        if (0 != rc)
> +        rc = vethInterfaceUpOrDown(newname, 1);
> +        if (0 != rc) {
> +            VIR_ERROR(_("Failed to enable %s (%d)"), newname, rc);
> +            rc = -1;
>              goto error_out;
> +        }
>          VIR_FREE(newname);
>      }

ACK

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list