[libvirt] [PATCH 00/12] Domain Events - Round 3

The following patch series implements the Events API discussed here previously in this thread: http://www.redhat.com/archives/libvir-list/2008-September/msg00321.html http://www.redhat.com/archives/libvir-list/2008-October/msg00245.html and https://www.redhat.com/archives/libvir-list/2008-October/msg00432.html Once again, I have broken these into the following patches: events-01-public-api Changes to libvirt.h, and libvirt.c events-02-internal-api Changes to internal.h and event code events-03-qemud Changes to the daemon events-04-qemud-rpc-protocol Changes to the qemud rpc protocol events-05-driver.patch Changes to the driver API events-06-driver-qemu Changes to the qemu driver events-07-driver-remote Changes to the remote driver events-08-driver-lxc Minor changes to LXC driver structure to prevent compile errors events-09-driver-openvz Minor changes to openvz driver structure to prevent compile errors events-10-driver-test Minor changes to test driver structure to prevent compile errors events-11-example-testapp Test app, and infrastructure changes for an example dir events-12-python-ignore.patch Add functions to be ignored, for now Differences from last submission - Formatting issues brought up by Daniel V Some protocol simplifications General fixes suggested from last time around. Removal of POLLxxx stuff (this caused a bit of churn) I think I got them all, but please let me know if I missed something. Again, domain events are only emitted from qemu/kvm guests. Ben Guthro

[PATCH 01/12] Domain Events - Public API This patch does the following: -implements the Event register/deregister code -Adds some callback lists, and queue functions used by drivers -Move EventImpl definitions into the public

On Tue, Oct 21, 2008 at 03:11:08PM -0400, Ben Guthro wrote:
[PATCH 01/12] Domain Events - Public API
This patch does the following: -implements the Event register/deregister code -Adds some callback lists, and queue functions used by drivers -Move EventImpl definitions into the public
thanks for the changes! I think the prototypes are good to go, maybe a couple tiny changes but I can make them myself based on the 'make rebuild' output in the doc directory functions in src/libvirt.c still need arguments checkings however, but I can add that later.
+/** + * virEventHandleCallback: callback for receiving file handle events
description just need to be moved after the parameters, can be trivially done later.
+ * @fd: file handle on which the event occurred + * @events: bitset of events from virEventHandleType constants + * @opaque: user data registered with handle + */ +typedef void (*virEventHandleCallback)(int fd, virEventHandleType events, + void *opaque); +/** + * virConnectDomainEventRegister: + * @conn: pointer to the connection + * @cb: callback to the function handling domain events + * @opaque: opaque data to pass on to the callback + * + * Adds a Domain Event Callback + * + * Returns 0 on success, -1 on failure + */ +int +virConnectDomainEventRegister(virConnectPtr conn, + virConnectDomainEventCallback cb, + void *opaque) +{
conn still need to be checked with the standard block if (!VIR_IS_CONNECT(conn)) { virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__); return (-1); } like every other public functions with a conn parameter in src/libvirt.c What if cb is NULL, that probably need to be rejected
+ /* Registering for a domain callback will enable delivery by default */ + if (conn->driver && conn->driver->domainEventRegister) + return conn->driver->domainEventRegister (conn, cb, opaque); + return -1; +} + +/** + * virConnectDomainEventDeregister: + * @conn: pointer to the connection + * @cb: callback to the function handling domain events + * + * Removes a Domain Event Callback + * + * Returns 0 on success, -1 on failure + */ +int +virConnectDomainEventDeregister(virConnectPtr conn, + virConnectDomainEventCallback cb) +{
same thing for VIR_IS_CONNECT and cb being NULL tests otherwise looks fine to me. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Daniel Veillard wrote on 10/22/2008 05:14 AM:
thanks for the changes! I think the prototypes are good to go, maybe a couple tiny changes but I can make them myself based on the 'make rebuild' output in the doc directory functions in src/libvirt.c still need arguments checkings however, but I can add that later.
Are these changes worth a 4th round of submissions - or is this something that can be taken care of in a follow-up patch?
+/** + * virEventHandleCallback: callback for receiving file handle events
description just need to be moved after the parameters, can be trivially done later.
+ * @fd: file handle on which the event occurred + * @events: bitset of events from virEventHandleType constants + * @opaque: user data registered with handle + */ +typedef void (*virEventHandleCallback)(int fd, virEventHandleType events, + void *opaque); +/** + * virConnectDomainEventRegister: + * @conn: pointer to the connection + * @cb: callback to the function handling domain events + * @opaque: opaque data to pass on to the callback + * + * Adds a Domain Event Callback + * + * Returns 0 on success, -1 on failure + */ +int +virConnectDomainEventRegister(virConnectPtr conn, + virConnectDomainEventCallback cb, + void *opaque) +{
conn still need to be checked with the standard block
if (!VIR_IS_CONNECT(conn)) { virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__); return (-1); }
like every other public functions with a conn parameter in src/libvirt.c What if cb is NULL, that probably need to be rejected
+ /* Registering for a domain callback will enable delivery by default */ + if (conn->driver && conn->driver->domainEventRegister) + return conn->driver->domainEventRegister (conn, cb, opaque); + return -1; +} + +/** + * virConnectDomainEventDeregister: + * @conn: pointer to the connection + * @cb: callback to the function handling domain events + * + * Removes a Domain Event Callback + * + * Returns 0 on success, -1 on failure + */ +int +virConnectDomainEventDeregister(virConnectPtr conn, + virConnectDomainEventCallback cb) +{
same thing for VIR_IS_CONNECT and cb being NULL tests
otherwise looks fine to me.
Daniel

On Wed, Oct 22, 2008 at 09:17:28AM -0400, Ben Guthro wrote:
Daniel Veillard wrote on 10/22/2008 05:14 AM:
thanks for the changes! I think the prototypes are good to go, maybe a couple tiny changes but I can make them myself based on the 'make rebuild' output in the doc directory functions in src/libvirt.c still need arguments checkings however, but I can add that later.
Are these changes worth a 4th round of submissions - or is this something that can be taken care of in a follow-up patch?
I'm fine with a followup patch, it's not like it's changing anything significant, I would actually do those once we decided to commit the whole pack. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Tue, Oct 21, 2008 at 03:11:08PM -0400, Ben Guthro wrote:
[PATCH 01/12] Domain Events - Public API
This patch does the following: -implements the Event register/deregister code -Adds some callback lists, and queue functions used by drivers -Move EventImpl definitions into the public
+ +/** + * virEventHandleType: + * + * a virEventHandleType is used similar to POLLxxx FD events, but is specific + * to libvirt. A client app must translate to, and from POLL events when using + * this construct. + */ +typedef enum { + VIR_EVENT_HANDLE_READABLE = (1 << 0), + VIR_EVENT_HANDLE_WRITABLE = (1 << 1), + VIR_EVENT_HANDLE_ERROR = (1 << 2), + VIR_EVENT_HANDLE_HANGUP = (1 << 3), +} virEventHandleType; + +/** + * virEventHandleCallback: callback for receiving file handle events + * + * @fd: file handle on which the event occurred + * @events: bitset of events from virEventHandleType constants + * @opaque: user data registered with handle + */ +typedef void (*virEventHandleCallback)(int fd, virEventHandleType events, + void *opaque);
We avoid using explicit enum types in any public API because they are not ABI safe in terms of their size. In any case, the 'events' parameter is atually a bit-mask of zero or more of the virEventHandleType constants, so the use of the enum isn't technically correct.
+ +/** + * virEventAddHandleFunc: + * @fd: file descriptor to listen on + * @event: events on which to fire the callback + * @cb: the callback to be called + * @opaque: user data to pass to the callback + * + * Part of the EventImpl, this callback Adds a file handle callback to + * listen for specific events + */ +typedef int (*virEventAddHandleFunc)(int fd, virEventHandleType event, + virEventHandleCallback cb, void *opaque);
Here too we should just use 'int events' as a bitmask
+ +/** + * virEventUpdateHandleFunc: + * @fd: file descriptor to modify + * @event: new events to listen on + * + * Part of the EventImpl, this user-provided callback is notified when + * events to listen on change + */ +typedef void (*virEventUpdateHandleFunc)(int fd, virEventHandleType event);
Same 'int events' here too.
+ + +int +__virEventHandleTypeToPollEvent(virEventHandleType events) +{ + int ret = 0; + if(events & VIR_EVENT_HANDLE_READABLE) + ret |= POLLIN; + if(events & VIR_EVENT_HANDLE_WRITABLE) + ret |= POLLOUT; + if(events & VIR_EVENT_HANDLE_ERROR) + ret |= POLLERR; + if(events & VIR_EVENT_HANDLE_HANGUP) + ret |= POLLHUP; + return ret; +} + +virEventHandleType +__virPollEventToEventHandleType(int events) +{ + virEventHandleType ret = 0; + if(events & POLLIN) + ret |= VIR_EVENT_HANDLE_READABLE; + if(events & POLLOUT) + ret |= VIR_EVENT_HANDLE_WRITABLE; + if(events & POLLERR) + ret |= VIR_EVENT_HANDLE_ERROR; + if(events & POLLHUP) + ret |= VIR_EVENT_HANDLE_HANGUP; + return ret; +}
Since these two functions are only used by the libvirtd daemon at this point, I think its better to just put them in qemud/event.c. This will avoid need to add conditionals here to disable their build on Mingw/Windows.
diff --git a/src/libvirt_sym.version b/src/libvirt_sym.version index 3cc4505..0297c9c 100644 --- a/src/libvirt_sym.version +++ b/src/libvirt_sym.version @@ -147,6 +147,10 @@ virStorageVolGetXMLDesc; virStorageVolGetPath;
+ virEventRegisterImpl; + virConnectDomainEventRegister; + virConnectDomainEventDeregister; + /* Symbols with __ are private only for use by the libvirtd daemon. They are not part of stable ABI @@ -167,8 +171,6 @@ __virGetStoragePool; __virGetStorageVol;
- __virEventRegisterImpl; - __virStateInitialize; __virStateCleanup; __virStateReload; @@ -198,5 +200,7 @@ __virReallocN; __virFree;
+ __virEventHandleTypeToPollEvent; + __virPollEventToEventHandleType;
These will also be unnecccessary if we put them in qemud/event.c Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 02/12] Domain Events - Internal API This patch -Removes EventImpl from being a private function -Introduces the virDomainEventCallbackListPtr, and virDomainEventQueuePtr objects

On Tue, Oct 21, 2008 at 03:11:36PM -0400, Ben Guthro wrote:
[PATCH 02/12] Domain Events - Internal API This patch -Removes EventImpl from being a private function -Introduces the virDomainEventCallbackListPtr, and virDomainEventQueuePtr objects
diff --git a/src/event.c b/src/event.c index 49a9e61..1e2b234 100644 --- a/src/event.c +++ b/src/event.c @@ -34,14 +34,15 @@ static virEventAddTimeoutFunc addTimeoutImpl = NULL; static virEventUpdateTimeoutFunc updateTimeoutImpl = NULL; static virEventRemoveTimeoutFunc removeTimeoutImpl = NULL;
-int virEventAddHandle(int fd, int events, virEventHandleCallback cb, void *opaque) { +int virEventAddHandle(int fd, virEventHandleType events, + virEventHandleCallback cb, void *opaque) { if (!addHandleImpl) return -1;
return addHandleImpl(fd, events, cb, opaque); }
-void virEventUpdateHandle(int fd, int events) { +void virEventUpdateHandle(int fd, virEventHandleType events) { updateHandleImpl(fd, events); }
This signature change isn't needed - it should still be just an int, since we're using the enum as a bitset. ACK, to the rest of the patch. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 03/12] Domain Events - daemon changes This code changes the daemaon to: use the pulic def of virEventRegisterImpl Add functionality to dispatch events to connected remote drivers event.c | 21 +++++---- event.h | 5 +- mdns.c | 15 ++++-- qemud.c | 72 ++++++++++++++++++++----------- qemud.h | 11 ++++ remote.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 227 insertions(+), 40 deletions(-)

On Tue, Oct 21, 2008 at 03:12:52PM -0400, Ben Guthro wrote:
[PATCH 03/12] Domain Events - daemon changes This code changes the daemaon to: use the pulic def of virEventRegisterImpl Add functionality to dispatch events to connected remote drivers
event.c | 21 +++++---- event.h | 5 +- mdns.c | 15 ++++-- qemud.c | 72 ++++++++++++++++++++----------- qemud.h | 11 ++++ remote.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 227 insertions(+), 40 deletions(-)
diff --git a/qemud/event.c b/qemud/event.c index bb1f381..f391cd1 100644 --- a/qemud/event.c +++ b/qemud/event.c @@ -38,7 +38,7 @@ /* State for a single file handle being monitored */ struct virEventHandle { int fd; - int events; + virEventHandleType events;
As per previous patch, simply using an 'int' is sufficient, likewise for the few other places in this patch doing the same. Aside from that, ACK to this patch. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 04/12] Domain Events - rpc changes Changes to the RPC protocol remote_dispatch_localvars.h | 3 +++ remote_dispatch_proc_switch.h | 18 ++++++++++++++++++ remote_dispatch_prototypes.h | 3 +++ remote_protocol.c | 29 +++++++++++++++++++++++++++++ remote_protocol.h | 25 +++++++++++++++++++++++++ remote_protocol.x | 25 ++++++++++++++++++++++++- 6 files changed, 102 insertions(+), 1 deletion(-)

On Tue, Oct 21, 2008 at 03:14:49PM -0400, Ben Guthro wrote:
[PATCH 04/12] Domain Events - rpc changes Changes to the RPC protocol
remote_dispatch_localvars.h | 3 +++ remote_dispatch_proc_switch.h | 18 ++++++++++++++++++ remote_dispatch_prototypes.h | 3 +++ remote_protocol.c | 29 +++++++++++++++++++++++++++++ remote_protocol.h | 25 +++++++++++++++++++++++++ remote_protocol.x | 25 ++++++++++++++++++++++++- 6 files changed, 102 insertions(+), 1 deletion(-)
diff --git a/qemud/remote_protocol.x b/qemud/remote_protocol.x index f1bd9ff..b7e41aa 100644 --- a/qemud/remote_protocol.x +++ b/qemud/remote_protocol.x @@ -965,6 +965,25 @@ struct remote_storage_vol_get_path_ret { remote_nonnull_string name; };
+/** + * Events Register/Deregister: + * It would seem rpcgen does not like both args, and ret + * to be null. It will not generate the prototype otherwise. + * Pass back a redundant boolean to force prototype generation. + */
Oh yes, I'd come across this problem in the past too. Adding the cb_registerd field is harmless enough, so lets do it.
+struct remote_domain_events_register_ret { + int cb_registered; +}; + +struct remote_domain_events_deregister_ret { + int cb_registered; +}; + +struct remote_domain_event_ret { + remote_nonnull_domain dom; + int event; +}; + /*----- Protocol. -----*/
/* Define the program number, protocol version and procedure numbers here. */ @@ -1086,7 +1105,11 @@ enum remote_procedure { REMOTE_PROC_NODE_GET_FREE_MEMORY = 102,
REMOTE_PROC_DOMAIN_BLOCK_PEEK = 103, - REMOTE_PROC_DOMAIN_MEMORY_PEEK = 104 + REMOTE_PROC_DOMAIN_MEMORY_PEEK = 104, + + REMOTE_PROC_DOMAIN_EVENTS_REGISTER = 105, + REMOTE_PROC_DOMAIN_EVENTS_DEREGISTER = 106, + REMOTE_PROC_DOMAIN_EVENT = 107 };
ACK to this patch. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 05/12] Domain Events - Driver API Additions to the driver API driver.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)

On Tue, Oct 21, 2008 at 03:15:19PM -0400, Ben Guthro wrote:
[PATCH 05/12] Domain Events - Driver API Additions to the driver API
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 06/12] Domain Events - qemu driver Register for, and dispatch domain event callbacks qemu_conf.h | 3 + qemu_driver.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 97 insertions(+), 7 deletions(-)

On Tue, Oct 21, 2008 at 03:15:47PM -0400, Ben Guthro wrote:
[PATCH 06/12] Domain Events - qemu driver Register for, and dispatch domain event callbacks
qemu_conf.h | 3 + qemu_driver.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 97 insertions(+), 7 deletions(-)
@@ -918,6 +938,11 @@ static int qemudStartVMDaemon(virConnectPtr conn, qemudShutdownVMDaemon(conn, driver, vm); return -1; } + dom = qemudDomainLookupByName(conn,vm->def->name); + if(dom) + qemudDomainEventDispatch(driver, vm, VIR_DOMAIN_EVENT_STARTED); + else + DEBUG0("Warning - dom is NULL at domain start");
The lookup & if(dom) bit is redundant - the only reasons qemudDomainLookupByName() would fail are either, that the named VM doesn't exist - we know it does, since we have its 'virDomainObjPtr' right here, or on out-of-memory. So we can just call qemudDomainEventDispatch() and avoid the check.
@@ -2210,6 +2240,11 @@ static int qemudDomainRestore(virConnectPtr conn, vm->state = VIR_DOMAIN_RUNNING; }
+ dom = virDomainLookupByID(conn, def->id); + if(dom) { + qemudDomainEventDispatch(driver, vm, VIR_DOMAIN_EVENT_RESTORED); + VIR_FREE(dom); + } return 0;
Likewise here, the virDomainLookupByID() is redundant, and we can just call qemudDomainEventDispatch(), which does a dom lookup anyway. ACK to the rest of the patch Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 07/12] Domain Events - remote driver Deliver local callbacks in response to remote events remote_internal.c | 276 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 271 insertions(+), 5 deletions(-)

On Tue, Oct 21, 2008 at 03:16:20PM -0400, Ben Guthro wrote:
[PATCH 07/12] Domain Events - remote driver Deliver local callbacks in response to remote events
remote_internal.c | 276 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 271 insertions(+), 5 deletions(-)
ACK to this. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 08/12] Domain Events - lxc driver Minor changes to LXC driver structure to prevent compile errors lxc_driver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)

On Tue, Oct 21, 2008 at 03:16:50PM -0400, Ben Guthro wrote:
[PATCH 08/12] Domain Events - lxc driver Minor changes to LXC driver structure to prevent compile errors
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 09/12] Domain Events - openvz driver Minor changes to openvz driver structure to prevent compile errors openvz_driver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/openvz_driver.c b/src/openvz_driver.c index b82d0df..2d0ddaa 100644 --- a/src/openvz_driver.c +++ b/src/openvz_driver.c @@ -1012,6 +1012,8 @@ static virDriver openvzDriver = { NULL, /* domainMemoryPeek */ NULL, /* nodeGetCellsFreeMemory */ NULL, /* nodeGetFreeMemory */ + NULL, /* domainEventRegister */ + NULL, /* domainEventDeregister */ }; int openvzRegister(void) {

On Tue, Oct 21, 2008 at 03:17:18PM -0400, Ben Guthro wrote:
[PATCH 09/12] Domain Events - openvz driver Minor changes to openvz driver structure to prevent compile errors
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 10/12] Domain Events - test driver Minor changes to test driver structure to prevent compile errors test.c | 2 ++ 1 file changed, 2 insertions(+)

On Tue, Oct 21, 2008 at 03:19:56PM -0400, Ben Guthro wrote:
[PATCH 10/12] Domain Events - test driver Minor changes to test driver structure to prevent compile errors
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 11/12] Domain Events - test harness Test app, and infrastructure changes for an example dir Makefile.am | 2 configure.in | 3 examples/domain-events/events-c/Makefile.am | 5 examples/domain-events/events-c/event-test.c | 261 +++++++++++++++++++++++++++ libvirt.spec.in | 3 5 files changed, 272 insertions(+), 2 deletions(-)

On Tue, Oct 21, 2008 at 03:20:19PM -0400, Ben Guthro wrote:
[PATCH 11/12] Domain Events - test harness Test app, and infrastructure changes for an example dir
ACK.
diff --git a/examples/domain-events/events-c/Makefile.am b/examples/domain-events/events-c/Makefile.am new file mode 100644 index 0000000..3c63ca3 --- /dev/null +++ b/examples/domain-events/events-c/Makefile.am @@ -0,0 +1,5 @@ +INCLUDES = -I@top_srcdir@/include +bin_PROGRAMS = event-test
Quick automake black-magic tip... Since we don't want the examples installed into /usr/bin, we can simply replace bin_PROGRAMS = event-test with noisnt_PROGRAMS = event-test
diff --git a/libvirt.spec.in b/libvirt.spec.in index cfd4a66..450d907 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -249,6 +249,9 @@ rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-python-%{version} rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu.conf %endif
+# We don't want examples in the built rpm +rm -f $RPM_BUILD_ROOT%{_bindir}/event-test
Use of 'noinst_PROGRAMS' will avoid the need for this Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

[PATCH 12/12] Domain Events - python Add functions to be ignored, to prevent rpm build failures generator.py | 3 +++ 1 file changed, 3 insertions(+)

[PATCH 01/12] Domain Events - Public API This patch does the following: -implements the Event register/deregister code -Adds some callback lists, and queue functions used by drivers -Move EventImpl definitions into the public

[PATCH 02/12] Domain Events - Internal API This patch -Removes EventImpl from being a private function -Introduces the virDomainEventCallbackListPtr, and virDomainEventQueuePtr objects

Apologies about the duplicate 00, 01, and 02 emails. My email seems to be acting up, and I didn't see those patches come through...so I resent those 3 Then they arrived in pairs. Please ignore the duplicates. Ben Guthro wrote on 10/21/2008 03:10 PM:
The following patch series implements the Events API discussed here previously in this thread: http://www.redhat.com/archives/libvir-list/2008-September/msg00321.html http://www.redhat.com/archives/libvir-list/2008-October/msg00245.html and https://www.redhat.com/archives/libvir-list/2008-October/msg00432.html
Once again, I have broken these into the following patches:
events-01-public-api Changes to libvirt.h, and libvirt.c events-02-internal-api Changes to internal.h and event code events-03-qemud Changes to the daemon events-04-qemud-rpc-protocol Changes to the qemud rpc protocol events-05-driver.patch Changes to the driver API events-06-driver-qemu Changes to the qemu driver events-07-driver-remote Changes to the remote driver events-08-driver-lxc Minor changes to LXC driver structure to prevent compile errors events-09-driver-openvz Minor changes to openvz driver structure to prevent compile errors events-10-driver-test Minor changes to test driver structure to prevent compile errors events-11-example-testapp Test app, and infrastructure changes for an example dir events-12-python-ignore.patch Add functions to be ignored, for now
Differences from last submission - Formatting issues brought up by Daniel V Some protocol simplifications General fixes suggested from last time around. Removal of POLLxxx stuff (this caused a bit of churn)
I think I got them all, but please let me know if I missed something.
Again, domain events are only emitted from qemu/kvm guests.
Ben Guthro
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Tue, Oct 21, 2008 at 03:40:45PM -0400, Ben Guthro wrote:
Apologies about the duplicate 00, 01, and 02 emails.
My email seems to be acting up, and I didn't see those patches come through...so I resent those 3 Then they arrived in pairs.
That's usually the fault of the mailman server running the redhat.com lists. There's quite alot of traffic on the redhat.com lists, so things can often get backed up in the delivery queue for a while. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Tue, Oct 21, 2008 at 03:10:15PM -0400, Ben Guthro wrote:
The following patch series implements the Events API discussed here previously in this thread:
Okay, I commited the set of patches to CVS, congratulations (also added you to the AUTHORS list as a result) ! I made the changes that Dan and I suggested before commiting. There is just a couple of things I did in addition, I may have been a bit over zealous in discarding virEventHandleType enums, I also replaced them by ints in internal APIs where not used as set. I think the only thing we loose is compiler checkings/warning in case of switch {} constructs, but I'm still worried about them as arguments even internally. Otherwise I also changed virStringListFree to __virStringListFree and virStringListJoin to __virStringListJoin to make clear they are not exported from libvirt.c, but that's not related to your patches. Again congratulations ! I think this also means the next release will be a 0.5.0 since this is a major API addition. I still looking at the other pending patches though, it would be better to have them in the next release ... oh and I want your java bindings and we need Python too (and QPid !) :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Again congratulations ! I think this also means the next release will be a 0.5.0 since this is a major API addition. I still looking at the other pending patches though, it would be better to have them in the next release ... oh and I want your java bindings and we need Python too (and QPid !) :-)
Great news! I'm just starting to look at the Python bindings...tryng to wrap my head around this whole process. Java will come after this, though I haven't even begun to look at it. As for Qpid... I suppose that will come after all the others. I've been mostly ignoring this, hoping I wouldn't have to know the gory details...but I guess that's unavoidable. Dave Lively's patches for HAL, and DevKit have some java bindings that are mostly done...I think submitting them are still on his TODO list. Are these the ones you are referring to? Thanks for accepting the patches! Ben

Also - Additional work is needed in the hypervisor drivers other than qemu to properly emit domain events. My initial patch submission included some code designed to add, and monitor xenstore watches. It would be nice to get this integrated, as well. Ben Guthro wrote on 10/23/2008 09:40 AM:
Again congratulations ! I think this also means the next release will be a 0.5.0 since this is a major API addition. I still looking at the other pending patches though, it would be better to have them in the next release ... oh and I want your java bindings and we need Python too (and QPid !) :-)
Great news! I'm just starting to look at the Python bindings...tryng to wrap my head around this whole process. Java will come after this, though I haven't even begun to look at it. As for Qpid... I suppose that will come after all the others. I've been mostly ignoring this, hoping I wouldn't have to know the gory details...but I guess that's unavoidable.
Dave Lively's patches for HAL, and DevKit have some java bindings that are mostly done...I think submitting them are still on his TODO list. Are these the ones you are referring to?
Thanks for accepting the patches!
Ben
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Thu, Oct 23, 2008 at 09:40:36AM -0400, Ben Guthro wrote:
Again congratulations ! I think this also means the next release will be a 0.5.0 since this is a major API addition. I still looking at the other pending patches though, it would be better to have them in the next release ... oh and I want your java bindings and we need Python too (and QPid !) :-)
Great news! I'm just starting to look at the Python bindings...tryng to wrap my head around this whole process. Java will come after this, though I haven't even begun to look at it. As for Qpid... I suppose that will come after all the others. I've been mostly ignoring this, hoping I wouldn't have to know the gory details...but I guess that's unavoidable.
Yep, the python stuff is seriously mind-bending with the mix of generated and hand-written code. To help you understand it: - libvir.c - hand written API wrappers - libvirt-py.c - auto-generated APi wrappers - libvir.py - hand written Python calling to C wrappers - libvirt.py - merged libvir.py with autogenerated code - generator.py - the code generator - docs/libvirt.xml - automatically extract API signatures - libvirt-python-api.xml - override incorrect API signatures The generator.py can cope with simple functions using API signature info from those two XML files. Sometimes it'll be able to get the python layer right, but not the C wrappers. For these, blacklist them in 'skip_impl' in generator.py. Sometimes it can't get either the C or python layer write - for those blacklist them in skip_function. I suspect you'll need the latter for the callback registering functions. I wouldn't worry too much about exposing the virEventRegisterImpl() function / callbacks in python. People using python are unlikely to be writing their own event loop impl in python - they'll just use glib/qt. The important bit to expose is the register/unregister of the domain event callbacks. Take a look at the way virRegisterErrorHandler() is handled in the python layer as a reasonable guide. As for Java, that's not time critical, since we release Java bindings separately from the main libvirt C/python code releases. Likewise the QPid stuff is separately released.
Dave Lively's patches for HAL, and DevKit have some java bindings that are mostly done...I think submitting them are still on his TODO list. Are these the ones you are referring to?
I'm still looking & experimenting with the device patches. I think we're getting close to a solution that can be committed, but I'll also need to submit my patches to split the driver out for the daemon to avoid the GPL/LGPL problem introduced by DBus before we can do a release with this merge. Good news is that those patches are almost ready too. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (3)
-
Ben Guthro
-
Daniel P. Berrange
-
Daniel Veillard