events: Return the correct number of registered events

Commit d09f6ba5fe introduced a regression in event
registration.  virDomainEventCallbackListAddID() will only return a positive
integer if the type of event being registered is VIR_DOMAIN_EVENT_ID_LIFECYCLE.
For other event types, 0 is always returned on success.  This has the
unfortunate side effect of not enabling remote event callbacks because
remoteDomainEventRegisterAny() uses the return value from the local call to
determine if an event callback needs to be registered on the remote end.

Make sure virDomainEventCallbackListAddID() returns the callback count for the
eventID being registered.

Signed-off-by: Adam Litke <agl@us.ibm.com>
This commit is contained in:
Adam Litke 2012-01-13 14:44:42 -06:00 committed by Eric Blake
parent 0f88c7c16e
commit c972237ee1

View File

@ -397,7 +397,7 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
/* check if we already have this callback on our list */
for (i = 0 ; i < cbList->count ; i++) {
if (cbList->callbacks[i]->cb == VIR_DOMAIN_EVENT_CALLBACK(callback) &&
cbList->callbacks[i]->eventID == VIR_DOMAIN_EVENT_ID_LIFECYCLE &&
cbList->callbacks[i]->eventID == eventID &&
cbList->callbacks[i]->conn == conn) {
eventReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("event callback already tracked"));
@ -434,7 +434,7 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
event->callbackID = cbList->nextID++;
for (i = 0 ; i < cbList->count ; i++) {
if (cbList->callbacks[i]->eventID == VIR_DOMAIN_EVENT_ID_LIFECYCLE &&
if (cbList->callbacks[i]->eventID == eventID &&
cbList->callbacks[i]->conn == conn &&
!cbList->callbacks[i]->deleted)
ret++;