connection: Do initial object refreshes in a thread

None of these objects are urgent, and this allows us to split up the
initial API calls to be more parallel.
This commit is contained in:
Cole Robinson 2014-09-12 11:55:34 -04:00
parent 37e0f16c8b
commit 76bc8e5ab9
3 changed files with 34 additions and 7 deletions

View File

@ -1102,6 +1102,31 @@ class vmmConnection(vmmGObject):
if e: if e:
raise e # pylint: disable=raising-bad-type raise e # pylint: disable=raising-bad-type
def _refresh_new_objects(self, newlist):
if not newlist:
return
def _refresh_generic():
for obj in newlist:
obj.refresh_xml()
def _refresh_pool():
for pool in newlist:
pool.refresh()
def _refresh_volumes(p):
for vol in p.get_volumes().values():
vol.refresh_xml()
self._start_thread(_refresh_volumes,
"pool=%s refreshing xml for volumes" % pool.get_name(),
(pool,))
cb = _refresh_generic
if hasattr(newlist[0], "get_volumes"):
cb = _refresh_pool
self._start_thread(cb,
"refreshing xml for new %s" % newlist[0].__class__)
def _tick(self, stats_update, def _tick(self, stats_update,
pollvm=False, pollnet=False, pollvm=False, pollnet=False,
pollpool=False, polliface=False, pollpool=False, polliface=False,
@ -1135,11 +1160,19 @@ class vmmConnection(vmmGObject):
self.hostinfo = self._backend.getInfo() self.hostinfo = self._backend.getInfo()
(goneNets, newNets, nets) = self._update_nets(pollnet) (goneNets, newNets, nets) = self._update_nets(pollnet)
self._refresh_new_objects(newNets.values())
(gonePools, newPools, pools) = self._update_pools(pollpool) (gonePools, newPools, pools) = self._update_pools(pollpool)
self._refresh_new_objects(newPools.values())
(goneInterfaces, (goneInterfaces,
newInterfaces, interfaces) = self._update_interfaces(polliface) newInterfaces, interfaces) = self._update_interfaces(polliface)
self._refresh_new_objects(newInterfaces.values())
# Refreshing these is handled by the mediadev callback
(goneNodedevs, (goneNodedevs,
newNodedevs, nodedevs) = self._update_nodedevs(pollnodedev) newNodedevs, nodedevs) = self._update_nodedevs(pollnodedev)
# These are refreshing in their __init__ method, because the
# data is wanted immediately
(goneVMs, newVMs, vms) = self._update_vms(pollvm) (goneVMs, newVMs, vms) = self._update_vms(pollvm)
def tick_send_signals(): def tick_send_signals():

View File

@ -35,7 +35,6 @@ class vmmInterface(vmmLibvirtObject):
self._support_isactive = None self._support_isactive = None
self.tick() self.tick()
self.refresh_xml()
# Routines from vmmLibvirtObject # Routines from vmmLibvirtObject
def _XMLDesc(self, flags): def _XMLDesc(self, flags):

View File

@ -108,7 +108,6 @@ class vmmStoragePool(vmmLibvirtObject):
self._volumes = {} self._volumes = {}
self.tick() self.tick()
self.refresh()
########################## ##########################
@ -204,13 +203,9 @@ class vmmStoragePool(vmmLibvirtObject):
self._volumes = {} self._volumes = {}
return return
(ignore, new, allvols) = pollhelpers.fetch_volumes( (ignore, ignore, allvols) = pollhelpers.fetch_volumes(
self.conn.get_backend(), self.get_backend(), self._volumes.copy(), self.conn.get_backend(), self.get_backend(), self._volumes.copy(),
lambda obj, key: vmmStorageVolume(self.conn, obj, key)) lambda obj, key: vmmStorageVolume(self.conn, obj, key))
for volname in allvols:
if volname not in new:
allvols[volname].refresh_xml()
self._volumes = allvols self._volumes = allvols