Bug 1274145

Summary: python event-test.py chokes on snapshot revert events
Product: [Community] Virtualization Tools Reporter: yafu <yafu>
Component: libvirt-pythonAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: crobinso, dyuan, fjin, jdenemar, mzhan, yafu, zpeng
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: LibvirtFirstBug
Fixed In Version: libvirt-python-4.9.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1648890 (view as bug list) Environment:
Last Closed: 2018-11-12 13:25: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:
Bug Depends On:    
Bug Blocks: 1648890    

Description yafu 2015-10-22 05:41:35 UTC
Description of problem:
it reports error info while executing 'virsh snapshot-revert' with the libvirt-python script and 'virsh event' reports domain state with unclear reason.

Version-Release number of selected component (if applicable):
  kernel-3.10.0-324.x86_64.rpm
  qemu-kvm-rhev-2.3.0-29.el7.x86_64
  libvirt-daemon-1.2.17-13.el7.x86_64
  

How reproducible:
100%

Steps to Reproduce:
1.Create a snapshot:
  #virsh snapshot-create-as vm s1
2.Open another two terminal,in terminal 1 running the following command
  #python /usr/share/doc/libvirt-python-1.1.1/events-python/event-test.py
3.In terminal 2 running the following command:
  #virsh event --all --loop
4.Revert snapshot:
  #virsh snapshot-revert vm s1
5.Check the guest's relate info in host
 <1>In terminal 1 ,it  reports the following error.
   Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 4686, in _dispatchDomainEventCallbacks
    cb(self, virDomain(self, _obj=dom), event, detail, opaque)
  File "/usr/share/doc/libvirt-python-1.2.17/examples/event-test.py", line 478, in myDomainEventCallback1
    domDetailToString(event, detail)))
  File "/usr/share/doc/libvirt-python-1.2.17/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 4697, in _dispatchDomainEventLifecycleCallback
    cb(self, virDomain(self, _obj=dom), event, detail, opaque)
  File "/usr/share/doc/libvirt-python-1.2.17/examples/event-test.py", line 483, in myDomainEventCallback2
    domDetailToString(event, detail)))
  File "/usr/share/doc/libvirt-python-1.2.17/examples/event-test.py", line 457, in domDetailToString
    return domEventStrings[event][detail]
 IndexError: tuple index out of range

  <2> In terminal 2, it reports "Resumed unknown":
   event 'lifecycle' for domain rhel7.1: Suspended Paused
   event 'lifecycle' for domain rhel7.1: Resumed Unpaused
   event 'lifecycle' for domain rhel7.1: *****Resumed unknown******

  <3> Can see the guest running status with the virsh domstate:
  #virsh  domstate vm --reason
     running (snapshot)

Actual results:
It reports error info while executing 'virsh snapshot-revert' with the libvirt-python script and 'virsh event' reports domain event with unclear reason.


Expected results:
shouldn't report the error in the libvirt-python script,and 'virsh event' should report the domain event with clear reason.

Comment 2 Pavel Hrdina 2016-02-18 20:51:53 UTC
This is a minor issue in the example script, moving to upstream.

Comment 3 Cole Robinson 2016-04-21 20:37:13 UTC
Tagging as LibvirtFirstBug, this will be something for the GSOC pile.

Easy to reproduce: sudo ./examples/event-test.py , then fire up virt-manager, start a VM, create a snapshot, then revert to it. Not only should event-test be extended to handle whatever event is firing that it doesn't know about, we should find a way to have it not choke on such issues in the future. So some solution that isn't blindly trying to access a list index that might not exist

Comment 4 Jiri Denemark 2018-11-12 13:25:08 UTC
This is fixed by

This should be already fixed upstream by

commit d5342a9803925ca728a33bfc5ffc6b2be0f356a6
Refs: v4.7.0-1-gd5342a9
Author:     Philipp Hahn <hahn>
AuthorDate: Thu Sep 20 08:10:43 2018 +0200
Commit:     Michal Privoznik <mprivozn>
CommitDate: Mon Sep 24 09:05:59 2018 +0200

    event-test.py: Sync list of domain lifecycle events

    Add new events to prevent crash:
    > Traceback (most recent call last):
    >   File "/usr/lib/python2.7/dist-packages/libvirt.py", line 4601, in _dispatchDomainEventCallbacks
    >     cb(self, virDomain(self, _obj=dom), event, detail, opaque)
    >   File "libvirt-python/examples/event-test.py", line 505, in myDomainEventCallback1
    >     domDetailToString(event, detail)))
    >   File "libvirt-python/examples/event-test.py", line 484, in domDetailToString
    >     return domEventStrings[event][detail]
    > IndexError: tuple index out of range

    Signed-off-by: Philipp Hahn <hahn>
    Signed-off-by: Michal Privoznik <mprivozn>