Change in vdsm[master]: net_scale: avoid netinfo instantiation for removal check

asegurap at redhat.com asegurap at redhat.com
Thu Feb 6 13:31:34 UTC 2014


Antoni Segura Puimedon has uploaded a new change for review.

Change subject: net_scale: avoid netinfo instantiation for removal check
......................................................................

net_scale: avoid netinfo instantiation for removal check

When removing networks, delNetwork used to generate a whole NetInfo
instance, which is rather costly and in the case that there's a lot
of delNetworks queued up (like in a lengthy setupNetworks operation)
it can impact performance significantly.

Change-Id: I1ff62dcd750ece1c3685c102723820aac5b432b2
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M lib/vdsm/netinfo.py
M vdsm/configNetwork.py
2 files changed, 12 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/58/24158/1

diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index b4931d1..e2a42ce 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -23,6 +23,7 @@
 from glob import iglob
 from datetime import datetime
 from itertools import chain
+import libvirt
 import logging
 import os
 import shlex
@@ -118,6 +119,15 @@
             if b.split('/')[-2] != DUMMY_BRIDGE]
 
 
+def networkExists(netName):
+    conn = libvirtconnection.get()
+    try:
+        conn.networkLookupByName(netName)
+    except libvirt.libvirtError:
+        return False
+    return True
+
+
 def networks():
     """
     Get dict of networks from libvirt
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 3b28b12..fc652db 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -414,9 +414,8 @@
     netEnt.remove()
 
     # We need to gather NetInfo again to refresh networks info from libvirt.
-    # The deleted bridge should never be up at this stage.
-    _netinfo = netinfo.NetInfo()
-    if network in _netinfo.networks:
+    # The deleted net should never exist at this stage.
+    if netinfo.networkExists(network):
         raise ConfigNetworkError(ne.ERR_USED_BRIDGE, 'delNetwork: bridge %s '
                                  'still exists' % network)
 


-- 
To view, visit http://gerrit.ovirt.org/24158
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ff62dcd750ece1c3685c102723820aac5b432b2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>


More information about the vdsm-patches mailing list