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

[virt-tools-list] [PATCH] Use dode device update event support



API will be available in upcoming libvirt 2.2.0
---
 virtManager/connection.py | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/virtManager/connection.py b/virtManager/connection.py
index 44f9bb5..8ef39a8 100644
--- a/virtManager/connection.py
+++ b/virtManager/connection.py
@@ -809,6 +809,18 @@ class vmmConnection(vmmGObject):
 
         self.schedule_priority_tick(pollnodedev=True, force=True)
 
+    def _node_device_update_event(self, conn, dev, userdata):
+        ignore = conn
+        ignore = userdata
+
+        name = dev.name()
+        logging.debug("node device update event: device=%s", name)
+
+        obj = self.get_nodedev(name)
+
+        if obj:
+            self.idle_add(obj.recache_from_event_loop)
+
     def _add_conn_events(self):
         if not self.check_support(support.SUPPORT_CONN_WORKING_XEN_EVENTS):
             return
@@ -894,6 +906,21 @@ class vmmConnection(vmmGObject):
             logging.debug("Error registering node device events: %s", e)
 
 
+        def _add_node_device_update_event(eventid, typestr):
+            if not self.using_node_device_events:
+                return
+            try:
+                self._node_device_cb_ids.append(
+                    self.get_backend().nodeDeviceEventRegisterAny(
+                    None, eventid, self._node_device_update_event, None))
+            except Exception, e:
+                logging.debug("Error registering node device %s event: %s",
+                    typestr, e)
+
+        _add_node_device_update_event(
+            getattr(libvirt, "VIR_NODE_DEVICE_EVENT_ID_UPDATE", 1),
+            "update")
+
     ######################################
     # Connection closing/opening methods #
     ######################################
-- 
2.7.4


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