[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] Implement forgotten backend of virInterfaceIsActive()



On Tue, Apr 13, 2010 at 01:26:00PM -0400, Laine Stump wrote:
> Somehow the backend of this function was never implemented in
> libvirt's netcf driver, and nobody noticed until now. (The required
> netcf function was already in place, so nothing needs to change
> there.)
> ---
>  src/interface/netcf_driver.c |   31 ++++++++++++++++++++++++++++++-
>  1 files changed, 30 insertions(+), 1 deletions(-)
> 
> diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c
> index 708f1f8..7163066 100644
> --- a/src/interface/netcf_driver.c
> +++ b/src/interface/netcf_driver.c
> @@ -511,6 +511,35 @@ cleanup:
>      return ret;
>  }
>  
> +static int interfaceIsActive(virInterfacePtr ifinfo)
> +{
> +    struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
> +    struct netcf_if *iface = NULL;
> +    unsigned int flags = 0;
> +
> +    interfaceDriverLock(driver);
> +
> +    iface = interfaceDriverGetNetcfIF(driver->netcf, ifinfo);
> +    if (!iface) {
> +        /* helper already reported error */
> +        goto cleanup;
> +    }
> +
> +    if (ncf_if_status(iface, &flags) < 0) {
> +        const char *errmsg, *details;
> +        int errcode = ncf_error(driver->netcf, &errmsg, &details);
> +        interfaceReportError(netcf_to_vir_err(errcode),
> +                             "failed to get status of interface %s (netcf: %s - %s)",
> +                             ifinfo->name, errmsg, details ? details : "");
> +        goto cleanup;
> +    }
> +
> +cleanup:
> +    ncf_if_free(iface);
> +    interfaceDriverUnlock(driver);
> +    return flags & NETCF_IFACE_ACTIVE ? 1 : 0;
> +}

This causes it to return a success code in the event of either of
the cleanup paths being taken. It needs to be a tri-state return
value of  -1 (error), 0 (inactive), 1  (active)

Regards,
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 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]