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