Bug 834927 - virConnectDomainEventRegisterAny won't register the same callback for the same event but for different domains
virConnectDomainEventRegisterAny won't register the same callback for the sam...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.3
Unspecified Unspecified
unspecified Severity unspecified
: rc
: 6.4
Assigned To: Michal Privoznik
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-24 19:06 EDT by Daniel Vrátil
Modified: 2015-11-01 20:36 EST (History)
12 users (show)

See Also:
Fixed In Version: libvirt-0.9.13-3.el6
Doc Type: Bug Fix
Doc Text:
Cause: Reversed condition in check when registering a callback was preventing multiple callbacks to be registered. Consequence: Same callbacks for different domains couldn't be registered. Fix: The condition was fixed. Result: Callbacks can be registered now successfully.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-02-21 02:18:04 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
reproducer (7.42 KB, text/plain)
2012-06-27 04:03 EDT, Michal Privoznik
no flags Details

  None (edit)
Description Daniel Vrátil 2012-06-24 19:06:42 EDT
Description of problem:

virConnectDomainEventRegisterAny() will return "libvir: Remote error : adding cb to list
" when you attempt to register the same callback for already registered event but for a different domain.

Version-Release number of selected component (if applicable):
0.9.12

How reproducible:
always

Steps to Reproduce:
...
virDomainPtr dom1 = virDomainLookupByName(conn, "domain1");
virDomainPtr dom1 = virDomainLookupByName(conn, "domain2");

virConnectDomainEventRegisterAny(conn, dom1, VIR_DOMAIN_EVENT_ID_LIFECYCLE,
                              VIR_DOMAIN_EVENT_CALLBACK (myCallback), someDataPtr, NULL);
virConnectDomainEventRegisterAny(conn, dom2, VIR_DOMAIN_EVENT_ID_LIFECYCLE,
                              VIR_DOMAIN_EVENT_CALLBACK (myCallback), someOtherDataPtr, NULL);


Actual results:
First call works as expected, second throws error "libvir: Remote error : adding cb to list" and the callback is not registered for domain2.


Expected results:
Both calls should work and register the callback correctly.

Additional info:
Problem seems to be in virDomainEventCallbackListAddID() where the first for() cycle does not take domain into account. Therefor it works perfectly for domain being NULL, but not for specific domains.
Comment 1 Michal Privoznik 2012-06-27 04:03:04 EDT
Created attachment 594710 [details]
reproducer

compile with: gcc repro.c -o repro -lvirt
Comment 2 Michal Privoznik 2012-06-27 04:05:43 EDT
Even though this is reported against upstream, RHEL is affected as well. Therefore I am changing product and setting 6.4? flag.
Comment 3 Michal Privoznik 2012-06-27 08:13:06 EDT
Patch proposed upstream:

https://www.redhat.com/archives/libvir-list/2012-June/msg01230.html
Comment 4 Michal Privoznik 2012-06-27 10:35:16 EDT
Okay, moving to POST:

commit cd15303fd123146b0ba53e387d08ef22b707223c
Author:     Michal Privoznik <mprivozn@redhat.com>
AuthorDate: Wed Jun 27 12:06:45 2012 +0200
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Wed Jun 27 16:20:41 2012 +0200

    events: Don't fail on registering events for two different domains
    
    virConnectDomainEventRegisterAny() takes a domain as an argument.
    So it should be possible to register the same event (be it
    VIR_DOMAIN_EVENT_ID_LIFECYCLE for example) for two different domains.
    That is, we need to take domain into account when searching for
    duplicate event being already registered.


v0.9.13-rc1-18-gcd15303
Comment 7 yanbing du 2012-07-24 04:36:48 EDT
With libvirt-0.9.13-3.el6.x86_64, run the reproducer in comment 1, and this bug can be verified.
I try to start/suspend/resume/destroy/save/restore for both tow guest, and no such error throw out like the bug described. 
The outputs:
myDomainEventCallback2 EVENT: Domain rhel6(2) Started Booted
myDomainEventCallback2 EVENT: Domain rhel6-2(1) Suspended Paused
myDomainEventCallback2 EVENT: Domain rhel6(2) Suspended Paused
myDomainEventCallback2 EVENT: Domain rhel6(2) Resumed Unpaused
myDomainEventCallback2 EVENT: Domain rhel6-2(1) Resumed Unpaused
myDomainEventCallback2 EVENT: Domain rhel6(-1) Stopped Destroyed
myDomainEventCallback2 EVENT: Domain rhel6-2(-1) Stopped Destroyed
myDomainEventCallback2 EVENT: Domain rhel6(3) Started Booted
myDomainEventCallback2 EVENT: Domain rhel6-2(4) Started Booted
myDomainEventCallback2 EVENT: Domain rhel6-2(-1) Stopped Failed
myDomainEventCallback2 EVENT: Domain rhel6(-1) Stopped Failed
myDomainEventCallback2 EVENT: Domain rhel6(5) Started Restored
myDomainEventCallback2 EVENT: Domain rhel6-2(6) Started Restored
Comment 8 errata-xmlrpc 2013-02-21 02:18:04 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-0276.html

Note You need to log in before you can comment on or make changes to this bug.