On 12/13/2011 05:38 PM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)redhat.com>
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks
I think this needs to swap places with the previous patch, and pick up
the hunks that I questioned there.
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
The changes themselves make sense. I had a minor merge conflict with my
own resolution to the compile errors left over in 1/8 and this patch,
due to an indentation problem.
---
src/conf/domain_event.c | 23 ++++++++++++++++++-----
src/conf/domain_event.h | 3 ++-
src/libvirt_private.syms | 2 +-
src/libxl/libxl_driver.c | 15 ++++++++-------
src/lxc/lxc_driver.c | 15 ++++++++-------
src/qemu/qemu_driver.c | 15 ++++++++-------
src/remote/remote_driver.c | 33 ++++++++++++++++-----------------
src/test/test_driver.c | 15 ++++++++-------
src/uml/uml_driver.c | 15 ++++++++-------
src/vbox/vbox_tmpl.c | 15 ++++++++-------
src/xen/xen_driver.c | 13 +++++++------
11 files changed, 92 insertions(+), 72 deletions(-)
+++ b/src/libxl/libxl_driver.c
@@ -3851,10 +3851,11 @@ libxlDomainEventRegisterAny(virConnectPtr conn, virDomainPtr dom,
int eventID,
int ret;
libxlDriverLock(driver);
- ret = virDomainEventCallbackListAddID(conn,
- driver->domainEventState->callbacks,
- dom, eventID, callback, opaque,
- freecb);
+ if (virDomainEventCallbackListAddID(conn,
+ driver->domainEventState->callbacks,
+ dom, eventID, callback, opaque,
+ freecb, &ret) < 0)
+ ret = -1;
Should we make virDomainEventCallbackListAddID guarantee that the
callbackID argument, if non-NULL, is set to -1 on failure?
@@ -7312,7 +7313,7 @@ static int
vboxDomainEventDeregisterAny(virConnectPtr conn,
*/
vboxDriverLock(data);
- cnt = virDomainEventStateDeregisterAny(conn, data->domainEvents,
+ cnt = virDomainEventStateDeregisterID(conn, data->domainEvents,
callbackID);
Indentation.
ACK.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org