Bug 1209802

Summary: Blockcopy for lun device changes disk type=block to file, however, it's unsupported configuration
Product: Red Hat Enterprise Linux 7 Reporter: Yang Yang <yanyang>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: dyuan, eblake, mzhan, rbalakri, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.3.5-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:16:04 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 Yang Yang 2015-04-08 09:00:37 UTC
Description of problem:
Blockcopy for lun device changes disk type=block to file, however,
it's unsupported configuration, disk device='lun' is only valid for
block type disk source. It's better provide error message when issuing
blockcopy, OR specify that when doing blockcopy with lun device,
must specify --blockdev in manual page


Version-Release number of selected component (if applicable):
libvirt-1.2.14-1.el7.x86_64
qemu-kvm-rhev-2.2.0-8.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare a transient domain specifying block as disk type, lun as device type
<disk type='block' device='lun'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/HostVG/vol1'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>

2. blockcopy and pivot

# virsh blockcopy vm3 vda /tmp/vm3.copy --wait --verbose
Block Copy: [100 %]
Now in mirroring phase

# virsh blockjob vm3 vda --pivot

3. check domain xml
# virsh dumpxml vm3 | grep disk -a6
<disk type='file' device='lun'>
      <driver name='qemu' type='qcow2'/>
      <source file='/tmp/vm3.copy'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>

4. edit domain xml to make it persistent and destroy/start domain
# virsh edit vm3
Domain vm3 XML configuration edited.

# virsh destroy vm3; virsh start vm3
Domain vm3 destroyed

error: Failed to start domain vm3
error: unsupported configuration: disk device='lun' is only valid for block type disk source

Actual results:

Expected results:
It's better provide error message when issuing blockcopy, OR specify that when doing blockcopy with lun device, must specify --blockdev in manual page


Additional info:

Comment 2 Eric Blake 2015-04-08 14:32:05 UTC
We could also be nice and automatically imply the --blockdev flag when copying a lun source (that is, you are correct that the destination of a block copy of a lun device must be another block device, and we should error out if the destination is a regular file; and this behavior is what you would get if supplying the --blockdev flag)

Comment 4 Peter Krempa 2016-05-09 11:36:00 UTC
Fixed upstream:

commit bd9d7078949ab19fd844926a20196d5533cfdf89
Author: Peter Krempa <pkrempa>
Date:   Mon May 2 15:26:51 2016 +0200

    qemu: Reject invalid block copy targets for <disk device='lun'>
    
    Extract the relevant parts of the existing checker and reuse them for
    blockcopy since copying to a non-block device creates an invalid
    configuration.

Comment 6 Yang Yang 2016-09-22 10:01:09 UTC
Verified with libvirt-2.0.0-10.el7.x86_64 and qemu-kvm-rhev-2.6.0-26.el7.x86_64

As virtio lun does not work currently, test it using lun device + raw format + scsi bus. Libvirt provides proper error message

Steps:
1. create a vm with scsi-block
<disk type='block' device='lun'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdl'/>
      <target dev='sda' bus='scsi'/>
    </disk>

2. blockcopy to a file
# virsh blockcopy vm1 sda /tmp/vm1.copy --wait --verbose
error: unsupported configuration: disk device='lun' is only valid for block type disk source

Comment 7 Yang Yang 2016-09-23 03:25:11 UTC
According to comment#6, move it to verified status

Comment 9 errata-xmlrpc 2016-11-03 18:16:04 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://rhn.redhat.com/errata/RHSA-2016-2577.html