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 1519745 - Wrongly recognize 'XXX[1]' as active layer when blockcommit
Summary: Wrongly recognize 'XXX[1]' as active layer when blockcommit
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Han Han
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-01 11:04 UTC by Han Han
Modified: 2018-04-10 11:01 UTC (History)
10 users (show)

Fixed In Version: libvirt-3.9.0-6.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 11:00:58 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2018:0704 0 None None None 2018-04-10 11:01:32 UTC

Description Han Han 2017-12-01 11:04:52 UTC
Description of problem:
As subject

Version-Release number of selected component (if applicable):
libvirt-3.9.0-3.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Create relative backing chain 
2. Create snapshot and reuse backing chain files as snapshot file
3. Start VM
4. Create a snapshot by absolute path
5. Do blockcommit with --pivot --active --shallow flag
6. Do blockcommit from index 1 with --shallow --keep-relative flag

You can execute following script to reproduce it:
```
BASE_IMG=/var/lib/libvirt/images/V.qcow2
VM=V
DISK=sda

cd $(dirname $BASE_IMG)
mkdir b c d -p
cd /var/lib/libvirt/images/b
qemu-img create -b ../$(basename $BASE_IMG) -o backing_fmt=qcow2 b -f qcow2
cd ../c
qemu-img create -b ../b/b -o backing_fmt=qcow2 c -f qcow2
#cd ../d
#qemu-img create -b ../c/c -o backing_fmt=qcow2 d -f qcow2
virsh start $VM && sleep 10
virsh snapshot-create-as $VM --reuse-external --no-metadata --disk-only --diskspec $DISK,file=$(dirname $BASE_IMG)/b/b
virsh snapshot-create-as $VM --reuse-external --no-metadata --disk-only --diskspec $DISK,file=$(dirname $BASE_IMG)/c/c
#virsh snapshot-create-as $VM --reuse-external --no-metadata --disk-only --diskspec $DISK,file=$(dirname $BASE_IMG)/d/d
virsh snapshot-create-as $VM --no-metadata --disk-only
virsh blockcommit $VM $DISK --active --pivot --shallow
virsh blockcommit V sda  --top 'sda[1]' --shallow --keep-relative

```

Actual results:
+ set -o nounset
+ BASE_IMG=/var/lib/libvirt/images/V.qcow2
+ VM=V
+ DISK=sda
++ dirname /var/lib/libvirt/images/V.qcow2
+ cd /var/lib/libvirt/images
+ mkdir b c d -p
+ cd /var/lib/libvirt/images/b
++ basename /var/lib/libvirt/images/V.qcow2
+ qemu-img create -b ../V.qcow2 -o backing_fmt=qcow2 b -f qcow2
Formatting 'b', fmt=qcow2 size=104857600 backing_file=../V.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
+ cd ../c
+ qemu-img create -b ../b/b -o backing_fmt=qcow2 c -f qcow2
Formatting 'c', fmt=qcow2 size=104857600 backing_file=../b/b backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
+ virsh start V
Domain V started

+ sleep 10
++ dirname /var/lib/libvirt/images/V.qcow2
+ virsh snapshot-create-as V --reuse-external --no-metadata --disk-only --diskspec sda,file=/var/lib/libvirt/images/b/b
Domain snapshot 1512125405 created
++ dirname /var/lib/libvirt/images/V.qcow2
+ virsh snapshot-create-as V --reuse-external --no-metadata --disk-only --diskspec sda,file=/var/lib/libvirt/images/c/c
Domain snapshot 1512125405 created
+ virsh snapshot-create-as V --no-metadata --disk-only
Domain snapshot 1512125405 created
+ virsh blockcommit V sda --active --pivot --shallow

Successfully pivoted
+ virsh blockcommit V sda --top 'sda[1]' --shallow --keep-relative
error: invalid argument: commit of 'sda' active layer requires active flag


Expected results:
blockcommit succeeds from 'sda[1]' with --shallow --keep-relative

Additional info:

Comment 2 Han Han 2017-12-01 11:08:55 UTC
Not reproduced on libvirt-3.2.0-14.el7. Blocks libvirt automation testing cases.

Comment 4 Peter Krempa 2017-12-08 09:27:01 UTC
Fixed upstream:

commit fac8724ceb371f962d5d185c639456a34d71659e 
Author: Peter Krempa <pkrempa>
Date:   Thu Dec 7 16:11:18 2017 +0100

    qemu: blockjob: Reset disk source index after pivot
    
    Since we are re-detecting the backing chain after pivoting to the active
    block commit target (or block copy target) the disk index needs to be
    reset to 0. This is necessary since we move a member of the backing
    chain to disk->src but clear indexes only starting from
    disk->src->backingStore. The freshly detected images have indexes
    starting from 1, but since we've pivoted into an image which was
    previously a backing store it would have a non-0 index.
    The lookup function would then return the top of the chain for queries
    like 'vda[1]' instead of the first backing store.

Comment 7 Han Han 2017-12-28 02:25:33 UTC
Verified on libvirt-3.9.0-6.el7.x86_64 qemu-kvm-rhev-2.10.0-13.el7.x86_64:
Steps:
1. Create relative backing chain 
2. Create snapshot and reuse backing chain files as snapshot file
3. Start VM
4. Create a snapshot by absolute path
5. Do blockcommit with --pivot --active --shallow flag
6. Do blockcommit from index 1 with --shallow --keep-relative flag
7. Do blockcommit from active layer with --pivot option

Run following script:
```
BASE_IMG=/var/lib/libvirt/images/V.qcow2
VM=V
DISK=vda

cd $(dirname $BASE_IMG)
mkdir b c d -p
cd /var/lib/libvirt/images/b
qemu-img create -b ../$(basename $BASE_IMG) -o backing_fmt=qcow2 b -f qcow2
cd ../c
qemu-img create -b ../b/b -o backing_fmt=qcow2 c -f qcow2
#cd ../d
#qemu-img create -b ../c/c -o backing_fmt=qcow2 d -f qcow2
virsh start $VM && sleep 10
virsh snapshot-create-as $VM --reuse-external --no-metadata --disk-only --diskspec $DISK,file=$(dirname $BASE_IMG)/b/b
virsh snapshot-create-as $VM --reuse-external --no-metadata --disk-only --diskspec $DISK,file=$(dirname $BASE_IMG)/c/c
#virsh snapshot-create-as $VM --reuse-external --no-metadata --disk-only --diskspec $DISK,file=$(dirname $BASE_IMG)/d/d
virsh snapshot-create-as $VM --no-metadata --disk-only
virsh blockcommit $VM $DISK --active --pivot --shallow --wait --verbose
virsh blockcommit V $DISK  --top "$DISK[1]" --shallow --keep-relative --wait --verbose
virsh dumpxml $VM|awk '/<disk/,/<\/disk/'
virsh blockcommit $VM $DISK --active --shallow --keep-relative --wait --verbose
virsh dumpxml $VM|awk '/<disk/,/<\/disk/'
virsh blockjob $VM $DISK --pivot
virsh dumpxml $VM|awk '/<disk/,/<\/disk/'
```

Result:
+ BASE_IMG=/var/lib/libvirt/images/V.qcow2
+ VM=V
+ DISK=vda
++ dirname /var/lib/libvirt/images/V.qcow2
+ cd /var/lib/libvirt/images
+ mkdir b c d -p
+ cd /var/lib/libvirt/images/b
++ basename /var/lib/libvirt/images/V.qcow2
+ qemu-img create -b ../V.qcow2 -o backing_fmt=qcow2 b -f qcow2
Formatting 'b', fmt=qcow2 size=10737418240 backing_file=../V.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
+ cd ../c
+ qemu-img create -b ../b/b -o backing_fmt=qcow2 c -f qcow2
Formatting 'c', fmt=qcow2 size=10737418240 backing_file=../b/b backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
+ virsh start V
Domain V started

+ sleep 10
++ dirname /var/lib/libvirt/images/V.qcow2
+ virsh snapshot-create-as V --reuse-external --no-metadata --disk-only --diskspec vda,file=/var/lib/libvirt/images/b/b
Domain snapshot 1514427184 created
++ dirname /var/lib/libvirt/images/V.qcow2
+ virsh snapshot-create-as V --reuse-external --no-metadata --disk-only --diskspec vda,file=/var/lib/libvirt/images/c/c
Domain snapshot 1514427184 created
+ virsh snapshot-create-as V --no-metadata --disk-only
Domain snapshot 1514427184 created
+ virsh blockcommit V vda --active --pivot --shallow --wait --verbose
Block commit: [100 %]
Successfully pivoted
+ virsh blockcommit V vda --top 'vda[1]' --shallow --keep-relative --wait --verbose
Block commit: [100 %]
Commit complete
+ virsh dumpxml V
+ awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/c/c'/>
      <backingStore type='file' index='1'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/c/../b/../V.qcow2'/>
        <backingStore/>
      </backingStore>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </disk>
+ virsh blockcommit V vda --active --shallow --keep-relative --wait --verbose
Block commit: [100 %]
Now in synchronized phase
+ virsh dumpxml V
+ awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/c/c'/>
      <backingStore type='file' index='1'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/c/../b/../V.qcow2'/>
        <backingStore/>
      </backingStore>
      <mirror type='file' job='active-commit' ready='yes'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/c/../b/../V.qcow2'/>
      </mirror>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </disk>
+ virsh blockjob V vda --pivot

+ virsh dumpxml V
+ awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/c/../b/../V.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </disk>

All blockcommit works as expected.

Comment 11 errata-xmlrpc 2018-04-10 11:00:58 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://access.redhat.com/errata/RHEA-2018:0704


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