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(a)redhat.com>
---
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 481c151..e495932 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -347,9 +347,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;
@@ -415,7 +415,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
@@ -425,19 +425,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;
}
@@ -533,7 +533,7 @@ virNetworkObjReplacePersistentDef(virNetworkObjPtr network,
/*
- * virNetworkConfigChangeSetup:
+ * virNetworkObjConfigChangeSetup:
*
* 1) checks whether network state is consistent with the requested
* type of modification.
@@ -543,9 +543,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;
@@ -579,8 +579,8 @@ virNetworkConfigChangeSetup(virNetworkObjPtr network,
void
-virNetworkRemoveInactive(virNetworkObjListPtr nets,
- virNetworkObjPtr net)
+virNetworkObjRemoveInactive(virNetworkObjListPtr nets,
+ virNetworkObjPtr net)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -636,8 +636,8 @@ virNetworkObjFormat(virNetworkObjPtr net,
int
-virNetworkSaveStatus(const char *statusDir,
- virNetworkObjPtr network)
+virNetworkObjSaveStatus(const char *statusDir,
+ virNetworkObjPtr network)
{
int ret = -1;
int flags = 0;
@@ -656,7 +656,7 @@ virNetworkSaveStatus(const char *statusDir,
}
-virNetworkObjPtr
+static virNetworkObjPtr
virNetworkLoadState(virNetworkObjListPtr nets,
const char *stateDir,
const char *name)
@@ -751,7 +751,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 */
@@ -781,7 +782,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
}
-virNetworkObjPtr
+static virNetworkObjPtr
virNetworkLoadConfig(virNetworkObjListPtr nets,
const char *configDir,
const char *autostartDir,
@@ -826,7 +827,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;
@@ -845,8 +846,8 @@ virNetworkLoadConfig(virNetworkObjListPtr nets,
int
-virNetworkLoadAllState(virNetworkObjListPtr nets,
- const char *stateDir)
+virNetworkObjLoadAllState(virNetworkObjListPtr nets,
+ const char *stateDir)
{
DIR *dir;
struct dirent *entry;
@@ -872,9 +873,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;
@@ -905,9 +906,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;
@@ -938,19 +939,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 &&
@@ -970,15 +971,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;
@@ -1011,7 +1012,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 bae0f4e..a097533 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -909,12 +909,9 @@ virInterfaceObjUnlock;
# conf/virnetworkobj.h
-virNetworkAssignDef;
-virNetworkBridgeInUse;
-virNetworkConfigChangeSetup;
-virNetworkDeleteConfig;
-virNetworkLoadAllConfigs;
-virNetworkLoadAllState;
+virNetworkObjAssignDef;
+virNetworkObjBridgeInUse;
+virNetworkObjDeleteConfig;
virNetworkObjEndAPI;
virNetworkObjFindByName;
virNetworkObjFindByNameLocked;
@@ -927,15 +924,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 c675f1e..c820a78 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -360,7 +360,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,
@@ -2735,7 +2735,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;
@@ -3060,7 +3060,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;
@@ -3096,7 +3096,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);
@@ -3372,15 +3372,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;
}
@@ -3418,7 +3417,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 */
@@ -3426,7 +3425,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
@@ -3478,9 +3477,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,
@@ -3668,10 +3667,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 */
@@ -5227,7 +5224,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;
@@ -5319,7 +5316,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));
@@ -5463,7 +5460,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 f78a181..7eaa470 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;
}
@@ -3381,9 +3381,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;
@@ -3413,7 +3413,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;
@@ -3450,7 +3450,7 @@ static int testNetworkUndefine(virNetworkPtr network)
VIR_NETWORK_EVENT_UNDEFINED,
0);
- virNetworkRemoveInactive(privconn->networks, privnet);
+ virNetworkObjRemoveInactive(privconn->networks, privnet);
ret = 0;
cleanup:
@@ -3544,7 +3544,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