To implement virt-sparsify in oVirt we actually need the full support for block devices. +++ This bug was initially created as a clone of Bug #1056290 +++ Description of problem: (Reported by shawnjgoff on IRC) If you do something like: virt-sparsify infile /dev/vg/lv then virt-sparsify will overwrite /dev/vg/lv with a file, which is not exactly as intended. It should detect if the output is a block device and (probably) reject the attempt, although there is a possible use case which is writing a qcow2 file into an LV (as used by oVirt). Version-Release number of selected component (if applicable): virt-sparsify 1.20.11rhel=6,release=2.el6 --- Additional comment from Richard W.M. Jones on 2014-01-22 08:12:47 EST --- Upstream fix is: 13bca32e4ec9213e69ea55e837dea846719fb67e available in libguestfs >= 1.25.26 and >= 1.24.6.
Patch posted: https://www.redhat.com/archives/libguestfs/2014-July/msg00073.html
(In reply to Richard W.M. Jones from comment #2) > Patch posted: > > https://www.redhat.com/archives/libguestfs/2014-July/msg00073.html Just for the record, we are not risking to hit bug 1056290 again? Thanks.
(In reply to Federico Simoncelli from comment #3) > (In reply to Richard W.M. Jones from comment #2) > > Patch posted: > > > > https://www.redhat.com/archives/libguestfs/2014-July/msg00073.html > > Just for the record, we are not risking to hit bug 1056290 again? Thanks. It's a good question. The code in virt-sparsify just runs: qemu-img convert overlay outdisk The root cause of bug 1056290 was not in libguestfs, it was in qemu-img, or more specifically in the block layer in qemu. I have tested qemu-img convert in RHEL 6.5 against a loop device and it correctly opens the block device. It doesn't delete or overwrite the device node. I have also tested virt-sparsify against an LV on recent Fedora, and that works. So we may have just hit a transient bug in qemu-img.
Upstream commit: https://github.com/libguestfs/libguestfs/commit/12b54ef5e3aecd55d228a96dfb0a9ab5c8acdf4a
Can reproduce with libguestfs-1.20.11-2.el6 Steps to reproduce: #virt-sparsify rhel77.img /dev/VolGroup/test qemu-img version 0.9 Create overlay file to protect source disk ... Examine source disk ... 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:-- Fill free space in /dev/rhel/root with zero ... 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 Clearing Linux swap on /dev/rhel/swap ... 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 Fill free space in /dev/sda1 with zero ... 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 Copy to destination and make sparse ... ......
Verified with the package version: libguestfs-1.20.11-14.el6.x86_64 Verify steps: 1. # virt-sparsify RHEL-Server-7.1-64-hvm-2.raw /dev/vg_ibmx3650m303/test qemu-img version 0.9 Input disk virtual size = 10486808576 bytes (9.8G) Create overlay file in /tmp to protect source disk ... Examine source disk ... Fill free space in /dev/rhel/root with zero ... 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 Clearing Linux swap on /dev/rhel/swap ... 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 Fill free space in /dev/sda1 with zero ... 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 Fill free space in volgroup rhel with zero ... Copy to destination and make sparse ... Sparsify operation completed with no errors. Before deleting the old disk, carefully check that the target disk boots and works correctly. --------end-------- 2. # virt-sparsify RHEL-Server-7.1-64-hvm-2.raw /dev/input/mouse0 virt-sparsify: error: output '/dev/vcs' cannot be a character device, it must be a regular file virt-sparsify: If reporting bugs, run virt-sparsify with debugging enabled (-v) and include the complete output. --------end-------- So the output can be a block device, but not a char device. Verified.
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-1444.html