On 05/19/2017 08:34 AM, Pavel Hrdina wrote: > The cb_add_new_pool callback will add a newly created storage pool > into virt-manager's cache so we don't have to wait for the libvirt > event to be handled. > > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1435064 > > Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> > --- > > This is not ideal solution for the caching code, we need to implement > some synchronization features, however this helps to add cached objects > into our internal cache if they are created by us. This can be also > done for the remaining cached objects that we also creates. > > virtManager/connection.py | 9 +++++++-- > virtinst/storage.py | 3 +++ > 2 files changed, 10 insertions(+), 2 deletions(-) > Yeah these problems are tricky, would need some re-architecting to handle it properly, but this looks like a good stop gap to me ACK Thanks, Cole > diff --git a/virtManager/connection.py b/virtManager/connection.py > index 52d108ac..7e57a856 100644 > --- a/virtManager/connection.py > +++ b/virtManager/connection.py > @@ -286,6 +286,10 @@ class vmmConnection(vmmGObject): > return ret > self._backend.cb_fetch_all_vols = fetch_all_vols > > + def add_new_pool(obj, key): > + self._new_object_cb(vmmStoragePool(self, obj, key), False, True) > + self._backend.cb_add_new_pool = add_new_pool > + > def clear_cache(pools=False): > if not pools: > return > @@ -974,6 +978,7 @@ class vmmConnection(vmmGObject): > self._backend.cb_fetch_all_nodedevs = None > self._backend.cb_fetch_all_vols = None > self._backend.cb_clear_cache = None > + self._backend.cb_add_new_pool = None > > def open(self): > if not self.is_disconnected(): > @@ -1133,7 +1138,7 @@ class vmmConnection(vmmGObject): > self.emit("nodedev-removed", obj.get_connkey()) > obj.cleanup() > > - def _new_object_cb(self, obj, initialize_failed): > + def _new_object_cb(self, obj, initialize_failed, skip_init=False): > if not self._backend.is_open(): > return > > @@ -1166,7 +1171,7 @@ class vmmConnection(vmmGObject): > elif class_name == "nodedev": > self.emit("nodedev-added", obj.get_connkey()) > finally: > - if self._init_object_event: > + if self._init_object_event and not skip_init: > self._init_object_count -= 1 > if self._init_object_count <= 0: > self._init_object_event.set() > diff --git a/virtinst/storage.py b/virtinst/storage.py > index a6963d50..e958b154 100644 > --- a/virtinst/storage.py > +++ b/virtinst/storage.py > @@ -560,6 +560,9 @@ class StoragePool(_StorageObject): > "%s" % str(e)) > raise RuntimeError(errmsg) > > + if self.conn.cb_add_new_pool: > + self.conn.cb_add_new_pool(pool, self.name) > + > return pool > > > _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list