diff --git a/virtManager/connection.py b/virtManager/connection.py index 526398ac..9acab3c1 100644 --- a/virtManager/connection.py +++ b/virtManager/connection.py @@ -1102,6 +1102,31 @@ class vmmConnection(vmmGObject): if e: 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, pollvm=False, pollnet=False, pollpool=False, polliface=False, @@ -1135,11 +1160,19 @@ class vmmConnection(vmmGObject): self.hostinfo = self._backend.getInfo() (goneNets, newNets, nets) = self._update_nets(pollnet) + self._refresh_new_objects(newNets.values()) (gonePools, newPools, pools) = self._update_pools(pollpool) + self._refresh_new_objects(newPools.values()) (goneInterfaces, newInterfaces, interfaces) = self._update_interfaces(polliface) + self._refresh_new_objects(newInterfaces.values()) + + # Refreshing these is handled by the mediadev callback (goneNodedevs, 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) def tick_send_signals(): diff --git a/virtManager/interface.py b/virtManager/interface.py index 55475a23..e7f78061 100644 --- a/virtManager/interface.py +++ b/virtManager/interface.py @@ -35,7 +35,6 @@ class vmmInterface(vmmLibvirtObject): self._support_isactive = None self.tick() - self.refresh_xml() # Routines from vmmLibvirtObject def _XMLDesc(self, flags): diff --git a/virtManager/storagepool.py b/virtManager/storagepool.py index 71036364..e1bd7a01 100644 --- a/virtManager/storagepool.py +++ b/virtManager/storagepool.py @@ -108,7 +108,6 @@ class vmmStoragePool(vmmLibvirtObject): self._volumes = {} self.tick() - self.refresh() ########################## @@ -204,13 +203,9 @@ class vmmStoragePool(vmmLibvirtObject): self._volumes = {} return - (ignore, new, allvols) = pollhelpers.fetch_volumes( + (ignore, ignore, allvols) = pollhelpers.fetch_volumes( self.conn.get_backend(), self.get_backend(), self._volumes.copy(), lambda obj, key: vmmStorageVolume(self.conn, obj, key)) - - for volname in allvols: - if volname not in new: - allvols[volname].refresh_xml() self._volumes = allvols