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 1523261 - block commit with --keep-relative does not work after libvirtd restart
Summary: block commit with --keep-relative does not work after libvirtd restart
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.4
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-07 14:36 UTC by Peter Krempa
Modified: 2018-04-10 11:03 UTC (History)
7 users (show)

Fixed In Version: libvirt-3.9.0-7.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 11:02:08 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:03:43 UTC

Description Peter Krempa 2017-12-07 14:36:14 UTC
Description of problem:
Libvirt does not re-detect or store necessary metadata for --keep-relative to work after restart.

Version-Release number of selected component (if applicable):


How reproducible:
100%

Steps to Reproduce:
1. Create few snapshots with relative backing paths (using --reuse-external)
2. Restart libvirtd
3. try virsh block-commit --keep-relative

Actual results:
error: Requested operation is not valid: can't keep relative backing relationship

Expected results:
Block commit successful

Additional info:

Comment 3 Han Han 2017-12-08 09:39:30 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'

Comment 4 Peter Krempa 2017-12-14 13:18:40 UTC
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.

Comment 7 Han Han 2018-01-13 14:48:09 UTC
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.

Comment 11 errata-xmlrpc 2018-04-10 11:02:08 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.