[libvirt] [PATCH] More event callback fixes

Daniel Veillard veillard at redhat.com
Fri Apr 9 12:30:30 UTC 2010


On Fri, Apr 09, 2010 at 11:51:46AM +0100, Daniel P. Berrange wrote:
> In a couple of cases typos meant we were firing the wrong type
> of event. In the python code my previous commit accidentally
> missed some chunks of the code.
> 
> * python/libvirt-override-virConnect.py: Add missing python glue
>   accidentally left out of previous commit
> * src/conf/domain_event.c, src/qemu/qemu_monitor_json.c: Fix typos
>   in event name / method name to invoke
> ---
>  python/libvirt-override-virConnect.py |   48 +++++++++++++++++++++++++++++++++
>  src/conf/domain_event.c               |    2 +-
>  src/qemu/qemu_monitor_json.c          |    2 +-
>  3 files changed, 50 insertions(+), 2 deletions(-)
> 
> diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
> index 444a499..b49f786 100644
> --- a/python/libvirt-override-virConnect.py
> +++ b/python/libvirt-override-virConnect.py
> @@ -63,6 +63,54 @@
>          except AttributeError:
>              pass
>  
> +    def dispatchDomainEventRTCChangeCallback(self, dom, offset, cbData):
> +        """Dispatches events to python user domain event callbacks
> +        """
> +        try:
> +            cb = cbData["cb"]
> +            opaque = cbData["opaque"]
> +
> +            cb(self, virDomain(self, _obj=dom), offset ,opaque)
> +            return 0
> +        except AttributeError:
> +            pass
> +
> +    def dispatchDomainEventWatchdogCallback(self, dom, action, cbData):
> +        """Dispatches events to python user domain event callbacks
> +        """
> +        try:
> +            cb = cbData["cb"]
> +            opaque = cbData["opaque"]
> +
> +            cb(self, virDomain(self, _obj=dom), action, opaque)
> +            return 0
> +        except AttributeError:
> +            pass
> +
> +    def dispatchDomainEventIOErrorCallback(self, dom, srcPath, devAlias, action, cbData):
> +        """Dispatches events to python user domain event callbacks
> +        """
> +        try:
> +            cb = cbData["cb"]
> +            opaque = cbData["opaque"]
> +
> +            cb(self, virDomain(self, _obj=dom), opaque)
> +            return 0
> +        except AttributeError:
> +            pass
> +
> +    def dispatchDomainEventGraphicsCallback(self, dom, phase, localAddr, remoteAddr, authScheme, subject, cbData):
> +        """Dispatches events to python user domain event callbacks
> +        """
> +        try:
> +            cb = cbData["cb"]
> +            opaque = cbData["opaque"]
> +
> +            cb(self, virDomain(self, _obj=dom), phase, localAddr, remoteAddr, authScheme, subject, opaque)
> +            return 0
> +        except AttributeError:
> +            pass
> +
>      def domainEventDeregisterAny(self, callbackID):
>          """Removes a Domain Event Callback. De-registering for a
>             domain callback will disable delivery of this event type """
> diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
> index 07d6a55..e3ce5ba 100644
> --- a/src/conf/domain_event.c
> +++ b/src/conf/domain_event.c
> @@ -660,7 +660,7 @@ virDomainEventPtr virDomainEventIOErrorNewFromObj(virDomainObjPtr obj,
>                                    obj->def->id, obj->def->name, obj->def->uuid);
>  
>      if (ev) {
> -        ev->data.watchdog.action = action;
> +        ev->data.ioError.action = action;
>          if (!(ev->data.ioError.srcPath = strdup(srcPath)) ||
>              !(ev->data.ioError.devAlias = strdup(devAlias))) {
>              virDomainEventFree(ev);
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 507e935..00bb275 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -536,7 +536,7 @@ static void qemuMonitorJSONHandleWatchdog(qemuMonitorPtr mon, virJSONValuePtr da
>      } else {
>              actionID = VIR_DOMAIN_EVENT_WATCHDOG_NONE;
>      }
> -    qemuMonitorEmitRTCChange(mon, actionID);
> +    qemuMonitorEmitWatchdog(mon, actionID);
>  }
>  
>  VIR_ENUM_DECL(qemuMonitorIOErrorAction)

  ACK, only suggestion would be to indicate the type of the event in the
description of the python dispatcher method, since there is one per
type, it shows in the name but for completeness description could carry
it too.

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list