[REPOST PATCH 5/5] conf: Use consistent function name prefixes for virnetworkobj

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use "virNetworkObj" as a prefix for any external API in virnetworkobj.

Also a couple of functions were local to virnetworkobj.c, so remove their
external defs in virnetworkobj.h.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/virnetworkobj.c    | 81 +++++++++++++++++++++++----------------------
 src/conf/virnetworkobj.h    | 51 ++++++++++------------------
 src/libvirt_private.syms    | 15 ++++-----
 src/network/bridge_driver.c | 57 +++++++++++++++----------------
 src/test/test_driver.c      | 14 ++++----
 5 files changed, 100 insertions(+), 118 deletions(-)

diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 55730e4..88e42b5 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -348,9 +348,9 @@ virNetworkObjUpdateAssignDef(virNetworkObjPtr network,
  * If flags is zero, network is considered as inactive and persistent.
  */
 static virNetworkObjPtr
-virNetworkAssignDefLocked(virNetworkObjListPtr nets,
-                          virNetworkDefPtr def,
-                          unsigned int flags)
+virNetworkObjAssignDefLocked(virNetworkObjListPtr nets,
+                             virNetworkDefPtr def,
+                             unsigned int flags)
 {
     virNetworkObjPtr network;
     virNetworkObjPtr ret = NULL;
@@ -416,7 +416,7 @@ virNetworkAssignDefLocked(virNetworkObjListPtr nets,
 
 
 /*
- * virNetworkAssignDef:
+ * virNetworkObjAssignDef:
  * @nets: list of all networks
  * @def: the new NetworkDef (will be consumed by this function iff successful)
  * @flags: bitwise-OR of VIR_NETWORK_OBJ_LIST_ADD_* flags
@@ -426,19 +426,19 @@ virNetworkAssignDefLocked(virNetworkObjListPtr nets,
  * def. For an existing network, use "live" and current state of the
  * network to determine which to replace.
  *
- * Look at virNetworkAssignDefLocked() for @flags description.
+ * Look at virNetworkObjAssignDefLocked() for @flags description.
  *
  * Returns NULL on error, virNetworkObjPtr on success.
  */
 virNetworkObjPtr
-virNetworkAssignDef(virNetworkObjListPtr nets,
-                    virNetworkDefPtr def,
-                    unsigned int flags)
+virNetworkObjAssignDef(virNetworkObjListPtr nets,
+                       virNetworkDefPtr def,
+                       unsigned int flags)
 {
     virNetworkObjPtr network;
 
     virObjectLock(nets);
-    network = virNetworkAssignDefLocked(nets, def, flags);
+    network = virNetworkObjAssignDefLocked(nets, def, flags);
     virObjectUnlock(nets);
     return network;
 }
@@ -534,7 +534,7 @@ virNetworkObjReplacePersistentDef(virNetworkObjPtr network,
 
 
 /*
- * virNetworkConfigChangeSetup:
+ * virNetworkObjConfigChangeSetup:
  *
  * 1) checks whether network state is consistent with the requested
  *    type of modification.
@@ -544,9 +544,9 @@ virNetworkObjReplacePersistentDef(virNetworkObjPtr network,
  *
  * Returns 0 on success, -1 on error.
  */
-int
-virNetworkConfigChangeSetup(virNetworkObjPtr network,
-                            unsigned int flags)
+static int
+virNetworkObjConfigChangeSetup(virNetworkObjPtr network,
+                               unsigned int flags)
 {
     bool isActive;
     int ret = -1;
@@ -580,8 +580,8 @@ virNetworkConfigChangeSetup(virNetworkObjPtr network,
 
 
 void
-virNetworkRemoveInactive(virNetworkObjListPtr nets,
-                         virNetworkObjPtr net)
+virNetworkObjRemoveInactive(virNetworkObjListPtr nets,
+                            virNetworkObjPtr net)
 {
     char uuidstr[VIR_UUID_STRING_BUFLEN];
 
@@ -637,8 +637,8 @@ virNetworkObjFormat(virNetworkObjPtr net,
 
 
 int
-virNetworkSaveStatus(const char *statusDir,
-                     virNetworkObjPtr network)
+virNetworkObjSaveStatus(const char *statusDir,
+                        virNetworkObjPtr network)
 {
     int ret = -1;
     int flags = 0;
@@ -657,7 +657,7 @@ virNetworkSaveStatus(const char *statusDir,
 }
 
 
-virNetworkObjPtr
+static virNetworkObjPtr
 virNetworkLoadState(virNetworkObjListPtr nets,
                     const char *stateDir,
                     const char *name)
@@ -752,7 +752,8 @@ virNetworkLoadState(virNetworkObjListPtr nets,
     }
 
     /* create the object */
-    if (!(net = virNetworkAssignDef(nets, def, VIR_NETWORK_OBJ_LIST_ADD_LIVE)))
+    if (!(net = virNetworkObjAssignDef(nets, def,
+                                       VIR_NETWORK_OBJ_LIST_ADD_LIVE)))
         goto error;
     /* do not put any "goto error" below this comment */
 
@@ -782,7 +783,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
 }
 
 
-virNetworkObjPtr
+static virNetworkObjPtr
 virNetworkLoadConfig(virNetworkObjListPtr nets,
                      const char *configDir,
                      const char *autostartDir,
@@ -827,7 +828,7 @@ virNetworkLoadConfig(virNetworkObjListPtr nets,
         def->mac_specified = false;
     }
 
-    if (!(net = virNetworkAssignDef(nets, def, 0)))
+    if (!(net = virNetworkObjAssignDef(nets, def, 0)))
         goto error;
 
     net->autostart = autostart;
@@ -846,8 +847,8 @@ virNetworkLoadConfig(virNetworkObjListPtr nets,
 
 
 int
-virNetworkLoadAllState(virNetworkObjListPtr nets,
-                       const char *stateDir)
+virNetworkObjLoadAllState(virNetworkObjListPtr nets,
+                          const char *stateDir)
 {
     DIR *dir;
     struct dirent *entry;
@@ -873,9 +874,9 @@ virNetworkLoadAllState(virNetworkObjListPtr nets,
 
 
 int
-virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
-                         const char *configDir,
-                         const char *autostartDir)
+virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets,
+                            const char *configDir,
+                            const char *autostartDir)
 {
     DIR *dir;
     struct dirent *entry;
@@ -906,9 +907,9 @@ virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
 
 
 int
-virNetworkDeleteConfig(const char *configDir,
-                       const char *autostartDir,
-                       virNetworkObjPtr net)
+virNetworkObjDeleteConfig(const char *configDir,
+                          const char *autostartDir,
+                          virNetworkObjPtr net)
 {
     char *configFile = NULL;
     char *autostartLink = NULL;
@@ -939,19 +940,19 @@ virNetworkDeleteConfig(const char *configDir,
 }
 
 
-struct virNetworkBridgeInUseHelperData {
+struct virNetworkObjBridgeInUseHelperData {
     const char *bridge;
     const char *skipname;
 };
 
 static int
-virNetworkBridgeInUseHelper(const void *payload,
-                            const void *name ATTRIBUTE_UNUSED,
-                            const void *opaque)
+virNetworkObjBridgeInUseHelper(const void *payload,
+                               const void *name ATTRIBUTE_UNUSED,
+                               const void *opaque)
 {
     int ret;
     virNetworkObjPtr net = (virNetworkObjPtr) payload;
-    const struct virNetworkBridgeInUseHelperData *data = opaque;
+    const struct virNetworkObjBridgeInUseHelperData *data = opaque;
 
     virObjectLock(net);
     if (data->skipname &&
@@ -971,15 +972,15 @@ virNetworkBridgeInUseHelper(const void *payload,
 
 
 int
-virNetworkBridgeInUse(virNetworkObjListPtr nets,
-                      const char *bridge,
-                      const char *skipname)
+virNetworkObjBridgeInUse(virNetworkObjListPtr nets,
+                         const char *bridge,
+                         const char *skipname)
 {
     virNetworkObjPtr obj;
-    struct virNetworkBridgeInUseHelperData data = {bridge, skipname};
+    struct virNetworkObjBridgeInUseHelperData data = {bridge, skipname};
 
     virObjectLock(nets);
-    obj = virHashSearch(nets->objs, virNetworkBridgeInUseHelper, &data);
+    obj = virHashSearch(nets->objs, virNetworkObjBridgeInUseHelper, &data);
     virObjectUnlock(nets);
 
     return obj != NULL;
@@ -1012,7 +1013,7 @@ virNetworkObjUpdate(virNetworkObjPtr network,
     virNetworkDefPtr livedef = NULL, configdef = NULL;
 
     /* normalize config data, and check for common invalid requests. */
-    if (virNetworkConfigChangeSetup(network, flags) < 0)
+    if (virNetworkObjConfigChangeSetup(network, flags) < 0)
        goto cleanup;
 
     if (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE) {
diff --git a/src/conf/virnetworkobj.h b/src/conf/virnetworkobj.h
index 0b6fbfe..8090c2e 100644
--- a/src/conf/virnetworkobj.h
+++ b/src/conf/virnetworkobj.h
@@ -90,9 +90,9 @@ typedef bool
                            virNetworkDefPtr def);
 
 virNetworkObjPtr
-virNetworkAssignDef(virNetworkObjListPtr nets,
-                    virNetworkDefPtr def,
-                    unsigned int flags);
+virNetworkObjAssignDef(virNetworkObjListPtr nets,
+                       virNetworkDefPtr def,
+                       unsigned int flags);
 
 void
 virNetworkObjUpdateAssignDef(virNetworkObjPtr network,
@@ -113,47 +113,32 @@ int
 virNetworkObjReplacePersistentDef(virNetworkObjPtr network,
                                   virNetworkDefPtr def);
 
-int
-virNetworkConfigChangeSetup(virNetworkObjPtr dom,
-                            unsigned int flags);
-
 void
-virNetworkRemoveInactive(virNetworkObjListPtr nets,
-                         virNetworkObjPtr net);
+virNetworkObjRemoveInactive(virNetworkObjListPtr nets,
+                            virNetworkObjPtr net);
 
 int
-virNetworkSaveStatus(const char *statusDir,
-                     virNetworkObjPtr net) ATTRIBUTE_RETURN_CHECK;
-
-virNetworkObjPtr
-virNetworkLoadConfig(virNetworkObjListPtr nets,
-                     const char *configDir,
-                     const char *autostartDir,
-                     const char *file);
-
-virNetworkObjPtr
-virNetworkLoadState(virNetworkObjListPtr nets,
-                    const char *stateDir,
-                    const char *name);
+virNetworkObjSaveStatus(const char *statusDir,
+                        virNetworkObjPtr net) ATTRIBUTE_RETURN_CHECK;
 
 int
-virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
-                         const char *configDir,
-                         const char *autostartDir);
+virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets,
+                            const char *configDir,
+                            const char *autostartDir);
 
 int
-virNetworkLoadAllState(virNetworkObjListPtr nets,
-                       const char *stateDir);
+virNetworkObjLoadAllState(virNetworkObjListPtr nets,
+                          const char *stateDir);
 
 int
-virNetworkDeleteConfig(const char *configDir,
-                       const char *autostartDir,
-                       virNetworkObjPtr net);
+virNetworkObjDeleteConfig(const char *configDir,
+                          const char *autostartDir,
+                          virNetworkObjPtr net);
 
 int
-virNetworkBridgeInUse(virNetworkObjListPtr nets,
-                      const char *bridge,
-                      const char *skipname);
+virNetworkObjBridgeInUse(virNetworkObjListPtr nets,
+                         const char *bridge,
+                         const char *skipname);
 
 int
 virNetworkObjUpdate(virNetworkObjPtr obj,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6aaa3f9..4861257 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -919,12 +919,9 @@ virInterfaceObjUnlock;
 
 
 # conf/virnetworkobj.h
-virNetworkAssignDef;
-virNetworkBridgeInUse;
-virNetworkConfigChangeSetup;
-virNetworkDeleteConfig;
-virNetworkLoadAllConfigs;
-virNetworkLoadAllState;
+virNetworkObjAssignDef;
+virNetworkObjBridgeInUse;
+virNetworkObjDeleteConfig;
 virNetworkObjEndAPI;
 virNetworkObjFindByName;
 virNetworkObjFindByNameLocked;
@@ -937,15 +934,17 @@ virNetworkObjListGetNames;
 virNetworkObjListNew;
 virNetworkObjListNumOfNetworks;
 virNetworkObjListPrune;
+virNetworkObjLoadAllConfigs;
+virNetworkObjLoadAllState;
 virNetworkObjNew;
+virNetworkObjRemoveInactive;
 virNetworkObjReplacePersistentDef;
+virNetworkObjSaveStatus;
 virNetworkObjSetDefTransient;
 virNetworkObjTaint;
 virNetworkObjUnsetDefTransient;
 virNetworkObjUpdate;
 virNetworkObjUpdateAssignDef;
-virNetworkRemoveInactive;
-virNetworkSaveStatus;
 
 
 # conf/virnodedeviceobj.h
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index b30caf5..45abe16 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -363,7 +363,7 @@ networkRemoveInactive(virNetworkDriverStatePtr driver,
     unlink(statusfile);
 
     /* remove the network definition */
-    virNetworkRemoveInactive(driver->networks, net);
+    virNetworkObjRemoveInactive(driver->networks, net);
 
     ret = 0;
 
@@ -753,13 +753,13 @@ networkStateInitialize(bool privileged,
     if (!(network_driver->networks = virNetworkObjListNew()))
         goto error;
 
-    if (virNetworkLoadAllState(network_driver->networks,
-                               network_driver->stateDir) < 0)
+    if (virNetworkObjLoadAllState(network_driver->networks,
+                                  network_driver->stateDir) < 0)
         goto error;
 
-    if (virNetworkLoadAllConfigs(network_driver->networks,
-                                 network_driver->networkConfigDir,
-                                 network_driver->networkAutostartDir) < 0)
+    if (virNetworkObjLoadAllConfigs(network_driver->networks,
+                                    network_driver->networkConfigDir,
+                                    network_driver->networkAutostartDir) < 0)
         goto error;
 
     /* Update the internal status of all allegedly active
@@ -841,11 +841,11 @@ networkStateReload(void)
     if (!network_driver)
         return 0;
 
-    virNetworkLoadAllState(network_driver->networks,
-                           network_driver->stateDir);
-    virNetworkLoadAllConfigs(network_driver->networks,
-                             network_driver->networkConfigDir,
-                             network_driver->networkAutostartDir);
+    virNetworkObjLoadAllState(network_driver->networks,
+                              network_driver->stateDir);
+    virNetworkObjLoadAllConfigs(network_driver->networks,
+                                network_driver->networkConfigDir,
+                                network_driver->networkAutostartDir);
     networkReloadFirewallRules(network_driver);
     networkRefreshDaemons(network_driver);
     virNetworkObjListForEach(network_driver->networks,
@@ -2751,7 +2751,7 @@ networkStartNetwork(virNetworkDriverStatePtr driver,
      * is setup.
      */
     VIR_DEBUG("Writing network status to disk");
-    if (virNetworkSaveStatus(driver->stateDir, network) < 0)
+    if (virNetworkObjSaveStatus(driver->stateDir, network) < 0)
         goto cleanup;
 
     network->active = 1;
@@ -3076,7 +3076,7 @@ networkFindUnusedBridgeName(virNetworkObjListPtr nets,
          * from virNetDevExists(), just in case it isn't implemented
          * on this platform (probably impossible).
          */
-        if (!(virNetworkBridgeInUse(nets, newname, def->name) ||
+        if (!(virNetworkObjBridgeInUse(nets, newname, def->name) ||
               virNetDevExists(newname) == 1)) {
             VIR_FREE(def->bridge); /*could contain template */
             def->bridge = newname;
@@ -3112,7 +3112,7 @@ networkBridgeNameValidate(virNetworkObjListPtr nets,
     int ret = -1;
 
     if (def->bridge && !strstr(def->bridge, "%d")) {
-        if (virNetworkBridgeInUse(nets, def->bridge, def->name)) {
+        if (virNetworkObjBridgeInUse(nets, def->bridge, def->name)) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("bridge name '%s' already in use."),
                            def->bridge);
@@ -3429,15 +3429,14 @@ static virNetworkPtr networkCreateXML(virConnectPtr conn, const char *xml)
      * we assign the def with live = true in anticipation that it will
      * be started momentarily.
      */
-    if (!(network = virNetworkAssignDef(driver->networks, def,
-                                        VIR_NETWORK_OBJ_LIST_ADD_LIVE |
-                                        VIR_NETWORK_OBJ_LIST_ADD_CHECK_LIVE)))
+    if (!(network = virNetworkObjAssignDef(driver->networks, def,
+                                           VIR_NETWORK_OBJ_LIST_ADD_LIVE |
+                                           VIR_NETWORK_OBJ_LIST_ADD_CHECK_LIVE)))
         goto cleanup;
     def = NULL;
 
     if (networkStartNetwork(driver, network) < 0) {
-        virNetworkRemoveInactive(driver->networks,
-                                 network);
+        virNetworkObjRemoveInactive(driver->networks, network);
         goto cleanup;
     }
 
@@ -3475,7 +3474,7 @@ static virNetworkPtr networkDefineXML(virConnectPtr conn, const char *xml)
     if (networkValidate(driver, def) < 0)
         goto cleanup;
 
-    if (!(network = virNetworkAssignDef(driver->networks, def, 0)))
+    if (!(network = virNetworkObjAssignDef(driver->networks, def, 0)))
         goto cleanup;
 
     /* def was assigned to network object */
@@ -3483,7 +3482,7 @@ static virNetworkPtr networkDefineXML(virConnectPtr conn, const char *xml)
 
     if (virNetworkSaveConfig(driver->networkConfigDir, def) < 0) {
         if (!virNetworkObjIsActive(network)) {
-            virNetworkRemoveInactive(driver->networks, network);
+            virNetworkObjRemoveInactive(driver->networks, network);
             goto cleanup;
         }
         /* if network was active already, just undo new persistent
@@ -3535,9 +3534,9 @@ networkUndefine(virNetworkPtr net)
     }
 
     /* remove autostart link */
-    if (virNetworkDeleteConfig(driver->networkConfigDir,
-                               driver->networkAutostartDir,
-                               network) < 0)
+    if (virNetworkObjDeleteConfig(driver->networkConfigDir,
+                                  driver->networkAutostartDir,
+                                  network) < 0)
         goto cleanup;
 
     event = virNetworkEventLifecycleNew(network->def->name,
@@ -3725,10 +3724,8 @@ networkUpdate(virNetworkPtr net,
         }
 
         /* save current network state to disk */
-        if ((ret = virNetworkSaveStatus(driver->stateDir,
-                                        network)) < 0) {
+        if ((ret = virNetworkObjSaveStatus(driver->stateDir, network)) < 0)
             goto cleanup;
-        }
     }
 
     /* call the 'updated' network hook script */
@@ -5312,7 +5309,7 @@ networkPlugBandwidthImpl(virNetworkObjPtr net,
     /* update sum of 'floor'-s of attached NICs */
     net->floor_sum += ifaceBand->in->floor;
     /* update status file */
-    if (virNetworkSaveStatus(driver->stateDir, net) < 0) {
+    if (virNetworkObjSaveStatus(driver->stateDir, net) < 0) {
         ignore_value(virBitmapClearBit(net->class_id, class_id));
         net->floor_sum -= ifaceBand->in->floor;
         iface->data.network.actual->class_id = 0;
@@ -5404,7 +5401,7 @@ networkUnplugBandwidth(virNetworkObjPtr net,
         ignore_value(virBitmapClearBit(net->class_id,
                                        iface->data.network.actual->class_id));
         /* update status file */
-        if (virNetworkSaveStatus(driver->stateDir, net) < 0) {
+        if (virNetworkObjSaveStatus(driver->stateDir, net) < 0) {
             net->floor_sum += ifaceBand->in->floor;
             ignore_value(virBitmapSetBit(net->class_id,
                                          iface->data.network.actual->class_id));
@@ -5548,7 +5545,7 @@ networkBandwidthUpdate(virDomainNetDefPtr iface,
 
         if (virNetDevBandwidthUpdateRate(network->def->bridge, 2,
                                          network->def->bandwidth, new_rate) < 0 ||
-            virNetworkSaveStatus(driver->stateDir, network) < 0) {
+            virNetworkObjSaveStatus(driver->stateDir, network) < 0) {
             /* Ouch, rollback */
             network->floor_sum -= newBandwidth->in->floor;
             network->floor_sum += ifaceBand->in->floor;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 1fd7414..12eecea 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -980,7 +980,7 @@ testParseNetworks(testDriverPtr privconn,
         if (!def)
             goto error;
 
-        if (!(obj = virNetworkAssignDef(privconn->networks, def, 0))) {
+        if (!(obj = virNetworkObjAssignDef(privconn->networks, def, 0))) {
             virNetworkDefFree(def);
             goto error;
         }
@@ -3371,9 +3371,9 @@ static virNetworkPtr testNetworkCreateXML(virConnectPtr conn, const char *xml)
     if ((def = virNetworkDefParseString(xml)) == NULL)
         goto cleanup;
 
-    if (!(net = virNetworkAssignDef(privconn->networks, def,
-                                    VIR_NETWORK_OBJ_LIST_ADD_LIVE |
-                                    VIR_NETWORK_OBJ_LIST_ADD_CHECK_LIVE)))
+    if (!(net = virNetworkObjAssignDef(privconn->networks, def,
+                                       VIR_NETWORK_OBJ_LIST_ADD_LIVE |
+                                       VIR_NETWORK_OBJ_LIST_ADD_CHECK_LIVE)))
         goto cleanup;
     def = NULL;
     net->active = 1;
@@ -3403,7 +3403,7 @@ virNetworkPtr testNetworkDefineXML(virConnectPtr conn, const char *xml)
     if ((def = virNetworkDefParseString(xml)) == NULL)
         goto cleanup;
 
-    if (!(net = virNetworkAssignDef(privconn->networks, def, 0)))
+    if (!(net = virNetworkObjAssignDef(privconn->networks, def, 0)))
         goto cleanup;
     def = NULL;
 
@@ -3440,7 +3440,7 @@ static int testNetworkUndefine(virNetworkPtr network)
                                         VIR_NETWORK_EVENT_UNDEFINED,
                                         0);
 
-    virNetworkRemoveInactive(privconn->networks, privnet);
+    virNetworkObjRemoveInactive(privconn->networks, privnet);
     ret = 0;
 
  cleanup:
@@ -3534,7 +3534,7 @@ static int testNetworkDestroy(virNetworkPtr network)
                                         VIR_NETWORK_EVENT_STOPPED,
                                         0);
     if (!privnet->persistent)
-        virNetworkRemoveInactive(privconn->networks, privnet);
+        virNetworkObjRemoveInactive(privconn->networks, privnet);
 
     ret = 0;
 
-- 
2.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux