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

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



On 08/17/2016 04:32 AM, Jovanka Gulicoska wrote:
> 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")
> +

Creating a separate function here is a bit overkill. I know that's the pattern
used for domain events above but that's because there is an ever growing list
of potential events we want to register. nodedev is likely not going to change
beyond these two events, at least WRT to virt-manager. So I took out the
nodeDeviceEventRegisterAny and opencoded it with the nodedev lifecycle chunk
above, fixed the typo in the commit subject, and pushed now

Thanks,
Cole

>      ######################################
>      # Connection closing/opening methods #
>      ######################################
> 


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