RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1341415 - 'virsh event' can not capture disk-change events
Summary: 'virsh event' can not capture disk-change events
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.3
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-01 03:11 UTC by Yanqiu Zhang
Modified: 2016-11-03 18:46 UTC (History)
8 users (show)

Fixed In Version: libvirt-2.0.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 18:46:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2577 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2016-11-03 12:07:06 UTC

Description Yanqiu Zhang 2016-06-01 03:11:20 UTC
Description of problem:
'virsh event' can not capture disk-change events

Version-Release number of selected component (if applicable):
libvirt-1.3.4-1.el7.x86_64
qemu-kvm-rhev-2.6.0-4.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Edit the guest  xml with optional startupPolicy,(rhel7.1.qcow2-non is a non-exist disk).
   ...
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/rhel7.1.qcow2-non' startupPolicy='optional'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
.....
2.Open the second terminal, run the 'event-test.py' python script to catch the event
# python /usr/share/doc/libvirt-python-1.3.4/examples/event-test.py qemu:///system
Using uri:qemu:///system    
3.Open third terminal, run the 'virsh event' command to catch the events
#virsh event --all --loop     
4.Start the guest :
#virsh start testvm
5. Check log about disk-change in the libvirtd.log:
#cat /var/log/libvirt/libvirtd.log | grep -i change
2016-05-31 09:41:32.247+0000: 513: debug : udevEventHandleCallback:1548 : udev action: 'change'
2016-05-31 09:41:36.691+0000: 518: info : virObjectNew:202 : OBJECT_NEW: obj=0x7fdc30001010 classname=virDomainEventDiskChange
2016-05-31 09:41:36.691+0000: 518: debug : virDomainEventDiskChangeDispose:474 : obj=0x7fdc30001010
2016-05-31 09:41:36.970+0000: 513: debug : udevEventHandleCallback:1548 : udev action: 'change'

Actual results:
No disk-change events show in the 2nd terminal & 3rd terminal.

Expected results:
'virsh event' should be able to capture disk-change events:
(2nd terminal) # python /usr/share/doc/libvirt-python-1.2.15/examples/event-test.py qemu:///system
Using uri:qemu:///system
myDomainEventDiskChangeCallback: Domain testvm(4) disk change oldSrcPath: /var/lib/libvirt/images/rhel7.1.qcow2-non newSrcPath: None devAlias: virtio-disk0 reason: 1
(3rd terminal):# virsh events --all --loop
event 'disk-change' for domain testvm disk virtio-disk0: /var/lib/libvirt/images/rhel7.1.qcow2-non -> <null>: dropped

Additional info:
1.It works well with libvirt-1.2.17-13.el7.x86_64.

Comment 2 Peter Krempa 2016-06-08 06:23:39 UTC
Fixed upstream:

commit 9cda91d6f6b887c6f06868f4d2fb16c288ae20d5
Author: Peter Krempa <pkrempa>
Date:   Thu Jun 2 15:32:00 2016 +0200

    qemu: process: Call disk startup policy check after cloning domain def
    
    In commit 1e38ef72 the disk startup policy check was moved prior to the
    call to virDomainObjSetDefTransient which dropped the disk from the
    config rather than the def to be started which is a bug.
    
    Additionally we'd not report the disk change event for this since the
    disk aliases were not set at that point.
    
    Finally 'volume' based disks would not work with startup policy too.
    
    Fix it by moving it back after the definition is copied, aliases are
    assigned and disk sources are translated.

Comment 4 yafu 2016-07-06 06:08:30 UTC
Reproduced with libvirt-1.3.4-1.el7.x86_64.
steps are as comment 0.

Verify pass with libvirt-2.0.0-1.el7.x86_64.

Test steps:
1.Edit the guest xml with optional startupPolicy,(no-disk.qcow2 is a non-exist disk).
   ...
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/no-disk.qcow2' startupPolicy='optional'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
.....


2.Open the second terminal, run the 'event-test.py' python script to catch the events
# python /usr/share/doc/libvirt-python-2.0.0/examples/event-test.py qemu:///system
Using uri:qemu:///system  
 
3.Open third terminal, run the 'virsh event' command to catch the events
#virsh event --all --loop 
    
4.Start the guest :
#virsh start rhel7.3

5.Check the output in the second terminal, can see the disk-chanage event:
 myDomainEventDiskChangeCallback: Domain rhel7.3(123) disk change oldSrcPath: /var/lib/libvirt/images/no-disk.qcow2 newSrcPath: None devAlias: virtio-disk1 reason: 1

6.Check the output in the third terminal,also can see the disk-change event:
event 'disk-change' for domain rhel7.3 disk virtio-disk1: /var/lib/libvirt/images/no-disk.qcow2 -> <null>: dropped

7.Also test cdrom/floppy with 'file' type, also can see the disk-change event.

Comment 6 errata-xmlrpc 2016-11-03 18:46:09 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.

https://rhn.redhat.com/errata/RHSA-2016-2577.html


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