[libvirt] [PATCH 01/13] Introduce a new public API for domain events

Eric Blake eblake at redhat.com
Fri Mar 19 17:06:40 UTC 2010


On 03/19/2010 09:38 AM, Daniel P. Berrange wrote:
> Since different event types can received different data in the callback,
> the API is defined with a generic callback. Specific events will each
> have a custom signature for their callback. Thus when registering an
> event it is neccessary to cast the callback to the generic signature
> 
>  
> +/* A generic callback definition. Specific events usually have a customization
> + * with extra parameters */
> +typedef void (*virConnectDomainEventGenericCallback)(virConnectPtr conn,
> +                                                     virDomainPtr dom,
> +                                                     void *opaque);

Should the callback be allowed to return anything, as void*?  For
example, I've seen some programming paradigms where you can write a
generic iterator that marches through callbacks for each item in a set,
allowing an early abort of the iteration if any of the callbacks return
a non-NULL value (useful for both finding the first element that matches
a given criteria, and for gracefully aborting operations on first failure).

> +
> +/**
> + * virConnectDomainEventRegister:
> + * @conn: pointer to the connection
> + * @dom: pointer to the domain
> + * @eventID: the event type to receive
> + * @cb: callback to the function handling domain events
> + * @opaque: opaque data to pass on to the callback
> + * @freecb: optional function to deallocate opaque when not used anymore
> + *
> + * Adds a callback to receive notifications of arbitrary domain events
> + * occurring on a domain.
> + *
> + * If dom is NULL, then events will be monitored for any domain. If dom
> + * is non-NULL, then only the specific domain will be monitored
> + *
> + * Most types of event have a callback providing a custom set of parameters
> + * for the event. When registering an event, it is thus neccessary to use

s/neccessary/necessary/

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 323 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100319/e7d82dc0/attachment-0001.sig>


More information about the libvir-list mailing list