Bug 834927 - virConnectDomainEventRegisterAny won't register the same callback for the same event but for different domains
Summary: virConnectDomainEventRegisterAny won't register the same callback for the sam...
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 6.4
Assignee: Michal Privoznik
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-24 23:06 UTC by Daniel Vrátil
Modified: 2015-11-02 01:36 UTC (History)
12 users (show)

(edit)
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.
Clone Of:
(edit)
Last Closed: 2013-02-21 07:18:04 UTC


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


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:0276 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2013-02-20 21:18:26 UTC

Description Daniel Vrátil 2012-06-24 23:06:42 UTC
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 08:03:04 UTC
Created attachment 594710 [details]
reproducer

compile with: gcc repro.c -o repro -lvirt

Comment 2 Michal Privoznik 2012-06-27 08:05:43 UTC
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 12:13:06 UTC
Patch proposed upstream:

https://www.redhat.com/archives/libvir-list/2012-June/msg01230.html

Comment 4 Michal Privoznik 2012-06-27 14:35:16 UTC
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 08:36:48 UTC
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 07:18:04 UTC
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.