Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1326653

Summary: Virsh blockjob reports unknown job when committing backing chain
Product: Red Hat Enterprise Linux 6 Reporter: Yang Yang <yanyang>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Han Han <hhan>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.8CC: dyuan, hhan, mzhan, rbalakri, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.10.2-61.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-21 10:39:03 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 Yang Yang 2016-04-13 09:51:00 UTC
Description of problem:
Virsh blockjob reports unknown job when committing backing chain 
# virsh blockjob vm2 hda
Unknown job: [ 15 %]
It should report like this
# virsh blockjob vm2 hda
Block Commit: [ 15 %]

Version-Release number of selected component (if applicable):
libvirt-0.10.2-60.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. create 3 external snapshots
# virsh snapshot-create-as vm2 s1 --no-metadata --disk-only --quiesce
Domain snapshot s1 created

# virsh console vm2
[root@localhost]# dd if=/dev/zero of=hello bs=1024 count=102400

# virsh snapshot-create-as vm2 s2 --no-metadata --disk-only --quiesce
Domain snapshot s2 created

# virsh console vm2
[root@localhost]# dd if=/dev/zero of=hello2 bs=1024 count=102400

# virsh snapshot-create-as vm2 s3 --no-metadata --disk-only --quiesce
Domain snapshot s3 created

# virsh console vm2
[root@localhost]# dd if=/dev/zero of=hello3 bs=1024 count=102400

# qemu-img info /var/lib/libvirt/images/vm2.s3  --backing-chain
image: /var/lib/libvirt/images/vm2.s3
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 20M
cluster_size: 65536
backing file: /var/lib/libvirt/images/vm2.s2
backing file format: qcow2

image: /var/lib/libvirt/images/vm2.s2
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 101M
cluster_size: 65536
backing file: /var/lib/libvirt/images/vm2.s1
backing file format: qcow2

image: /var/lib/libvirt/images/vm2.s1
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 103M
cluster_size: 65536
backing file: /var/lib/libvirt/images/vm2.img
backing file format: raw

image: /var/lib/libvirt/images/vm2.img
file format: raw
virtual size: 8.0G (8589934592 bytes)
disk size: 8.0G

2. committing into base image
# virsh blockcommit vm2 hda --top /var/lib/libvirt/images/vm2.s1
Block Commit started

3. query blockjob
# virsh blockjob vm2 hda
Unknown job: [ 15 %]

Actual result
Virsh blockjob reports unknown job when committing into base image

Expected result
Virsh blockjob reports like this
# virsh blockjob vm2 hda
Block Commit: [ 15 %]

Additional info:

Comment 2 Peter Krempa 2016-09-22 12:48:59 UTC
Upstream "accidentally" fixed this by commit:

commit 466b12ab797f3dc1b37005f5501ebec3549e5cad
Author: Eric Blake <eblake>
Date:   Fri Feb 21 12:55:06 2014 -0700

    virsh: use more compact VIR_ENUM_IMPL
    
    Dan Berrange suggested that using VIR_ENUM_IMPL is more compact
    than open-coding switch statements, and still just as forceful
    at making us remember to update lists if we add enum values
    in the future.  Make this change throughout virsh.
    
    Sure enough, doing this change caught that we missed at least
    VIR_STORAGE_VOL_NETDIR.
    
    * tools/virsh-domain-monitor.c (vshDomainIOErrorToString)
    (vshDomainControlStateToString, vshDomainStateToString)
    (vshDomainStateReasonToString): Change switch to enum lookup.
    (cmdDomControl, cmdDominfo): Update caller.
    * tools/virsh-domain.c (vshDomainVcpuStateToString)
    (vshDomainEventToString, vshDomainEventDetailToString): Change
    switch to enum lookup.
    (vshDomainBlockJobToString, vshDomainJobToString): New functions.
    (cmdVcpuinfo, cmdBlockJob, cmdDomjobinfo, cmdEvent): Update
    callers.
    * tools/virsh-network.c (vshNetworkEventToString): Change switch
    to enum lookup.
    * tools/virsh-pool.c (vshStoragePoolStateToString): New function.
    (cmdPoolList, cmdPoolInfo): Update callers.
    * tools/virsh-volume.c (vshVolumeTypeToString): Change switch to
    enum lookup.
    (cmdVolInfo, cmdVolList): Update callers.
    
    Signed-off-by: Eric Blake <eblake>

Comment 5 Han Han 2016-11-18 07:45:29 UTC
Verify it on libvirt-0.10.2-62.el6.x86_64
1. Prepare a running VM b1
2. Runing following script reproduce.sh
```
#!/bin/bash
DOM=b1
DOM_IP=192.168.122.86

for i in s{1..3};do
    virsh snapshot-create-as $DOM $i --no-metadata --disk-only
    ssh root@$DOM_IP dd if=/dev/urandom of=hello bs=1k count=102400
done
qemu-img info /var/lib/libvirt/images/$DOM.s3  --backing-chain
virsh blockcommit $DOM hda --top /var/lib/libvirt/images/$DOM.s1
for i in {1..10};do
    virsh blockjob $DOM hda
done 

```
3. Check the result
Domain snapshot s1 created
102400+0 records in
102400+0 records out
104857600 bytes (105 MB) copied, 19.0657 s, 5.5 MB/s
Domain snapshot s2 created
102400+0 records in
102400+0 records out
104857600 bytes (105 MB) copied, 18.5078 s, 5.7 MB/s
Domain snapshot s3 created
102400+0 records in
102400+0 records out
104857600 bytes (105 MB) copied, 18.7518 s, 5.6 MB/s
image: /var/lib/libvirt/images/b1.s3
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 98M
cluster_size: 65536
backing file: /var/lib/libvirt/images/b1.s2
backing file format: qcow2

image: /var/lib/libvirt/images/b1.s2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 101M
cluster_size: 65536
backing file: /var/lib/libvirt/images/b1.s1
backing file format: qcow2

image: /var/lib/libvirt/images/b1.s1
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 94M
cluster_size: 65536
backing file: /var/lib/libvirt/images/b1.qcow2
backing file format: qcow2

image: /var/lib/libvirt/images/b1.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 1.2G
cluster_size: 65536
Block Commit started
Block Commit: [ 44 %]
Block Commit: [ 48 %]
Block Commit: [ 48 %]
Block Commit: [ 49 %]
Block Commit: [ 49 %]
Block Commit: [ 49 %]
Block Commit: [ 49 %]
Block Commit: [ 49 %]
Block Commit: [ 49 %]
Block Commit: [ 49 %]


No 'unknown job' when blockcommit. Bug fixed.

Comment 7 errata-xmlrpc 2017-03-21 10:39:03 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/RHBA-2017-0682.html