Bug 1774375 - Fail to create external snapshot after pivot blockcommit with -blockdev enabled
Summary: Fail to create external snapshot after pivot blockcommit with -blockdev enabled
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.2
Assignee: Peter Krempa
QA Contact: Meina Li
URL:
Whiteboard:
Depends On:
Blocks: 1792195
TreeView+ depends on / blocked
 
Reported: 2019-11-20 08:00 UTC by Han Han
Modified: 2020-05-05 09:51 UTC (History)
6 users (show)

Fixed In Version: libvirt-5.10.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1792195 (view as bug list)
Environment:
Last Closed: 2020-05-05 09:50:55 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)
domain xml, virtqemud log (10.18 KB, application/gzip)
2019-11-20 08:00 UTC, Han Han
no flags Details
domain xml and libvirtd log of comment6 (14.62 KB, application/gzip)
2020-01-17 06:43 UTC, Han Han
no flags Details
domain xml, libvirtd log, disk.xml (9.53 KB, application/gzip)
2020-01-17 09:39 UTC, Han Han
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:2017 0 None None None 2020-05-05 09:51:38 UTC

Description Han Han 2019-11-20 08:00:09 UTC
Created attachment 1638029 [details]
domain xml, virtqemud log

Description of problem:
As subject

Version-Release number of selected component (if applicable):
libvirt-5.9.0-2.module+el8.2.0+4683+7e10e783.x86_64
qemu v4.2.0-rc2
Qemu build configurations:
./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --interp-prefix=/usr/qemu-%M --localstatedir=/var --docdir=/usr/share/doc/qemu-kvm --libexecdir=/usr/libexec '--extra-ldflags=-Wl,--build-id -Wl,-z,relro -Wl,-z,now' '--extra-cflags=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --with-pkgversion=qemu-kvm-4.1.0-13.el8 --with-confsuffix=/qemu-kvm --firmwarepath=/usr/share/qemu-firmware --disable-fdt --enable-glusterfs --enable-guest-agent --enable-numa --enable-rbd --enable-rdma --disable-pvrdma --enable-seccomp --enable-spice --enable-smartcard --enable-virglrenderer --enable-opengl --enable-usb-redir --disable-tcmalloc --enable-libpmem --enable-vhost-user --enable-avx2 --python=/usr/libexec/platform-python --target-list=x86_64-softmmu --block-drv-rw-whitelist=qcow2,raw,file,host_device,nbd,iscsi,rbd,blkdebug,luks,null-co,nvme,copy-on-read,throttle,gluster --audio-drv-list= --block-drv-ro-whitelist=vmdk,vhdx,vpc,https,ssh --with-coroutine=ucontext --tls-priority=NORMAL --disable-bluez --disable-brlapi --disable-cap-ng --enable-coroutine-pool --enable-curl --disable-curses --disable-debug-tcg --enable-docs --disable-gtk --enable-kvm --enable-libiscsi --disable-libnfs --enable-libssh --enable-libusb --disable-bzip2 --enable-linux-aio --disable-live-block-migration --enable-lzo --enable-pie --disable-qom-cast-debug --disable-sdl --enable-snappy --disable-sparse --disable-strip --enable-tpm --enable-trace-backend=dtrace --disable-vde --disable-vhost-scsi --disable-vxhs --disable-virtfs --disable-vnc-jpeg --disable-vte --enable-vnc-png --enable-vnc-sasl --enable-werror --disable-xen --disable-xfsctl --enable-gnutls --enable-gcrypt --disable-nettle --enable-attr --disable-bsd-user --disable-cocoa --enable-debug-info --disable-guest-agent-msi --disable-hax --disable-jemalloc --disable-linux-user --enable-modules --disable-netmap --disable-replication --enable-system --enable-tools --disable-user --enable-vhost-net --enable-vhost-vsock --enable-vnc --enable-mpath --disable-xen-pci-passthrough --enable-tcg --with-git=git --disable-sanitizers --disable-hvf --disable-whpx --enable-malloc-trim --disable-membarrier --disable-vhost-crypto --disable-libxml2 --enable-capstone --disable-git-update --disable-crypto-afalg --disable-debug-mutex --disable-bochs --disable-cloop --disable-dmg --disable-qcow1 --disable-vdi --disable-vvfat --disable-qed --disable-parallels --disable-sheepdog --disable-auth-pam --enable-iconv --disable-lzfse --enable-vhost-kernel --with-default-devices

How reproducible:
100%

Steps to Reproduce:
1. Build qemu as configurations above and install qemu-system-x86_64 to /bin.
Set virtqemud logfilter as following:
log_filters="1:qemu 1:libvirt 4:object 4:json 4:event 1:util"

Stop libvirtd and start virtproxy&virtqemud


2. Start a vm with -blockdev enabled
<domain type='kvm' id='4' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
...
  <qemu:capabilities>
    <qemu:add capability='blockdev'/>
  </qemu:capabilities>
</domain>

3. Create a external snapshot, do blockcommit with --pivot, then create a external snapshot again:
➜  ~ virsh snapshot-create-as copy s1 --no-metadata --disk-only
Domain snapshot s1 created
➜  ~ virsh blockcommit copy sda --active --wait --verbose
Block commit: [100 %]
Now in synchronized phase
➜  ~ virsh blockjob copy sda --pivot

➜  ~ virsh snapshot-create-as copy s2 --no-metadata --disk-only
error: unsupported configuration: nothing selected for snapshot


Actual results:
As step3

Expected results:
No error on the 2nd snapshot

Additional info:
Building 4.2 from source code is to bypass BZ1773925. You can install qemu 4.2 directly when rpms are ready.

Comment 1 Peter Krempa 2019-11-20 08:45:25 UTC
Could you please check, whether the active XML contains <readonly/> on the disk of the VM? If so it's probably a bug which was fixed by 

commit b036834eaea6eeb514896310edd418686b82f64b
Author: Peter Krempa <pkrempa>
Date:   Fri Nov 8 16:38:08 2019 +0100

    qemu: blockjob: Transfer 'readonly' state of images after active layer block commit
    
    When commiting a different image becomes the disk source. Since we store
    the readonly flag per-image we must update it to the same state the
    original image had.

https://libvirt.org/git/?p=libvirt.git;a=commit;h=b036834eaea6eeb514896310edd418686b82f64b

Comment 2 Han Han 2019-11-20 09:08:32 UTC
(In reply to Peter Krempa from comment #1)
> Could you please check, whether the active XML contains <readonly/> on the
> disk of the VM? If so it's probably a bug which was fixed by 
> 
> commit b036834eaea6eeb514896310edd418686b82f64b
> Author: Peter Krempa <pkrempa>
> Date:   Fri Nov 8 16:38:08 2019 +0100
> 
>     qemu: blockjob: Transfer 'readonly' state of images after active layer
> block commit
>     
>     When commiting a different image becomes the disk source. Since we store
>     the readonly flag per-image we must update it to the same state the
>     original image had.
> 
> https://libvirt.org/git/?p=libvirt.git;a=commit;
> h=b036834eaea6eeb514896310edd418686b82f64b

Active xml:
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/copy.qcow2' index='1'/>
      <backingStore/>
      <target dev='sda' bus='scsi'/>
      <readonly/>
      <alias name='scsi0-0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

<readonly/> there 
😃

Comment 3 Peter Krempa 2019-11-20 09:14:02 UTC
Thank you for the confirmation!

Comment 4 Jiri Denemark 2019-11-20 11:39:11 UTC
Changing product according to the libvirt and QEMU versions in the bug description.

Comment 6 Han Han 2020-01-17 06:40:37 UTC
test failed on libvirt-6.0.0-1.module+el8.2.0+5453+31b2b136.x86_64 qemu-kvm-4.2.0-6.module+el8.2.0+5453+31b2b136.x86_64:
Prepare an active vm:
# virsh snapshot-create-as pc s1 --no-metadata --disk-only
Domain snapshot s1 created

# virsh blockcommit pc vda --active --wait --verbose
error: internal error: unable to execute QEMU command 'block-commit': Need a root block node

# virsh blockcommit pc vda --active --wait --verbose
error: internal error: child reported (status=125): Requested operation is not valid: Setting different SELinux label on /var/lib/libvirt/images/RHEL-8.2-x86_64-latest.qcow2 which is already in use

# virsh blockcommit pc vda --active --wait --verbose
error: internal error: child reported (status=125): Requested operation is not valid: Setting different SELinux label on /var/lib/libvirt/images/RHEL-8.2-x86_64-latest.qcow2 which is already in use

Comment 7 Han Han 2020-01-17 06:43:34 UTC
Created attachment 1652958 [details]
domain xml and libvirtd log of comment6

Comment 8 Peter Krempa 2020-01-17 09:32:57 UTC
The root cause of the problem in comment#6 is completely different from this bug. I filed https://bugzilla.redhat.com/show_bug.cgi?id=1792195 for that. Moving back to ON_QA. Please re-test this issue without 'copy_on_read' enabled on the disk.

Comment 9 Han Han 2020-01-17 09:39:35 UTC
Created attachment 1652987 [details]
domain xml, libvirtd log, disk.xml

Blockcopy to nbd disk also shows the same error:

version: the same as comment6

steps:
1. Create a full allocated qcow2
# qemu-img create /var/lib/libvirt/images/nbd.qcow2 10G -f qcow2 -o preallocation=full

2. Create nbd server
# qemu-nbd -f raw /var/lib/libvirt/images/nbd.qcow2 -x test -t -e 10 -v

3. Start vm and do blockcopy
# virsh list                                                           
 Id   Name   State
----------------------
 3    pc     running

# virsh dumpxml pc|xmllint --xpath '//disk' -                          
<disk type="file" device="disk">
      <driver name="qemu" type="qcow2" copy_on_read="on"/>
      <source file="/var/lib/libvirt/images/RHEL-8.2-x86_64-latest.qcow2" index="1"/>
      <backingStore/>
      <target dev="vda" bus="virtio"/>
      <alias name="virtio-disk0"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x09" function="0x0"/>
    </disk>#

# cat nbd.xml 
  <disk type='network'>
    <driver name="qemu" type="qcow2"/>
    <source protocol="nbd" name="test">
      <host name="localhost"/>
    </source>
    <target dev="vda" bus="virtio"/>
  </disk>

# virsh blockcopy pc vda --xml nbd.xml --transient-job --wait --verbose
error: internal error: unable to execute QEMU command 'blockdev-mirror': Need a root block node

However the connection is continued:

# netstat -antp|grep 10809                            
tcp        0      0 0.0.0.0:10809           0.0.0.0:*               LISTEN      26114/qemu-nbd      
tcp        0      0 127.0.0.1:40810         127.0.0.1:10809         ESTABLISHED 26950/qemu-kvm      
tcp        0      0 127.0.0.1:10809         127.0.0.1:40810         ESTABLISHED 26114/qemu-nbd

Comment 10 Peter Krempa 2020-01-17 10:34:15 UTC
That is also instance of https://bugzilla.redhat.com/show_bug.cgi?id=1792195 . The problem is with the copy_on_read part.

Comment 11 Han Han 2020-01-19 06:20:38 UTC
Works on libvirt-6.0.0-1.module+el8.2.0+5453+31b2b136.x86_64 qemu-kvm-4.2.0-6.module+el8.2.0+5453+31b2b136.x86_64:
1. Start an VM
VM disk xml:
# virsh dumpxml pc|xmllint --xpath //disk -                                              
<disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
        <source protocol="nbd" name="test" tls="no">
          <host name="localhost" port="10809"/>
        </source>
      <target dev="vda" bus="virtio"/>
      <alias name="virtio-disk0"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x09" function="0x0"/>
    </disk>

2. Create a snapshot
# virsh snapshot-create-as pc s1 --diskspec vda,file=/tmp/pc.s1 --no-metadata --disk-only
Domain snapshot s1 created

3. Do blockcommit:
# virsh blockcommit pc vda --active --wait --verbose --pivot   
Block commit: [100 %]
Successfully pivoted

Comment 12 Meina Li 2020-03-17 08:38:03 UTC
Worked well on version:
libvirt-6.0.0-10.el8.x86_64
Test Steps:
SC1: Create external snapshot for the guest with the simple file disk.
1. Start a guest.
# virsh dumpxml lmn | grep /disk -B7
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/lmn.qcow2' index='1'/>	
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
2. Create an external snapshot, do blockcommit with --pivot.
# virsh snapshot-create-as lmn s1 --disk-only --no-metadata 
Domain snapshot s1 created
# virsh blockcommit lmn vda --active --wait --verbose --pivot 
Block commit: [100 %]
Successfully pivoted
3. Create another external snapshot again.
# virsh snapshot-create-as lmn s2 --disk-only --no-metadata 
Domain snapshot s2 created

SC2: Create external snapshot for the guest with nbd network disk.
1. Create a full allocated qcow2 and nbd server in another terminal.
# qemu-img create /var/lib/libvirt/images/nbd.qcow2 2G -f qcow2 -o preallocation=full
Formatting '/var/lib/libvirt/images/nbd.qcow2', fmt=qcow2 size=2147483648 cluster_size=65536 preallocation=full lazy_refcounts=off refcount_bits=16
# qemu-nbd -f raw /var/lib/libvirt/images/nbd.qcow2 -x test -t -e 10 -v
2. Start the guest with nbd network disk.
 # virsh dumpxml lmn | grep /disk -B8
    <disk type='network' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source protocol='nbd' name='test' tls='no' index='1'>
        <host name='localhost' port='10809'/>
      </source>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
3. Create an external snapshot, do blockcommit with --pivot.
virsh snapshot-create-as lmn s1 --diskspec vda,file=/tmp/lmn.s1 --disk-only --no-metadata
Domain snapshot s1 created
# virsh blockcommit lmn vda --active --wait --verbose --pivot 
Block commit: [100 %]
Successfully pivoted
4. Create another external snapshot again.
# virsh snapshot-create-as lmn s2 --diskspec vda,file=/tmp/lmn.s2 --disk-only --no-metadata
Domain snapshot s2 created

Comment 14 errata-xmlrpc 2020-05-05 09:50:55 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/RHBA-2020:2017


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