Bug 845958

Summary: libvirt domain event handler can not catch domain pmsuspend and get error when pmwakeup
Product: Red Hat Enterprise Linux 6 Reporter: Huang Wenlong <whuang>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.4CC: acathrow, cwei, dallan, dyasny, dyuan, mzhan, rwu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.10.2-0rc1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 07:21:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Huang Wenlong 2012-08-06 09:44:18 UTC
Description of problem:
libvirt domain event handler can not catch domain pmsuspend and get error when pmwakeup

Version-Release number of selected component (if applicable):
libvirt-0.10.0-0rc0.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.298.el6_3.x86_64


How reproducible:
100%

Steps to Reproduce:
First need add <loader>/usr/share/seabios/bios-pm.bin</loader> in the domain xml then restart domain 

1.# python /usr/share/doc/libvirt-python-*/events-python/event-test.py
Using uri:qemu:///system


2.   in the domain run
#pm-suspend

3. in the host

# virsh list
 Id    Name                           State
----------------------------------------------------
 3     ga                             pmsuspended

4. move mouse will wakeup  domain or virsh pmwakeup domain

virsh # dompmwakeup ga
Domain ga successfully woken up


3.  event-test.py will get error  but wakeup success

Traceback (most recent call last):
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 3425, in _dispatchDomainEventCallbacks
    cb(self,dom,event,detail,opaque)
  File "/usr/share/doc/libvirt-python-0.10.0/events-python/event-test.py", line 457, in myDomainEventCallback1
    detailToString(event, detail))
  File "/usr/share/doc/libvirt-python-0.10.0/events-python/event-test.py", line 452, in detailToString
    return eventStrings[event][detail]
IndexError: tuple index out of range
Traceback (most recent call last):
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 3436, in _dispatchDomainEventLifecycleCallback
    cb(self, virDomain(self, _obj=dom), event, detail, opaque)
  File "/usr/share/doc/libvirt-python-0.10.0/events-python/event-test.py", line 462, in myDomainEventCallback2
    detailToString(event, detail))
  File "/usr/share/doc/libvirt-python-0.10.0/events-python/event-test.py", line 452, in detailToString
    return eventStrings[event][detail]
IndexError: tuple index out of range
myDomainEventRebootCallback: Domain ga(3)





Actual results:
can not catch suspend event and wake up pop up error  in  event handler

Expected results:
catch suspend event no error report when wakeup domain

Additional info:
no error in libvirtd.log

Comment 2 Jiri Denemark 2012-08-08 14:19:53 UTC
This is trivial, the event-test.py is just needs updating to cover all possible event details.

Comment 3 Jiri Denemark 2012-08-08 14:21:26 UTC
Patch sent upstream: https://www.redhat.com/archives/libvir-list/2012-August/msg00517.html

Comment 4 Jiri Denemark 2012-08-09 14:02:39 UTC
Fixed upstream by v0.10.0-rc0-63-g462c211:

commit 462c211232b85c52897819a4c91beb0c95d21bc7
Author: Jiri Denemark <jdenemar>
Date:   Wed Aug 8 16:17:31 2012 +0200

    examples: Update strings for event details

Comment 6 Huang Wenlong 2012-08-23 07:15:35 UTC
Hi, Jiri 

I test it with 
libvirt-0.10.0-0rc1.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.303.el6.x86_64


domain handler can catch the pmwakeup event , but it can not catch the pmsuspend event still in this version ,so I assign this bug.


1) check virsh list  after run pm-suspend  in the domain
# virsh list 
 Id    Name                           State
----------------------------------------------------
 7     f17                            pmsuspended


#python /usr/share/doc/libvirt-python-*/events-python/event-test.py
Using uri:qemu:///system

myDomainEventCallback1 EVENT: Domain f17(7) Started Wakeup
myDomainEventCallback2 EVENT: Domain f17(7) Started Wakeup
myDomainEventRebootCallback: Domain f17(7)

Comment 7 Jiri Denemark 2012-08-23 13:58:45 UTC
Ah, great, the pmsuspended state was added without an equivalent lifecycle event.

Comment 8 Jiri Denemark 2012-09-07 08:32:38 UTC
So there were more issue than what I have hoped for. They should all be fixed upstream by v0.10.1-57-gafab482, v0.10.1-58-gfc4115e, and v0.10.1-59-ge2a7f97:

commit afab4824ebe8b5a03dcdd3aa6b70359224219cd2
Author: Jiri Denemark <jdenemar>
Date:   Thu Sep 6 16:56:08 2012 +0200

    Fix PMSuspend and PMWakeup events
    
    The unused reason parameter of PM{Suspend,Wakeup} event callbacks was
    completely ignored in lot of places and those events were not actually
    working at all.

commit fc4115e8d693635d5569e01b432a9cde03341f0c
Author: Jiri Denemark <jdenemar>
Date:   Thu Sep 6 17:00:43 2012 +0200

    Add PMSUSPENDED life cycle event
    
    While PMSUSPENDED state was added a long time ago, we didn't have
    corresponding life cycle event.

commit e2a7f97b2b1cee9d0dd628ac03a30a33041a98bb
Author: Jiri Denemark <jdenemar>
Date:   Thu Sep 6 17:02:47 2012 +0200

    examples: Fix event detail printing in python test
    
    If there is only one detail string for a particular event, we need to pu
    comma after the string otherwise the string itself will be taken as a
    list and only its first character will be printed out. For example,
    
        myDomainEventCallback1 EVENT: Domain fedora17(12) Shutdown F
    
    instead of the desired
    
        myDomainEventCallback1 EVENT: Domain fedora17(12) Shutdown Finished

Comment 9 Huang Wenlong 2012-09-19 09:00:07 UTC
Verify this bug with : 
libvirt-0.10.2-0rc1.el6.x86_64


virsh # list
 Id    Name                           State
----------------------------------------------------
 3     q64                            running

virsh # dompmsuspend q64 mem
Domain q64 successfully suspended
virsh # list
 Id    Name                           State
----------------------------------------------------
 3     q64                            pmsuspended

virsh # dompmwakeup q64
Domain q64 successfully woken up
virsh # list
 Id    Name                           State
----------------------------------------------------
 3     q64                            running

# python /usr/share/doc/libvirt-python-0.10.2/events-python/event-test.py
Using uri:qemu:///system

myDomainEventPMSuspendCallback: Domain q64(3) system pmsuspend
myDomainEventCallback1 EVENT: Domain q64(3) PMSuspended Memory
myDomainEventCallback2 EVENT: Domain q64(3) PMSuspended Memory
myDomainEventPMWakeupCallback: Domain q64(3) system pmwakeup
myDomainEventCallback1 EVENT: Domain q64(3) Started Wakeup
myDomainEventCallback2 EVENT: Domain q64(3) Started Wakeup

Comment 10 Huang Wenlong 2012-09-19 09:11:33 UTC
Hi,Jiri 

I found libvirt event handler can not differentiate "shutdown guest" and "dompmsuspend disk" and  "start guest" and "pmwakeup guest" , their events is the same


myDomainEventCallback1 EVENT: Domain q64(3) Shutdown Finished
myDomainEventCallback2 EVENT: Domain q64(3) Shutdown Finished
myDomainEventCallback1 EVENT: Domain q64(3) Stopped Shutdown
myDomainEventCallback2 EVENT: Domain q64(3) Stopped Shutdown
myDomainEventCallback1 EVENT: Domain q64(4) Started Booted
myDomainEventCallback2 EVENT: Domain q64(4) Started Booted
myDomainEventGraphicsCallback: Domain q64(4) 0 none
myDomainEventGraphicsCallback: Domain q64(4) 1 none

Is there a bug to trace this issue ?

Comment 11 Jiri Denemark 2012-09-19 09:51:19 UTC
Yes, that's a separate issue tracked by bug 839661.

Comment 12 Huang Wenlong 2012-09-19 10:12:22 UTC
(In reply to comment #11)
> Yes, that's a separate issue tracked by bug 839661.

Thanks very much .

Comment 13 errata-xmlrpc 2013-02-21 07:21:08 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