[virt-manager PATCH] virtManager.connection: introduce cb_add_new_pool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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(-)

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
 
 
-- 
2.13.0

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux