Please add something like this to the commit message body: API will be available in upcoming libvirt 2.2.0 On 08/08/2016 03:41 PM, Jovanka Gulicoska wrote: > --- > virtManager/connection.py | 37 +++++++++++++++++++++++++++++++++++++ > virtManager/nodedev.py | 3 +++ > 2 files changed, 40 insertions(+) > > diff --git a/virtManager/connection.py b/virtManager/connection.py > index 5ca8786..97a6d19 100644 > --- a/virtManager/connection.py > +++ b/virtManager/connection.py > @@ -215,6 +215,8 @@ class vmmConnection(vmmGObject): > self._network_cb_ids = [] > self.using_storage_pool_events = False > self._storage_pool_cb_ids = [] > + self.using_node_device_events = False > + self._node_device_cb_ids = [] > > self._xml_flags = {} > > @@ -796,6 +798,22 @@ class vmmConnection(vmmGObject): > else: > self.schedule_priority_tick(pollpool=True, force=True) > > + def _node_device_lifecycle_event(self, conn, dev, > + event, reason, userdata): > + ignore = conn > + ignore = userdata > + > + name = dev.name() > + logging.debug("node device lifecycle event: device=%s event=%s " > + "reason=%s", name, event, reason) > + > + obj = self.get_nodedev(name) > + > + if obj: > + self.idle_add(obj.recache_from_event_loop) > + else: > + self.schedule_priority_tick(pollnodedev=True, force=True) > + Since these nodedev events are only when a device is added or removed, we want to unconditionally repoll the whole netdev list, and the recache_from_event_loop bit is redundant and should be removed. The recache logic will be used when UPDATE support is added though, but in a different function > def _add_conn_events(self): > if not self.check_support(support.SUPPORT_CONN_WORKING_XEN_EVENTS): > return > @@ -866,6 +884,20 @@ class vmmConnection(vmmGObject): > self.using_storage_pool_events = False > logging.debug("Error registering storage pool events: %s", e) > > + try: > + if FORCE_DISABLE_EVENTS: > + raise RuntimeError("FORCE_DISABLE_EVENTS = True") > + > + eventid = getattr(libvirt, "VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE", 0) > + self._node_device_cb_ids.append( > + self.get_backend().nodeDeviceEventRegisterAny( > + None, eventid, self._node_device_lifecycle_event, None)) > + self.using_node_device_events = True > + logging.debug("Using node device events") > + except Exception, e: > + self.using_network_events = False > + logging.debug("Error registering node device events: %s", e) > + > > ###################################### > # Connection closing/opening methods # > @@ -888,6 +920,8 @@ class vmmConnection(vmmGObject): > self._backend.networkEventDeregisterAny(eid) > for eid in self._storage_pool_cb_ids: > self._backend.storagePoolEventDeregisterAny(eid) > + for eid in self._node_device_cb_ids: > + self._backend.nodeDeviceEventDeregisterAny(eid) > except: > logging.debug("Failed to deregister events in conn cleanup", > exc_info=True) > @@ -895,6 +929,7 @@ class vmmConnection(vmmGObject): > self._domain_cb_ids = [] > self._network_cb_ids = [] > self._storage_pool_cb_ids = [] > + self._node_device_cb_ids = [] > > self._backend.close() > self._stats = [] > @@ -1227,6 +1262,8 @@ class vmmConnection(vmmGObject): > pollnet = False > if self.using_storage_pool_events and not force: > pollpool = False > + if self.using_node_device_events and not force: > + pollnodedev = False > > self._hostinfo = self._backend.getInfo() > > diff --git a/virtManager/nodedev.py b/virtManager/nodedev.py > index 4046ff0..af10e8d 100644 > --- a/virtManager/nodedev.py > +++ b/virtManager/nodedev.py > @@ -44,9 +44,12 @@ class vmmNodeDevice(vmmLibvirtObject): > return self.get_connkey() > def is_active(self): > return True > + def _using_events(self): > + return self.conn.using_node_device_events > > def tick(self, stats_update=True): > # Deliberately empty > ignore = stats_update > def _init_libvirt_state(self): > + self.tick() > self.ensure_latest_xml() > I don't think this self.tick() bit does anything and can be dropped Otherwise looks good! Thanks, Cole _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list