Now that the network driver lock is ash heap of history,
we can use more of networkObjFromNetwork().
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/network/bridge_driver.c | 33 +++++----------------------------
1 file changed, 5 insertions(+), 28 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 529ba2b..2eb225f 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -130,7 +130,6 @@ networkObjFromNetwork(virNetworkPtr net)
char uuidstr[VIR_UUID_STRING_BUFLEN];
network = virNetworkObjFindByUUID(driver->networks, net->uuid);
-
if (!network) {
virUUIDFormat(net->uuid, uuidstr);
virReportError(VIR_ERR_NO_NETWORK,
@@ -3005,12 +3004,8 @@ networkUndefine(virNetworkPtr net)
bool active = false;
virObjectEventPtr event = NULL;
- network = virNetworkObjFindByUUID(driver->networks, net->uuid);
- if (!network) {
- virReportError(VIR_ERR_NO_NETWORK,
- "%s", _("no network with matching uuid"));
+ if (!(network = networkObjFromNetwork(net)))
goto cleanup;
- }
if (virNetworkUndefineEnsureACL(net->conn, network->def) < 0)
goto cleanup;
@@ -3071,12 +3066,8 @@ networkUpdate(virNetworkPtr net,
VIR_NETWORK_UPDATE_AFFECT_CONFIG,
-1);
- network = virNetworkObjFindByUUID(driver->networks, net->uuid);
- if (!network) {
- virReportError(VIR_ERR_NO_NETWORK,
- "%s", _("no network with matching uuid"));
+ if (!(network = networkObjFromNetwork(net)))
goto cleanup;
- }
if (virNetworkUpdateEnsureACL(net->conn, network->def, flags) < 0)
goto cleanup;
@@ -3225,13 +3216,8 @@ static int networkCreate(virNetworkPtr net)
int ret = -1;
virObjectEventPtr event = NULL;
- network = virNetworkObjFindByUUID(driver->networks, net->uuid);
-
- if (!network) {
- virReportError(VIR_ERR_NO_NETWORK,
- "%s", _("no network with matching uuid"));
+ if (!(network = networkObjFromNetwork(net)))
goto cleanup;
- }
if (virNetworkCreateEnsureACL(net->conn, network->def) < 0)
goto cleanup;
@@ -3257,13 +3243,8 @@ static int networkDestroy(virNetworkPtr net)
int ret = -1;
virObjectEventPtr event = NULL;
- network = virNetworkObjFindByUUID(driver->networks, net->uuid);
-
- if (!network) {
- virReportError(VIR_ERR_NO_NETWORK,
- "%s", _("no network with matching uuid"));
+ if (!(network = networkObjFromNetwork(net)))
goto cleanup;
- }
if (virNetworkDestroyEnsureACL(net->conn, network->def) < 0)
goto cleanup;
@@ -3375,13 +3356,9 @@ static int networkSetAutostart(virNetworkPtr net,
int ret = -1;
networkDriverLock();
- network = virNetworkObjFindByUUID(driver->networks, net->uuid);
- if (!network) {
- virReportError(VIR_ERR_NO_NETWORK,
- "%s", _("no network with matching uuid"));
+ if (!(network = networkObjFromNetwork(net)))
goto cleanup;
- }
if (virNetworkSetAutostartEnsureACL(net->conn, network->def) < 0)
goto cleanup;
--
2.0.5