Re: [libvirt] [PATCH] Allow NULL mac address in virGetInterface.

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

 



On Mon, Oct 19, 2009 at 04:41:52PM -0400, Laine Stump wrote:
> There are places where an interface will not have a mac address, and netcf
> returns this as a NULL pointer rather than a pointer to an empty string.
> Rather than checking for this all over the place in libvirt, just save it
> in the virInterface object as an empty string.
> ---
>  src/datatypes.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/src/datatypes.c b/src/datatypes.c
> index 89ad309..ecefc59 100644
> --- a/src/datatypes.c
> +++ b/src/datatypes.c
> @@ -588,10 +588,15 @@ virInterfacePtr
>  virGetInterface(virConnectPtr conn, const char *name, const char *mac) {
>      virInterfacePtr ret = NULL;
>  
> -    if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (mac == NULL)) {
> +    if ((!VIR_IS_CONNECT(conn)) || (name == NULL)) {
>          virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
>          return(NULL);
>      }
> +
> +    /* a NULL mac from caller is okay. Treat it as blank */
> +    if (mac == NULL)
> +       mac = "";
> +
>      virMutexLock(&conn->lock);
>  
>      ret = (virInterfacePtr) virHashLookup(conn->interfaces, name);

  ACK that sounds reasonnable to me.
I assume the inverted situation of an interface known only by it's MAC
can't happen, right ?

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]