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

Daniel P. Berrange berrange at redhat.com
Fri Mar 19 17:11:13 UTC 2010

On Fri, Mar 19, 2010 at 11:06:40AM -0600, Eric Blake wrote:
> 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).

If these callbacks where synchronous with the operation causing them,
then I'd agree we need a return value. All the domain events though
are reporting something that has already happened, asychronously, so
there's nothing that a callback could stop/abort for this.

|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

More information about the libvir-list mailing list