Bug 871055

Summary: libvirt should support both upstream and RHEL drive-mirror
Product: Red Hat Enterprise Linux 6 Reporter: Eric Blake <eblake>
Component: libvirtAssignee: Eric Blake <eblake>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: high    
Version: 6.3CC: acathrow, ajia, dallan, dyasny, dyuan, eblake, fsimonce, jdenemar, jpallich, juzhang, kchamart, mjenner, mzhan, rwu, zpeng
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.10.2-6.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 856247 Environment:
Last Closed: 2013-02-21 07:11:11 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: 772088, 837787, 856247    
Bug Blocks: 860720    

Comment 3 Eric Blake 2012-10-29 15:23:37 UTC
It turns out that RHEL libvirt will NOT support qemu 1.3, at least not without the addition of several upstream patches, such as:
43e23c73a    Add support for detecting capablities using QMP commands
0caccb58f    qemu: Kill processes used for QMP caps probing
2b804cfaf    build: fix typo in debug message
844cdf22e    qemu: Fix QMP detection of QXL graphics
and probably several others.  See also bug 869138

But it also turns out that the existing RHEL-only patch for supporting both 'block-commit' and '__com.redhat_block-commit' (if we overlook the fact that qemu 1.3 isn't even supported) also has a bug - on an ill-timed OOM error, it failed to set 'ret = -1' and can report success when block-commit fails and retrying with __com.redhat_block-commit.

The v2 patch here addresses the potential OOM wrong return value, but we would need a much more invasive series as a v3 if we want RHEL libvirt to be able to drive qemu 1.3.
http://post-office.corp.redhat.com/archives/rhvirt-patches/2012-October/msg01202.html

Comment 7 zhe peng 2012-12-05 06:16:38 UTC
thanks Dave,
test with:
libvirt-0.10.2-10.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.337.el6.x86_64
for block-commit & block-pull:
step:
 1:create&start a guest
 2:create two snapshot
  #virsh snapshot-create-as vm1 snapshot1 --disk-only
  #virsh snapshot-create-as vm1 snapshot2 --disk-only
 check snapshot
# virsh snapshot-list vm1
 Name                 Creation Time             State
------------------------------------------------------------
 snapshot1            2012-12-05 14:48:01 -0500 disk-snapshot
 snapshot2            2012-12-05 14:48:04 -0500 disk-snapshot
# qemu-img info /var/lib/libvirt/images/test.snapshot1 
image: /var/lib/libvirt/images/test.snapshot1
file format: qcow2
virtual size: 1.0G (1048576000 bytes)
disk size: 136K
cluster_size: 65536
backing file: /var/lib/libvirt/images/test.img
[root@localhost tmp]# qemu-img info /var/lib/libvirt/images/test.snapshot2 
image: /var/lib/libvirt/images/test.snapshot2
file format: qcow2
virtual size: 1.0G (1048576000 bytes)
disk size: 136K
cluster_size: 65536
backing file: /var/lib/libvirt/images/test.snapshot1
  3:do block-pull
# virsh blockpull vm1 hda
Block Pull started
when task finish, check img
# qemu-img info /var/lib/libvirt/images/test.snapshot2 
image: /var/lib/libvirt/images/test.snapshot2
file format: qcow2
virtual size: 1.0G (1048576000 bytes)
disk size: 196K
cluster_size: 65536
#virsh dumpxml vm1
....
    <source file='/var/lib/libvirt/images/test.snapshot2'/>
....

for block-commit:
step:
 1:restore env. 
 2:#virsh blockcommit vm1 hda --base /var/lib/libvirt/images/test.img --top /var/lib/libvirt/images/test.snapshot1
Block Commit started

 3:when finish,check img
# qemu-img info test.snapshot2
image: test.snapshot2
file format: qcow2
virtual size: 1.0G (1048576000 bytes)
disk size: 196K
cluster_size: 65536
backing file: /var/lib/libvirt/images/test.img

for block-copy:
# vgcreate vgtest1 /dev/mapper/1IET_00010001
# lvcreate -n lvbaseimg1 -L 1G vgtest1
# lvcreate -n lvbaseimg2 -L 1G vgtest1
# lvcreate -n lvleafimg1 -L 1G vgtest1
# lvcreate -n lvleafimg2 -L 1G vgtest1
# qemu-img create -f qcow2 -F raw -b /dev/vgtest1/lvbaseimg1 /dev/vg_virt/lvleafimg1
# qemu-img create -f qcow2 -F raw -b /dev/vgtest1/lvbaseimg2 /dev/vg_virt/lvleafimg2
# cat > vm1.xml <<EOF
<domain type="kvm">
  <name>vm1</name>
  <memory>131072</memory>
  <devices>
    <disk device="disk" type="block">
      <source dev="/dev/vg_virt/lvleafimg1"/>
      <target bus="ide" dev="hda"/>
      <driver name="qemu" type="qcow2"/>
    </disk>
  </devices>
  <os>
    <type arch="x86_64" machine="pc">hvm</type>
  </os>
</domain>
EOF

# for i in /dev/vg_virt/lv*; do chgrp -v qemu $(readlink -f $i); done

#virsh create vm1.xml

# virsh blockcopy --shallow --reuse-external --wait vm1 /dev/vg_virt/lvleafimg1 /dev/vg_virt/lvleafimg2

Now in mirroring phase

make sure blockjob in phase two
#virsh blockjob --info vm1 /dev/vg_virt/lvleafimg1
Block Copy: [100 %]


blockcopy can worked, but pivot still have some issues,i will track it in another bug: https://bugzilla.redhat.com/show_bug.cgi?id=856247
so move this bug to verified.

Comment 8 errata-xmlrpc 2013-02-21 07:11:11 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.

http://rhn.redhat.com/errata/RHSA-2013-0276.html