Bug 1792195

Summary: block jobs of disks with copy_on_read fail to start
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Peter Krempa <pkrempa>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: yisun
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.2CC: aliang, coli, dyuan, hhan, jdenemar, jgao, kwolf, lmen, rbalakri, xuzhang, yisun
Target Milestone: rc   
Target Release: 8.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-6.0.0-4.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1774375 Environment:
Last Closed: 2020-05-05 09:55:54 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:
Bug Depends On: 1594747, 1774375    
Bug Blocks:    
Attachments:
Description Flags
XMLs and libvirtd log none

Description Peter Krempa 2020-01-17 09:30:18 UTC
+++ This bug was initially created as a clone of Bug #1774375 +++

Based on comment 6 of the bug above. The root cause is completely different.

When a disk has copy on read configured qemu reports an error when trying to block-commit.

--- Additional comment from Han Han on 2020-01-17 07:40:37 CET ---

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 1 Han Han 2020-01-19 02:05:56 UTC
And also https://bugzilla.redhat.com/show_bug.cgi?id=1774375#c9

Comment 2 Han Han 2020-01-19 03:12:38 UTC
Created attachment 1653519 [details]
XMLs and libvirtd log

It also fails at hot-plug:
1. Start an VM
2. Attach a disk with copy_on_read on:
# cat disk.xml    
<disk type='block' device='disk'>
      <driver name='qemu' type='raw' copy_on_read='on'/>
      <source dev='/dev/sdb'/>
      <target dev='vdb' bus='virtio'/>
    </disk>

# virsh attach-device pc disk.xml         
error: Failed to attach device from disk.xml
error: internal error: missing alias or qom-type for qemu object '<null>'

Comment 3 Peter Krempa 2020-02-04 14:27:16 UTC
Fixed upstream by:

0c3792a155 qemu: backup: Implement support for backup disk bitmap name configuration
bce4ac55f8 qemu: backup: Implement support for backup disk export name configuration
12ccd8d4db conf: backup: Allow configuration of names exported via NBD
69908db0f6 qemu: Fix value of 'device' argument for block-commit
e3137539a9 qemu: Fix value of 'device' argument for blockdev-mirror
0b0f389335 qemu: domain: Extract code to determine topmost nodename to qemuDomainDiskGetTopNodename
623366d130 qemu: blockcopy: Actually unplug unused images when mirror job fails to start


Note that due to bug 1594747 the block-commit job still will not work but with a different error message. This series also fixes the unplug of the backend on a failed job.

Comment 4 Peter Krempa 2020-02-04 14:28:22 UTC
(In reply to Han Han from comment #2)
> Created attachment 1653519 [details]
> XMLs and libvirtd log
> 
> It also fails at hot-plug:
> 1. Start an VM
> 2. Attach a disk with copy_on_read on:
> # cat disk.xml    
> <disk type='block' device='disk'>
>       <driver name='qemu' type='raw' copy_on_read='on'/>
>       <source dev='/dev/sdb'/>
>       <target dev='vdb' bus='virtio'/>
>     </disk>
> 
> # virsh attach-device pc disk.xml         
> error: Failed to attach device from disk.xml
> error: internal error: missing alias or qom-type for qemu object '<null>'

Since hot-plug is not a block job, please file a separate bug for that issue.

Comment 6 Han Han 2020-02-05 07:30:11 UTC
(In reply to Peter Krempa from comment #4)
> (In reply to Han Han from comment #2)
> > Created attachment 1653519 [details]
> > XMLs and libvirtd log
> > 
> > It also fails at hot-plug:
> > 1. Start an VM
> > 2. Attach a disk with copy_on_read on:
> > # cat disk.xml    
> > <disk type='block' device='disk'>
> >       <driver name='qemu' type='raw' copy_on_read='on'/>
> >       <source dev='/dev/sdb'/>
> >       <target dev='vdb' bus='virtio'/>
> >     </disk>
> > 
> > # virsh attach-device pc disk.xml         
> > error: Failed to attach device from disk.xml
> > error: internal error: missing alias or qom-type for qemu object '<null>'
> 
> Since hot-plug is not a block job, please file a separate bug for that issue.

New bug: https://bugzilla.redhat.com/show_bug.cgi?id=1798366

Comment 8 yisun 2020-02-24 09:00:22 UTC
Test result: PASS

[root@hp-dl320eg8-05 bz1792195]# rpm -qa | egrep "^libvirt-6|^qemu-kvm-4"
qemu-kvm-4.2.0-10.module+el8.2.0+5740+c3dff59e.x86_64
libvirt-6.0.0-5.module+el8.2.0+5765+64816f89.x86_64

[root@hp-dl320eg8-05 bz1792195]# virsh start vm1
Domain vm1 started

[root@hp-dl320eg8-05 bz1792195]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' copy_on_read='on'/>
      <source file='/var/lib/libvirt/images/vda.qcow2' index='1'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </disk>
[root@hp-dl320eg8-05 bz1792195]# virsh snapshot-create-as vm1 s1 --no-metadata --disk-only
Domain snapshot s1 created
[root@hp-dl320eg8-05 bz1792195]# virsh blockcommit vm1 vda --active --wait --verbose
error: internal error: unable to execute QEMU command 'block-commit': 'libvirt-2-format' is not in this backing file chain

The error message is due to copy-on-read broke the backing chain due to bug 1594747 as mentioned in comment 3. So mark current bz as VERIFIED
backup scenarios will be covered in IncrementalBackup bz

Comment 10 errata-xmlrpc 2020-05-05 09:55:54 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