Bug 1523261
| Summary: | block commit with --keep-relative does not work after libvirtd restart | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Peter Krempa <pkrempa> |
| Component: | libvirt | Assignee: | Peter Krempa <pkrempa> |
| Status: | CLOSED ERRATA | QA Contact: | Han Han <hhan> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 7.4 | CC: | dyuan, lmen, lmiksik, meili, rbalakri, salmy, xuzhang |
| Target Milestone: | rc | Keywords: | Regression |
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | libvirt-3.9.0-7.el7 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2018-04-10 11:02: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: | |||
|
Description
Peter Krempa
2017-12-07 14:36:14 UTC
Reproduced on qemu-kvm-rhev-2.10.0-11.el7.x86_64 libvirt-3.9.0-5.el7.x86_64:
Run script:
```
+ set -o nounset
+ VM=q35
+ DISK=vdb
+ cd /var/lib/libvirt/images
+ mkdir b c d -p
+ cd /var/lib/libvirt/images/b
+ qemu-img create /var/lib/libvirt/images/b 100M -f qcow2
Formatting '/var/lib/libvirt/images/b', fmt=qcow2 size=104857600 cluster_size=65536 lazy_refcounts=off refcount_bits=16
qemu-img: /var/lib/libvirt/images/b: Could not create file: Is a directory
+ 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
+ cd ../d
+ qemu-img create -b ../c/c -o backing_fmt=qcow2 d -f qcow2
Formatting 'd', fmt=qcow2 size=104857600 backing_file=../c/c backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
+ virsh start q35
Domain q35 started
+ sleep 10
+ virsh attach-disk q35 /var/lib/libvirt/images/d/d vdb --subdriver qcow2
Disk attached successfully
+ systemctl restart libvirtd
+ virsh blockcommit q35 vdb --top 'vdb[1]' --shallow --keep-relative
error: Requested operation is not valid: can't keep relative backing relationship
➜ ~ virsh destroy q35
vDomain q35 destroyed
➜ ~ vim /tmp/reproduce.sh
➜ ~ /tmp/reproduce.sh
+ set -o nounset
+ VM=q35
+ DISK=vdb
+ cd /var/lib/libvirt/images
+ mkdir b c d -p
+ cd /var/lib/libvirt/images/b
+ qemu-img create /var/lib/libvirt/images/b 100M -f qcow2
Formatting '/var/lib/libvirt/images/b', fmt=qcow2 size=104857600 cluster_size=65536 lazy_refcounts=off refcount_bits=16
qemu-img: /var/lib/libvirt/images/b: Could not create file: Is a directory
+ 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
+ cd ../d
+ qemu-img create -b ../c/c -o backing_fmt=qcow2 d -f qcow2
Formatting 'd', fmt=qcow2 size=104857600 backing_file=../c/c backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
+ virsh start q35
Domain q35 started
+ sleep 10
+ virsh attach-disk q35 /var/lib/libvirt/images/d/d vdb --subdriver qcow2
Disk attached successfully
+ systemctl restart libvirtd
+ virsh blockcommit q35 vdb --top 'vdb[1]' --shallow --keep-relative
error: Requested operation is not valid: can't keep relative backing relationship
+ virsh dumpxml q35
+ awk '/<disk/,/<\/disk/'
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/q35.qcow2'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/d/d'/>
<backingStore type='file' index='1'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/d/../c/c'/>
<backingStore type='file' index='2'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/d/../c/../b/b'/>
<backingStore type='file' index='3'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/d/../c/../b/../V.qcow2'/>
<backingStore/>
</backingStore>
</backingStore>
</backingStore>
<target dev='vdb' bus='virtio'/>
<alias name='virtio-disk1'/>
<address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
</disk>
```
As the result 'error: Requested operation is not valid: can't keep relative backing relationship'
Fixed upstream by:
commit b3d0270c44b85944f91906225b27bca6700a6333
Author: Peter Krempa <pkrempa>
Date: Wed Dec 13 17:06:00 2017 +0100
qemu: domain: Parse and format relPath into disk source private data
Register the helpers directly to format and parse the data.
https://bugzilla.redhat.com/show_bug.cgi?id=1523261
commit cd31709351142a2770d2b9baa7755eaed672710a
Author: Peter Krempa <pkrempa>
Date: Wed Dec 13 17:04:54 2017 +0100
util: storage: Add helpers to parse and format relPath into privateData
This will be the first private piece of data that will need to be stored
in the XML for some drivers. Add helpers which will do it.
commit aed3d038a6565f3b0e916bdb004ca90b302b200d
Author: Peter Krempa <pkrempa>
Date: Tue Dec 12 17:55:03 2017 +0100
conf: Add infrastructure for disk source private data XML
VM drivers may need to store additional private data to the status XML
so that it can be restored after libvirtd restart. Since not everything
is needed add a callback infrastructure, where VM drivers can add only
stuff they need.
Note that the private data is formatted as a <privateData> sub-element
of the <disk> or <backingStore> <source> sub-element. This is done since
storing it out of band (in the VM private data) would require a complex
matching process to allow to put the data into correct place.
Verified in libvirt-3.9.0-7.el7.x86_64 qemu-kvm-rhev-2.10.0-15.el7.x86_64:
Try to do blockcommit on a relative backing chain after restart libvirt:
Run following script:
```
#!/bin/bash -x
VM=V-raw
DISK=vdb
cd /var/lib/libvirt/images
mkdir b c d -p
cd /var/lib/libvirt/images/b
qemu-img create b 100M -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 attach-disk $VM /var/lib/libvirt/images/d/d $DISK --subdriver qcow2
virsh dumpxml $VM|awk '/<disk/,/<\/disk/'
systemctl restart libvirtd
diff <( virsh dumpxml $VM ) /tmp/$VM.xml
virsh blockcommit $VM $DISK --top "$DISK[1]" --shallow --keep-relative
virsh dumpxml $VM|awk '/<disk/,/<\/disk/'
```
The result:
+ VM=V-raw [1/462]
+ DISK=vdb
+ cd /var/lib/libvirt/images
+ mkdir b c d -p
+ cd /var/lib/libvirt/images/b
+ qemu-img create b 100M -f qcow2
Formatting 'b', fmt=qcow2 size=104857600 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
+ cd ../d
+ qemu-img create -b ../c/c -o backing_fmt=qcow2 d -f qcow2
Formatting 'd', fmt=qcow2 size=104857600 backing_file=../c/c backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
+ virsh start V-raw
Domain V-raw started
+ sleep 10
+ virsh attach-disk V-raw /var/lib/libvirt/images/d/d vdb --subdriver qcow2
Disk attached successfully
+ virsh dumpxml V-raw
+ awk '/<disk/,/<\/disk/'
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/mapper/rhel-V'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/d/d'/>
<backingStore type='file' index='1'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/d/../c/c'/>
<backingStore type='file' index='2'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/d/../c/../b/b'/>
<backingStore/>
</backingStore>
</backingStore>
<target dev='vdb' bus='virtio'/>
<alias name='virtio-disk1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
</disk>
+ systemctl restart libvirtd
+ diff /dev/fd/63 /tmp/V-raw.xml
++ virsh dumpxml V-raw
1c1
< <domain type='kvm' id='63'>
---
> <domain type='kvm' id='60'>
109c109
< <source path='/dev/pts/5'/>
---
> <source path='/dev/pts/3'/>
115,116c115,116
< <console type='pty' tty='/dev/pts/5'>
< <source path='/dev/pts/5'/>
---
> <console type='pty' tty='/dev/pts/3'>
> <source path='/dev/pts/3'/>
126c126
< <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-63-V-raw/org.qemu.guest_agent.0'/>
---
> <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-60-V-raw/org.qemu.guest_agent.0'/>
164,165c164,165
< <label>system_u:system_r:svirt_t:s0:c67,c822</label>
< <imagelabel>system_u:object_r:svirt_image_t:s0:c67,c822</imagelabel>
---
> <label>system_u:system_r:svirt_t:s0:c703,c726</label>
> <imagelabel>system_u:object_r:svirt_image_t:s0:c703,c726</imagelabel>
+ virsh blockcommit V-raw vdb --top 'vdb[1]' --shallow --keep-relative
Block Commit started
+ virsh dumpxml V-raw
+ awk '/<disk/,/<\/disk/'
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/mapper/rhel-V'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/d/d'/>
<backingStore type='file' index='1'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/d/../c/../b/b'/>
<backingStore/>
</backingStore>
<target dev='vdb' bus='virtio'/>
<alias name='virtio-disk1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
</disk>
Blockcommit works well after libvirt restarted. Bug fixed.
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 |