Blame SOURCES/virt-manager-virtManager.connection-introduce-cb_add_new_pool.patch

184e0d
From 763fa93d4cb13c819278dd942b536428ef75515d Mon Sep 17 00:00:00 2001
184e0d
From: Pavel Hrdina <phrdina@redhat.com>
184e0d
Date: Fri, 19 May 2017 14:26:49 +0200
184e0d
Subject: virtManager.connection: introduce cb_add_new_pool
184e0d
184e0d
The cb_add_new_pool callback will add a newly created storage pool
184e0d
into virt-manager's cache so we don't have to wait for the libvirt
184e0d
event to be handled.
184e0d
184e0d
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1435064
184e0d
184e0d
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
184e0d
(cherry picked from commit 168651188674f35ce4afd8b3c0bac1a6be2317c0)
184e0d
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
184e0d
---
184e0d
 virtManager/connection.py | 9 +++++++--
184e0d
 virtinst/connection.py    | 1 +
184e0d
 virtinst/storage.py       | 3 +++
184e0d
 3 files changed, 11 insertions(+), 2 deletions(-)
184e0d
184e0d
diff --git a/virtManager/connection.py b/virtManager/connection.py
184e0d
index 49979182..12e36a13 100644
184e0d
--- a/virtManager/connection.py
184e0d
+++ b/virtManager/connection.py
184e0d
@@ -286,6 +286,10 @@ class vmmConnection(vmmGObject):
184e0d
             return ret
184e0d
         self._backend.cb_fetch_all_vols = fetch_all_vols
184e0d
 
184e0d
+        def add_new_pool(obj, key):
184e0d
+            self._new_object_cb(vmmStoragePool(self, obj, key), False, True)
184e0d
+        self._backend.cb_add_new_pool = add_new_pool
184e0d
+
184e0d
         def clear_cache(pools=False):
184e0d
             if not pools:
184e0d
                 return
184e0d
@@ -973,6 +977,7 @@ class vmmConnection(vmmGObject):
184e0d
         self._backend.cb_fetch_all_nodedevs = None
184e0d
         self._backend.cb_fetch_all_vols = None
184e0d
         self._backend.cb_clear_cache = None
184e0d
+        self._backend.cb_add_new_pool = None
184e0d
 
184e0d
     def open(self):
184e0d
         if not self.is_disconnected():
184e0d
@@ -1132,7 +1137,7 @@ class vmmConnection(vmmGObject):
184e0d
                 self.emit("nodedev-removed", obj.get_connkey())
184e0d
             obj.cleanup()
184e0d
 
184e0d
-    def _new_object_cb(self, obj, initialize_failed):
184e0d
+    def _new_object_cb(self, obj, initialize_failed, skip_init=False):
184e0d
         if not self._backend.is_open():
184e0d
             return
184e0d
 
184e0d
@@ -1165,7 +1170,7 @@ class vmmConnection(vmmGObject):
184e0d
             elif class_name == "nodedev":
184e0d
                 self.emit("nodedev-added", obj.get_connkey())
184e0d
         finally:
184e0d
-            if self._init_object_event:
184e0d
+            if self._init_object_event and not skip_init:
184e0d
                 self._init_object_count -= 1
184e0d
                 if self._init_object_count <= 0:
184e0d
                     self._init_object_event.set()
184e0d
diff --git a/virtinst/connection.py b/virtinst/connection.py
184e0d
index e8d2378c..b2f37e67 100644
184e0d
--- a/virtinst/connection.py
184e0d
+++ b/virtinst/connection.py
184e0d
@@ -86,6 +86,7 @@ class VirtualConnection(object):
184e0d
         self.cb_fetch_all_vols = None
184e0d
         self.cb_fetch_all_nodedevs = None
184e0d
         self.cb_clear_cache = None
184e0d
+        self.cb_add_new_pool = None
184e0d
 
184e0d
 
184e0d
     ##############
184e0d
diff --git a/virtinst/storage.py b/virtinst/storage.py
184e0d
index 808891f3..647de931 100644
184e0d
--- a/virtinst/storage.py
184e0d
+++ b/virtinst/storage.py
184e0d
@@ -560,6 +560,9 @@ class StoragePool(_StorageObject):
184e0d
                               "%s" % str(e))
184e0d
             raise RuntimeError(errmsg)
184e0d
 
184e0d
+        if self.conn.cb_add_new_pool:
184e0d
+            self.conn.cb_add_new_pool(pool, self.name)
184e0d
+
184e0d
         return pool
184e0d
 
184e0d
 
184e0d
-- 
184e0d
2.13.0
184e0d