[libvirt] [PATCH 1/2] Make virNetDevSetupControl() public.

Roman Bogorodskiy bogorodskiy at gmail.com
Thu May 16 05:47:12 UTC 2013


This method is useful not only in virnetdev.c.
---
 src/libvirt_private.syms         |  1 +
 src/util/virnetdev.c             | 15 +++++++++++++--
 src/util/virnetdev.h             | 12 ++++++++++++
 src/util/virnetdevmacvlan.c      |  2 +-
 src/util/virnetdevvportprofile.c |  2 +-
 5 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index cc734da..d65ecc1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1526,6 +1526,7 @@ virNetDevSetMTUFromDevice;
 virNetDevSetName;
 virNetDevSetNamespace;
 virNetDevSetOnline;
+virNetDevSetupControl;
 virNetDevValidateConfig;
 
 
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index cee4001..f658c6d 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -88,11 +88,22 @@ static int virNetDevSetupControlFull(const char *ifname,
 }
 
 
-static int virNetDevSetupControl(const char *ifname,
-                                 struct ifreq *ifr)
+int
+virNetDevSetupControl(const char *ifname,
+                      struct ifreq *ifr)
 {
     return virNetDevSetupControlFull(ifname, ifr, VIR_NETDEV_FAMILY, SOCK_DGRAM);
 }
+#else
+int
+virNetDevSetupControl(const char *ifname ATTRIBUTE_UNUSED,
+                      void *ifr ATTRIBUTE_UNUSED)
+{
+    virReportSystemError(ENOSYS,
+                         _("%s is not supported on this platform"),
+                         __func__);
+    return -1;
+}
 #endif
 
 
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index bc0777c..73c267f 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -23,11 +23,23 @@
 #ifndef __VIR_NETDEV_H__
 # define __VIR_NETDEV_H__
 
+# include <config.h>
+# include <net/if.h>
+
 # include "virsocketaddr.h"
 # include "virnetlink.h"
 # include "virmacaddr.h"
 # include "virpci.h"
 
+#ifdef HAVE_STRUCT_IFREQ
+int virNetDevSetupControl(const char *ifname,
+                          struct ifreq *ifr)
+    ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+#else
+int virNetDevSetupControl(const char *ifname,
+                          void *ifr);
+#endif
+
 int virNetDevExists(const char *brname)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
 
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 5316520..d5d36e4 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -48,7 +48,7 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST,
 # include <sys/socket.h>
 # include <sys/ioctl.h>
 
-# include <linux/if.h>
+# include <net/if.h>
 # include <linux/if_tun.h>
 
 /* Older kernels lacked this enum value.  */
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
index 883aa46..71aae24 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -49,7 +49,7 @@ VIR_ENUM_IMPL(virNetDevVPortProfileOp, VIR_NETDEV_VPORT_PROFILE_OP_LAST,
 # include <sys/socket.h>
 # include <sys/ioctl.h>
 
-# include <linux/if.h>
+# include <net/if.h>
 # include <linux/if_tun.h>
 
 # include "virnetlink.h"
-- 
1.7.11.5




More information about the libvir-list mailing list