Bug 1519745
| Summary: | Wrongly recognize 'XXX[1]' as active layer when blockcommit | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Han Han <hhan> |
| Component: | libvirt | Assignee: | Peter Krempa <pkrempa> |
| Status: | CLOSED ERRATA | QA Contact: | Han Han <hhan> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 7.5 | CC: | chwen, dyuan, jiyan, lmen, lmiksik, meili, pkrempa, rbalakri, xuzhang, yisun |
| Target Milestone: | rc | Keywords: | Automation, Regression |
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | libvirt-3.9.0-6.el7 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2018-04-10 11:00:58 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
Han Han
2017-12-01 11:04:52 UTC
Not reproduced on libvirt-3.2.0-14.el7. Blocks libvirt automation testing cases. 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.
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.
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 |