]> xenbits.xensource.com Git - libvirt.git/commitdiff
Rename low level macvlan creation APIs
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 2 Nov 2011 17:26:11 +0000 (17:26 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 18 Nov 2011 16:10:02 +0000 (16:10 +0000)
Rename ifaceMacvtapLinkAdd to virNetDevMacVLanCreate and
ifaceLinkDel to virNetDevMacVLanDelete. Strictly speaking
the latter isn't restricted to macvlan devices, but that's
the only use libvirt has for it.

* util/interface.c, util/interface.h,
  util/virnetdevmacvlan.c: Rename APIs

src/libvirt_private.syms
src/util/interface.c
src/util/interface.h
src/util/virnetdevmacvlan.c

index 759b6414b4802820b3e228b13bb020f3edb1e1fe..78d166ba5ee7441c3fd5f085f23091ef937f12e8 100644 (file)
@@ -583,8 +583,8 @@ ifaceGetPhysicalFunction;
 ifaceGetVirtualFunctionIndex;
 ifaceGetVlanID;
 ifaceIsVirtualFunction;
-ifaceLinkDel;
-ifaceMacvtapLinkAdd;
+virNetDevMacVLanCreate;
+virNetDevMacVLanDelete;
 ifaceMacvtapLinkDump;
 ifaceReplaceMacAddress;
 ifaceRestoreMacAddress;
index 63e6bf728be53b592996e730b223dc122b5df6a1..a1c56f5088cd51920afd12f81ed20e0b04212899 100644 (file)
@@ -313,12 +313,11 @@ ifaceGetIPAddress(const char *ifname ATTRIBUTE_UNUSED,
 #endif /* __linux__ */
 
 /**
- * ifaceLinkAdd
+ * virNetDevMacVLanCreate:
  *
+ * @ifname: The name the interface is supposed to have; optional parameter
  * @type: The type of device, i.e., "macvtap"
  * @macaddress: The MAC address of the device
- * @macaddrsize: The size of the MAC address, typically '6'
- * @ifname: The name the interface is supposed to have; optional parameter
  * @srcdev: The name of the 'link' device
  * @macvlan_mode: The macvlan mode to use
  * @retry: Pointer to integer that will be '1' upon return if an interface
@@ -331,12 +330,12 @@ ifaceGetIPAddress(const char *ifname ATTRIBUTE_UNUSED,
  */
 #if defined(__linux__) && WITH_MACVTAP
 int
-ifaceMacvtapLinkAdd(const char *type,
-                    const unsigned char *macaddress, int macaddrsize,
-                    const char *ifname,
-                    const char *srcdev,
-                    uint32_t macvlan_mode,
-                    int *retry)
+virNetDevMacVLanCreate(const char *ifname,
+                       const char *type,
+                       const unsigned char *macaddress,
+                       const char *srcdev,
+                       uint32_t macvlan_mode,
+                       int *retry)
 {
     int rc = 0;
     struct nlmsghdr *resp;
@@ -366,7 +365,7 @@ ifaceMacvtapLinkAdd(const char *type,
     if (nla_put_u32(nl_msg, IFLA_LINK, ifindex) < 0)
         goto buffer_too_small;
 
-    if (nla_put(nl_msg, IFLA_ADDRESS, macaddrsize, macaddress) < 0)
+    if (nla_put(nl_msg, IFLA_ADDRESS, VIR_MAC_BUFLEN, macaddress) < 0)
         goto buffer_too_small;
 
     if (ifname &&
@@ -458,14 +457,12 @@ buffer_too_small:
 
 #else
 
-int
-ifaceMacvtapLinkAdd(const char *type ATTRIBUTE_UNUSED,
-                    const unsigned char *macaddress ATTRIBUTE_UNUSED,
-                    int macaddrsize ATTRIBUTE_UNUSED,
-                    const char *ifname ATTRIBUTE_UNUSED,
-                    const char *srcdev ATTRIBUTE_UNUSED,
-                    uint32_t macvlan_mode ATTRIBUTE_UNUSED,
-                    int *retry ATTRIBUTE_UNUSED)
+int virNetDevMacVLanCreate(const char *ifname ATTRIBUTE_UNUSED,
+                           const char *type ATTRIBUTE_UNUSED,
+                           const unsigned char *macaddress ATTRIBUTE_UNUSED,
+                           const char *srcdev ATTRIBUTE_UNUSED,
+                           uint32_t macvlan_mode ATTRIBUTE_UNUSED,
+                           int *retry ATTRIBUTE_UNUSED)
 {
     ifaceError(VIR_ERR_INTERNAL_ERROR, "%s",
 # if defined(__linux__) && !WITH_MACVTAP
@@ -483,7 +480,7 @@ ifaceMacvtapLinkAdd(const char *type ATTRIBUTE_UNUSED,
 
 
 /**
- * ifaceLinkDel
+ * virNetDevMacVLanDelete:
  *
  * @ifname: Name of the interface
  *
@@ -492,8 +489,7 @@ ifaceMacvtapLinkAdd(const char *type ATTRIBUTE_UNUSED,
  * Returns 0 on success, -1 on fatal error.
  */
 #if defined( __linux__) && WITH_MACVTAP
-int
-ifaceLinkDel(const char *ifname)
+int virNetDevMacVLanDelete(const char *ifname)
 {
     int rc = 0;
     struct nlmsghdr *resp;
@@ -572,8 +568,7 @@ buffer_too_small:
 
 #else
 
-int
-ifaceLinkDel(const char *ifname ATTRIBUTE_UNUSED)
+int virNetDevMacVLanDelete(const char *ifname ATTRIBUTE_UNUSED)
 {
     ifaceError(VIR_ERR_INTERNAL_ERROR, "%s",
 # if defined(__linux__) && !WITH_MACVTAP
index 4adc6017a326056f5e39283a25d95b9c8c8d6c30..a62f26a932ce3183aa628d7bafd1a488c27e50b6 100644 (file)
@@ -39,14 +39,17 @@ int ifaceGetVlanID(const char *vlanifname, int *vlanid);
 
 int ifaceGetIPAddress(const char *ifname, virSocketAddrPtr addr);
 
-int ifaceMacvtapLinkAdd(const char *type,
-                        const unsigned char *macaddress, int macaddrsize,
-                        const char *ifname,
-                        const char *srcdev,
-                        uint32_t macvlan_mode,
-                        int *retry);
-
-int ifaceLinkDel(const char *ifname);
+int virNetDevMacVLanCreate(const char *ifname,
+                           const char *type,
+                           const unsigned char *macaddress,
+                           const char *srcdev,
+                           uint32_t macvlan_mode,
+                           int *retry)
+    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
+    ATTRIBUTE_RETURN_CHECK;
+
+int virNetDevMacVLanDelete(const char *ifname)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
 
 int ifaceMacvtapLinkDump(bool nltarget_kernel, const char *ifname, int ifindex,
                          struct nlattr **tb, unsigned char **recvbuf,
index a322ecee048e45ce91cfef662f920d54fb3257f9..ab552afb4f6fc5a77bd5ffc2bf660281e1928a1f 100644 (file)
@@ -284,8 +284,8 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
             return -1;
         }
         cr_ifname = tgifname;
-        rc = ifaceMacvtapLinkAdd(type, macaddress, 6, tgifname, linkdev,
-                                 macvtapMode, &do_retry);
+        rc = virNetDevMacVLanCreate(tgifname, type, macaddress, linkdev,
+                                    macvtapMode, &do_retry);
         if (rc < 0)
             return -1;
     } else {
@@ -294,8 +294,8 @@ create_name:
         for (c = 0; c < 8192; c++) {
             snprintf(ifname, sizeof(ifname), MACVTAP_NAME_PATTERN, c);
             if (ifaceGetIndex(false, ifname, &ifindex) == -ENODEV) {
-                rc = ifaceMacvtapLinkAdd(type, macaddress, 6, ifname, linkdev,
-                                         macvtapMode, &do_retry);
+                rc = virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
+                                            macvtapMode, &do_retry);
                 if (rc == 0)
                     break;
 
@@ -350,7 +350,7 @@ disassociate_exit:
                                                    vmOp));
 
 link_del_exit:
-    ifaceLinkDel(cr_ifname);
+    ignore_value(virNetDevMacVLanDelete(cr_ifname));
 
     return rc;
 }
@@ -385,7 +385,7 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
                                               linkdev,
                                               VIR_NETDEV_VPORT_PROFILE_OP_DESTROY) < 0)
             ret = -1;
-        if (ifaceLinkDel(ifname) < 0)
+        if (virNetDevMacVLanDelete(ifname) < 0)
             ret = -1;
     }
     return ret;