Bug 1196066

Summary: Disk type=block converted to disk type=file after block copy
Product: Red Hat Enterprise Linux 7 Reporter: Jan Kurik <jkurik>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.1CC: alitke, amureini, bazulay, bhamrick, cmestreg, cww, dyuan, eblake, ecohen, fromani, gklein, iheim, jdenemar, jherrman, kgoldbla, lpeer, lsurette, michele, mjenner, mkalinin, nsoffer, ogofen, pkrempa, pm-eus, rbalakri, rlocke, scohen, sherold, shyu, vanhoof, xuzhang, yeylon, ylavi
Target Milestone: rcKeywords: Regression, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.8-16.el7_1.1 Doc Type: Bug Fix
Doc Text:
The block copy operation has previously been adjusted to change the disk type of the copied disk to "file". However, using block copy for moving block-based storage thus converted the new target to an incorrect type. Consequently, if a virtual disk was backed by a block device rather than a file, libvirt did not report the allocation information necessary to track a thin-provisioned volume. This update introduces a libvirt flag that makes it possible to specify that the target will be treated as a block device. As a result, users can now perform a block copy to a block target correctly.
Story Points: ---
Clone Of: 1195461 Environment:
Last Closed: 2015-03-05 14:10:13 UTC Type: ---
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: 1195461    
Bug Blocks: 1176673    

Description Jan Kurik 2015-02-25 09:06:16 UTC
This bug has been copied from bug #1195461 and has been proposed
to be backported to 7.1 z-stream (EUS).

Comment 9 Shanzhi Yu 2015-02-26 10:31:40 UTC
With packages
libvirt-1.2.8-16.el7_1.1.x86_64
qemu-kvm-rhev-2.2.0-5.el7.x86_64

My verify steps is as below:

1. Prepare logical volume lv01 ,lv02 and lv03, and format lv01 and lv02 to qcow2 with qemu-img

# pvcreate /dev/sda7
  Physical volume "/dev/sda7" successfully created
# vgcreate vg01 /dev/sda7
  Volume group "vg01" successfully created
# for i in 1 2 3 ;do lvcreate -L  10G  -n lv0$i vg01;done
  Logical volume "lv01" created.
  Logical volume "lv02" created.
  Logical volume "lv03" created.
# qemu-img create -f qcow2 /dev/vg01/lv01 10G
Formatting '/dev/vg01/lv01', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 lazy_refcounts=off 
# qemu-img create -f qcow2 /dev/vg01/lv02 10G
Formatting '/dev/vg01/lv02', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 lazy_refcounts=off

2. Prepare a transient guest with source file based on logical volume lv01

# virsh list --transient
 Id    Name                           State
----------------------------------------------------
 3     r7                             running

# virsh dumpxml r7|grep disk -A 5
    <disk type=block device=disk>
      <driver name=qemu type=qcow2/>
      <source dev=/dev/vg01/lv01/>
      <backingStore/>
      <target dev=vda bus=virtio/>
      <alias name=virtio-disk0/>
      <address type=pci domain=0x0000 bus=0x00 slot=0x04 function=0x0/>
    </disk>

3. Do blockcopy to lv02(qcow2 format)

3.1 doesn't use options --reuse-external

1. check do blockjob then abort the blockcopy

1). Do blockcopy
# virsh blockcopy r7 vda --blockdev /dev/vg01/lv02 --verbose --wait 

Now in mirroring phase

2). Check blockjob info

# virsh blockjob r7 vda 

NB:
No block job show 
[deserve a fix here?]

# virsh dumpxml r7|grep mirror -B 4
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv01'/>
      <backingStore/>
      <mirror type='block' job='copy' ready='yes'>
        <format type='qcow2'/>
        <source dev='/dev/vg01/lv02'/>
      </mirror>


3). Abort the job
# virsh blockjob r7 vda --abort 

4). Recheck the source file type.

# virsh dumpxml r7|grep disk -A 4
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv01'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>


2. check do blockjob then pivot the blockcopy

1) Do blockcopy 
# virsh blockcopy r7 vda --blockdev /dev/vg01/lv02 --verbose --wait 

Now in mirroring phase

2) Check blockjob info
# virsh blockjob r7 vda 

# virsh dumpxml r7|grep mirror -B 4 
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv01'/>
      <backingStore/>
      <mirror type='block' job='copy' ready='yes'>
        <format type='qcow2'/>
        <source dev='/dev/vg01/lv02'/>
      </mirror>

3) Do pivot 

# virsh blockjob r7 vda --pivot 

4) Recheck the source file type

# virsh dumpxml r7|grep disk -A 4
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv02'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>

3.2 use options --reuse-external 

1. check do blockjob then abort the blockcopy

1)Do blockcopy
# virsh blockcopy r7 vda --blockdev --reuse-external  /dev/vg01/lv02 --verbose --wait 

Now in mirroring phase


2)Check blockjob info

# virsh blockjob r7 vda 

# virsh dumpxml r7|grep mirror -B 4 
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv01'/>
      <backingStore/>
      <mirror type='block' job='copy' ready='yes'>
        <format type='qcow2'/>
        <source dev='/dev/vg01/lv02'/>
      </mirror>

3) Abort the job
# virsh blockjob r7 vda --abort

# virsh dumpxml r7|grep mirror -B 4


4) Recheck the source file type.

# virsh dumpxml r7|grep disk -A 4
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv01'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>

2. check do blockjob then pivot the blockcopy

1) Do blockcopy
# virsh blockcopy r7 vda /dev/vg01/lv02 --blockdev --reuse-external --verbose --wait 

Now in mirroring phase


2) Check blockjob info

# virsh blockjob r7 vda 

# virsh dumpxml r7|grep mirror -B 4 
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv01'/>
      <backingStore/>
      <mirror type='block' job='copy' ready='yes'>
        <format type='qcow2'/>
        <source dev='/dev/vg01/lv01'/>
      </mirror>


3) Pivot the job

# virsh blockjob r7 vda --pivot 

# virsh dumpxml r7|grep mirror -B 4 

4) Recheck the source file type.

# virsh dumpxml r7|grep disk -A 4
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv01'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>

4. Do blockcopy to lv03(raw format)

# qemu-img info /dev/vg01/lv03 
image: /dev/vg01/lv03
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 0

4.1 blockcopy + pivot 

# virsh blockcopy r7 vda /dev/vg01/lv03 --blockdev  --verbose --wait 

Now in mirroring phase

# virsh dumpxml r7|grep mirror -B 4
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv01'/>
      <backingStore/>
      <mirror type='block' job='copy' ready='yes'>
        <format type='qcow2'/>
        <source dev='/dev/vg01/lv03'/>
      </mirror>

# qemu-img info /dev/vg01/lv03 
image: /dev/vg01/lv03
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 0
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    corrupt: false

# virsh blockjob r7 vda --pivot 


# virsh dumpxml r7|grep disk -A 4 
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv03'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>

4.2 blockcopy + abort

# virsh blockcopy r7 vda /dev/vg01/lv03 --blockdev  --verbose --wait 

Now in mirroring phase

# virsh dumpxml r7|grep mirror -B 4
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv01'/>
      <backingStore/>
      <mirror type='block' job='copy' ready='yes'>
        <format type='qcow2'/>
        <source dev='/dev/vg01/lv03'/>
      </mirror>

# qemu-img info /dev/vg01/lv03 
image: /dev/vg01/lv03
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 0
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    corrupt: false

# virsh blockjob r7 vda  --abort

# virsh dumpxml r7|grep disk -A  4
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/vg01/lv01'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>

The only issue is there is no job info show when blockcopy is in mirror phase,  and there is no any difference whether I use "--reuse-external" or not. So that mean this option doens't work here? Does that matter?

# virsh blockjob r7 vda 

Otherwise, I will change this bug to verify.

Comment 10 Peter Krempa 2015-02-26 12:58:31 UTC
The block job state issue happens on upstream too so I think it's worth a separate bug.

Comment 13 errata-xmlrpc 2015-03-05 14:10:13 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/RHBA-2015-0625.html