[libvirt] [PATCH 2/2] cleanup: make several interface functions commonly available

Eric Blake eblake at redhat.com
Tue Jun 21 20:38:28 UTC 2011


On 06/21/2011 10:21 AM, Stefan Berger wrote:
> In a second cleanup step this patch makes several interface functions
> from macvtap.c commonly available by moving them into interface.c and
> prefixing their names with 'iface'. Those functions taking
> Linux-specific structures as parameters are only visible on Linux.
> 
> ifaceRestoreMacAddress returns the return code from the ifaceSetMacAddr
> call and display an error message if setting the MAC address did not
> work. The caller is unchanged and still ignores the return code (which
> is ok).
> 
> Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
> 
> ---
>  src/libvirt_private.syms |    8
>  src/util/interface.c     |  590
> +++++++++++++++++++++++++++++++++++++++++++++++
>  src/util/interface.h     |   33 ++
>  src/util/macvtap.c       |  495 ---------------------------------------
>  4 files changed, 640 insertions(+), 486 deletions(-)

Same story about providing stubs on non-Linux platforms, for the purpose
of satisfying the libvirt_private.syms export listings.

> +int
> +ifaceMacvtapLinkDump(bool nltarget_kernel, const char *ifname, int
> ifindex,
> +                     struct nlattr **tb, unsigned char **recvbuf,
> +                     uint32_t (*getPidFunc)(void))

A forward declaration of struct nlattr as an opaque type should be
enough to allow a dummy implementation of this function on non-Linux.

> --- libvirt-acl.orig/src/util/interface.h
> +++ libvirt-acl/src/util/interface.h
> @@ -10,6 +10,13 @@
>  #ifndef __VIR_INTERFACE_H__
>  # define __VIR_INTERFACE_H__
> 
> +# include <stdint.h>
> +
> +# if __linux__
> +#  include <sys/socket.h>
> +#  include <linux/netlink.h>
> +# endif

Here's where you could use an #else to do the forward declaration of
opaque types for non-Linux.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110621/c9a0c2a6/attachment-0001.sig>


More information about the libvir-list mailing list