connection: Cache 'storage supported' check

Otherwise we were hitting libvirt more than necc.
This commit is contained in:
Cole Robinson 2011-04-07 17:57:19 -04:00
parent 6da0a95b57
commit 16e43da0ae
2 changed files with 15 additions and 19 deletions

View File

@ -119,7 +119,7 @@ class vmmConnection(vmmGObject):
self._caps_xml = None
self.network_capable = None
self.storage_capable = None
self._storage_capable = None
self.interface_capable = None
self._nodedev_capable = None
@ -489,7 +489,19 @@ class vmmConnection(vmmGObject):
#######################
def is_storage_capable(self):
return virtinst.util.is_storage_capable(self.vmm)
if self._storage_capable == None:
self._storage_capable = virtinst.util.is_storage_capable(self.vmm)
if self._storage_capable is False:
logging.debug("Connection doesn't seem to support storage "
"APIs. Skipping all storage polling.")
else:
# Try to create the default storage pool
try:
util.build_default_pool(self)
except Exception, e:
logging.debug("Building default pool failed: %s" % str(e))
return self._storage_capable
def is_nodedev_capable(self):
if self._nodedev_capable == None:
@ -1202,20 +1214,7 @@ class vmmConnection(vmmGObject):
newActivePoolNames = []
newInactivePoolNames = []
if self.storage_capable == None:
self.storage_capable = virtinst.util.is_storage_capable(self.vmm)
if self.storage_capable is False:
logging.debug("Connection doesn't seem to support storage "
"APIs. Skipping all storage polling.")
else:
# Try to create the default storage pool
try:
util.build_default_pool(self)
except Exception, e:
logging.debug("Building default pool failed: %s" % str(e))
if not self.storage_capable:
if self.is_storage_capable() is False:
return (stopPools, startPools, origPools, newPools, currentPools)
try:

View File

@ -47,9 +47,6 @@ def build_default_pool(vmmconn):
"""
# FIXME: This should use config.get_default_image_path ?
conn = vmmconn.vmm
if not virtinst.util.is_storage_capable(conn):
# VirtualDisk will raise an error for us
return
path = get_default_pool_path(vmmconn)
name = get_default_pool_name(vmmconn)