Bug 1463188 - event-test.py gets traceback when guest shutdown
event-test.py gets traceback when guest shutdown
Status: VERIFIED
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt-python (Show other bugs)
7.4
x86_64 Linux
unspecified Severity unspecified
: rc
: ---
Assigned To: Martin Kletzander
lcheng
: Upstream
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-20 07:06 EDT by yanqzhan@redhat.com
Modified: 2017-10-23 03:14 EDT (History)
9 users (show)

See Also:
Fixed In Version: libvirt-python-3.7.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
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)

  None (edit)
Description yanqzhan@redhat.com 2017-06-20 07:06:00 EDT
Description of problem:
libvirt(3.2.0-7) and qemu-kvm-rhev(2.9.0-9) make a change to distinguish whether the request is from host or guest when shutdown a guest, but "event-test.py" can not adapt to this now and gives traceback.

Version-Release number of selected component (if applicable):
*libvirt-python-3.2.0-3.el7.x86_64*
qemu-kvm-rhev-2.9.0-12.el7.x86_64
libvirt-3.2.0-10.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Shutdown a guest by "virsh shutdown"
# virsh event --loop --all
event 'lifecycle' for domain V: Shutdown Finished after guest request
event 'lifecycle' for domain V: Stopped Shutdown
# python `locate event-test.py`
Using uri:qemu:///system
myDomainEventAgentLifecycleCallback: Domain V(2) disconnected channel event
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 4645, in _dispatchDomainEventCallbacks
    cb(self, virDomain(self, _obj=dom), event, detail, opaque)
  File "/usr/share/doc/libvirt-python-3.2.0/examples/event-test.py", line 478, in myDomainEventCallback1
    domDetailToString(event, detail)))
  File "/usr/share/doc/libvirt-python-3.2.0/examples/event-test.py", line 457, in domDetailToString
    return domEventStrings[event][detail]
IndexError: tuple index out of range
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 4656, in _dispatchDomainEventLifecycleCallback
    cb(self, virDomain(self, _obj=dom), event, detail, opaque)
  File "/usr/share/doc/libvirt-python-3.2.0/examples/event-test.py", line 483, in myDomainEventCallback2
    domDetailToString(event, detail)))
  File "/usr/share/doc/libvirt-python-3.2.0/examples/event-test.py", line 457, in domDetailToString
    return domEventStrings[event][detail]
IndexError: tuple index out of range
myDomainEventCallback1 EVENT: Domain V(2) Stopped Shutdown
myDomainEventCallback2 EVENT: Domain V(2) Stopped Shutdown

2.Shutdown a guest by "kill -15 $pidof_qemu"
# virsh event --loop --all
event 'lifecycle' for domain V: Shutdown Finished after host request
event 'lifecycle' for domain V: Stopped Shutdown
# python `locate event-test.py`
Using uri:qemu:///system
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 4645, in _dispatchDomainEventCallbacks
    cb(self, virDomain(self, _obj=dom), event, detail, opaque)
  File "/usr/share/doc/libvirt-python-3.2.0/examples/event-test.py", line 478, in myDomainEventCallback1
    domDetailToString(event, detail)))
  File "/usr/share/doc/libvirt-python-3.2.0/examples/event-test.py", line 457, in domDetailToString
    return domEventStrings[event][detail]
IndexError: tuple index out of range
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 4656, in _dispatchDomainEventLifecycleCallback
    cb(self, virDomain(self, _obj=dom), event, detail, opaque)
  File "/usr/share/doc/libvirt-python-3.2.0/examples/event-test.py", line 483, in myDomainEventCallback2
    domDetailToString(event, detail)))
  File "/usr/share/doc/libvirt-python-3.2.0/examples/event-test.py", line 457, in domDetailToString
    return domEventStrings[event][detail]
IndexError: tuple index out of range
myDomainEventCallback1 EVENT: Domain V(3) Stopped Shutdown
myDomainEventCallback2 EVENT: Domain V(3) Stopped Shutdown


Actual results:
when working with qemu-kvm-rhev(>=2.9.0-9), event-test.py gets traceback when guest shutdown

Expected results:
event-test.py should be able to report the guest shutdown event and its reason(from host or guest) without error, just as libvirt "virsh event" does.

Additional info:
Comment 2 Martin Kletzander 2017-06-20 10:33:48 EDT
Fixed upstream with v3.4.0-1-g36430e115df2:
commit 36430e115df2b3d70936c4196b61e9b7824d09a3
Author: Martin Kletzander <mkletzan@redhat.com>
Date:   2017-06-20 13:33:52 +0200

    Add details for shutdown event
Comment 4 lcheng 2017-10-23 03:14:37 EDT
I can reproduce this bug on libvirt-python-3.2.0-3.el7.x86_64 and verify on libvirt-python-3.8.0-1.el7.x86_64.

1. Shutdown a guest by 'virsh shutdown'.
On console 1, shutdown a guest.
# virsh shutdown virtlab_test
Domain virtlab_test is being shutdown

On console 2, run 'virsh event'.
# virsh event --loop --all
event 'agent-lifecycle' for domain virtlab_test: state: 'disconnected' reason: 'channel event'
event 'lifecycle' for domain virtlab_test: Shutdown Finished after guest request
event 'lifecycle' for domain virtlab_test: Stopped Shutdown

On console 3, run 'python event-test.py'.
# python /usr/share/doc/libvirt-python-3.8.0/examples/event-test.py
Using uri 'qemu:///system' and event loop 'poll'
myDomainEventAgentLifecycleCallback: Domain virtlab_test(1) disconnected channel event
myDomainEventCallback1 EVENT: Domain virtlab_test(1) Shutdown On guest request
myDomainEventCallback2 EVENT: Domain virtlab_test(1) Shutdown On guest request
myNodeDeviceEventLifecycleCallback: Node device  net_vnet0_fe_52_00_45_c3_8a Deleted 0
myDomainEventCallback1 EVENT: Domain virtlab_test(1) Stopped Shutdown
myDomainEventCallback2 EVENT: Domain virtlab_test(1) Stopped Shutdown


2. Shutdown a guest by 'kill $PID'.
On console 1, shutdown a guest.
# kill 31883

On console 2, run 'virsh event'.
# virsh event --loop --all
event 'lifecycle' for domain virtlab_test: Shutdown Finished after host request
event 'lifecycle' for domain virtlab_test: Stopped Shutdown

On console 3, run 'python event-test.py'.
# python /usr/share/doc/libvirt-python-3.8.0/examples/event-test.py
Using uri 'qemu:///system' and event loop 'poll'
myDomainEventAgentLifecycleCallback: Domain virtlab_test(4) connected channel event
myDomainEventCallback1 EVENT: Domain virtlab_test(4) Shutdown On host request
myDomainEventCallback2 EVENT: Domain virtlab_test(4) Shutdown On host request
myNodeDeviceEventLifecycleCallback: Node device  net_vnet0_fe_52_00_45_c3_8a Deleted 0
myDomainEventCallback1 EVENT: Domain virtlab_test(4) Stopped Shutdown
myDomainEventCallback2 EVENT: Domain virtlab_test(4) Stopped Shutdown


So move to VERIFIED.

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