[libvirt] [PATCH 1/2] cleanup: make nlComm commonly available

Eric Blake eblake at redhat.com
Tue Jun 21 20:32:29 UTC 2011


On 06/21/2011 10:08 AM, Stefan Berger wrote:
> In a first cleanup step, make nlComm from macvtap.c commonly available
> for other code to use. Since nlComm uses Linux-specific structures as
> parameters it's prototype is only visible on Linux.
> 
> Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
> 
> ---
>  src/Makefile.am          |    1
>  src/libvirt_private.syms |    4 +

The code motion looks okay to me.  However:

Exporting the private symbols says the symbols must be available
everywhere...

> +#if __linux__
> +int nlComm(struct nl_msg *nl_msg,
> +           unsigned char **respbuf, unsigned int *respbuflen,
> +           int nl_pid)
> +{

> +
> +#endif /* __linux__ */

so you should provide an #else clause with a dummy implementation that
always fails, as well as a dummy:

struct nl_msg;

forward prototype to allow compilation on non-Linux.

> +
> Index: libvirt-acl/src/util/netlink.h
> ===================================================================
> --- /dev/null
> +++ libvirt-acl/src/util/netlink.h
> @@ -0,0 +1,14 @@
> +#ifndef __VIR_NETLINK_H__
> +# define __VIR_NETLINK_H__
> +
> +# if __linux__
> +
> +#  include <netlink/msg.h>
> +
> +int nlComm(struct nl_msg *nl_msg,
> +           unsigned char **respbuf, unsigned int *respbuflen,
> +           int nl_pid);
> +
> +#endif /* __linux__ */

at which point this header can be unconditional.

> +++ libvirt-acl/src/libvirt_private.syms
> @@ -668,6 +668,10 @@ virResizeN;
>  virShrinkN;
> 
> 
> +#netlink.h
> +nlComm;
> +

An alternative would be finding a way to only conditionally export
nlComm on Linux, by sticking it in a separate .syms file only when
actually used.

-- 
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/18ec272b/attachment-0001.sig>


More information about the libvir-list mailing list