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

Re: [Libvir] Asynchronous notifications of domain start/stop



On Wed, Jul 18, 2007 at 10:56:42AM +0100, Richard W.M. Jones wrote:
> I had some private discussions with a developer who wants to start using 
> libvirt, but requires asynch notifications of domain start/stop (and 
> other stuff, but this will do for the moment).  Right now he's using 
> XenStore watches.  The alternative of polling didn't look very appealing 
> for him.
> 
> A rough API for this might look like this:
> 
> typedef int virEventHandle;
> 
> /* Register a callback to catch domain start events. */
> virEventHandle virEventDomainStart
>     (virConnectPtr,
>      void (*f) (virConnectPtr, int domid));
> 
> /* Register a callback to catch domain stop events. */
> virEventHandle virEventDomainStop
>     (virConnectPtr,
>      void (*f) (virConnectPtr, int domid));
> 
> /* Unregister any type of callback. */
> int virEventCancel (virConnectPtr, virEventHandle handle);

Yuk - this is going to give an ever growing number of callbacks - there
are many interesting states besides Start & Start. Pause, resume, save,
restore.  Probably want something that takes

   void (*virDomainStateNotify)(virDomainPtr dom, int state);

The 'state' value could be any  virDomainState  constant - though we should
not notify for changes betweeen  'nostate', 'running' and 'blocked' because
they all effectively just mean 'running' and Xen domains ossicilate between
them many times a second. Or maybe define a different set of 'state' 
transitions to represent the actiohn triggered, rather than the resulting
state ?

Any you could register with:

   virDomainRegisterStateNotify(virDomainPtr, virDomainStateNotify);
   virDomainRegisterStateNotify(virDomainPtr);

A pre-requisite of using these notifications would be that the application
had registered an event loop implementation, as per

http://www.redhat.com/archives/libvir-list/2007-May/msg00083.html

See src/event.c and srv/event.h for actual impls we already have.

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 


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