[libvirt] [PATCH] portability: fix virNetDevSetMAC and virNetDevExists on BSD

Eric Blake eblake at redhat.com
Fri May 10 17:10:24 UTC 2013


On 05/03/2013 07:35 AM, Roman Bogorodskiy wrote:
> - provide virNetDevSetMAC() implementation based on SIOCSIFLLADDR
>   ioctl.
> - adjust virNetDevExists() to check for ENXIO error because
>   FreeBSD throws it when device doesn't exist
> ---
>  configure.ac         |  8 ++++++++
>  src/util/virnetdev.c | 41 ++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 48 insertions(+), 1 deletion(-)
> 

> +++ b/configure.ac
> @@ -2372,6 +2372,14 @@ AC_CHECK_MEMBERS([struct ifreq.ifr_newname,
>                    #include <net/if.h>
>                   ])
>  
> +AC_CHECK_DECLS([link_addr],

Maybe a comment mentioning that this is a BSD interface might help
future readers.

> +++ b/src/util/virnetdev.c
> @@ -47,6 +47,11 @@
>  # undef HAVE_STRUCT_IFREQ
>  #endif
>  
> +#ifdef HAVE_DECL_LINK_ADDR

Fails 'make syntax-check':

src/util/virnetdev.c:50:#ifdef HAVE_DECL_LINK_ADDR
maint.mk: HAVE_DECL macros are always defined

s/ifdef/if/ to fix

> @@ -179,6 +184,40 @@ cleanup:
>      VIR_FORCE_CLOSE(fd);
>      return ret;
>  }
> +#elif defined(SIOCSIFLLADDR) && defined(HAVE_STRUCT_IFREQ) && \
> +      defined(HAVE_DECL_LINK_ADDR)

Ouch.  'make syntax-check' didn't pick up on this one.  You want
s/defined(\(HAVE_DECL_LINK_ADDR\))/\1/, and I have a chore to fix the
syntax-checker to spot this one :)

ACK, and pushed with this squashed in.

diff --git i/src/util/virnetdev.c w/src/util/virnetdev.c
index 0527a27..251a66a 100644
--- i/src/util/virnetdev.c
+++ w/src/util/virnetdev.c
@@ -47,7 +47,7 @@
 # undef HAVE_STRUCT_IFREQ
 #endif

-#ifdef HAVE_DECL_LINK_ADDR
+#if HAVE_DECL_LINK_ADDR
 # include <sys/sockio.h>
 # include <net/if_dl.h>
 #endif
@@ -185,7 +185,7 @@ cleanup:
     return ret;
 }
 #elif defined(SIOCSIFLLADDR) && defined(HAVE_STRUCT_IFREQ) && \
-      defined(HAVE_DECL_LINK_ADDR)
+    HAVE_DECL_LINK_ADDR
 int virNetDevSetMAC(const char *ifname,
                     const virMacAddrPtr macaddr)
 {


-- 
Eric Blake   eblake 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: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130510/2f5d283e/attachment-0001.sig>


More information about the libvir-list mailing list