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

Re: [libvirt] [PATCH 3/4] Implement Public API of new virInterface functions



On Thu, Jun 18, 2009 at 02:44:29PM -0400, Laine Stump wrote:
> ---
>  src/libvirt.c |   89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 files changed, 86 insertions(+), 3 deletions(-)
> 
> diff --git a/src/libvirt.c b/src/libvirt.c
> index bf49018..c5c868d 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -5502,9 +5502,9 @@ virInterfaceGetConnect (virInterfacePtr iface)
>   * virConnectNumOfInterfaces:
>   * @conn: pointer to the hypervisor connection
>   *
> - * Provides the number of interfaces on the physical host.
> + * Provides the number of active interfaces on the physical host.
>   *
> - * Returns the number of interface found or -1 in case of error
> + * Returns the number of active interfaces found or -1 in case of error
>   */
>  int
>  virConnectNumOfInterfaces(virConnectPtr conn)
> @@ -5540,7 +5540,8 @@ error:
>   * @names: array to collect the list of names of interfaces
>   * @maxnames: size of @names
>   *
> - * Collect the list of physical host interfaces, and store their names in @names
> + * Collect the list of active physical host interfaces,
> + * and store their names in @names
>   *
>   * Returns the number of interfaces found or -1 in case of error
>   */
> @@ -5578,6 +5579,88 @@ error:
>  }
>  
>  /**
> + * virConnectNumOfDefinedInterfaces:
> + * @conn: pointer to the hypervisor connection
> + *
> + * Provides the number of defined (inactive) interfaces on the physical host.
> + *
> + * Returns the number of defined interface found or -1 in case of error
> + */
> +int
> +virConnectNumOfDefinedInterfaces(virConnectPtr conn)
> +{
> +    DEBUG("conn=%p", conn);
> +
> +    virResetLastError();
> +
> +    if (!VIR_IS_CONNECT(conn)) {
> +        virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
> +        return (-1);
> +    }
> +
> +    if (conn->interfaceDriver && conn->interfaceDriver->numOfDefinedInterfaces) {
> +        int ret;
> +        ret = conn->interfaceDriver->numOfDefinedInterfaces (conn);
> +        if (ret < 0)
> +            goto error;
> +        return ret;
> +    }
> +
> +    virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> +    /* Copy to connection error object for back compatability */
> +    virSetConnError(conn);
> +    return -1;
> +}
> +
> +/**
> + * virConnectListDefinedInterfaces:
> + * @conn: pointer to the hypervisor connection
> + * @names: array to collect the list of names of interfaces
> + * @maxnames: size of @names
> + *
> + * Collect the list of defined (inactive) physical host interfaces,
> + * and store their names in @names.
> + *
> + * Returns the number of interfaces found or -1 in case of error
> + */
> +int
> +virConnectListDefinedInterfaces(virConnectPtr conn,
> +                                char **const names,
> +                                int maxnames)
> +{
> +    DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
> +
> +    virResetLastError();
> +
> +    if (!VIR_IS_CONNECT(conn)) {
> +        virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
> +        return (-1);
> +    }
> +
> +    if ((names == NULL) || (maxnames < 0)) {
> +        virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
> +        goto error;
> +    }
> +
> +    if (conn->interfaceDriver && conn->interfaceDriver->listDefinedInterfaces) {
> +        int ret;
> +        ret = conn->interfaceDriver->listDefinedInterfaces (conn, names, maxnames);
> +        if (ret < 0)
> +            goto error;
> +        return ret;
> +    }
> +
> +    virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> +    /* Copy to connection error object for back compatability */
> +    virSetConnError(conn);
> +    return -1;
> +}
> +
> +/**
>   * virInterfaceLookupByName:
>   * @conn: pointer to the hypervisor connection
>   * @name: name for the interface
> -- 

ACK

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.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]