Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1056558 - virt-sparsify overwrites block devices if used as output files
Summary: virt-sparsify overwrites block devices if used as output files
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libguestfs
Version: 6.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Pino Toscano
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 1056290 1122557
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-22 13:11 UTC by Richard W.M. Jones
Modified: 2015-06-10 13:47 UTC (History)
9 users (show)

Fixed In Version: libguestfs-1.20.11-4.el6
Doc Type: Bug Fix
Doc Text:
As a result of the fix for BZ#1056558, it was not possible to use a block device for output when using the virt-sparsify utility. This update re-enables block devices to be used as ouput in virt-sparsify.
Clone Of: 1056290
Environment:
Last Closed: 2014-10-14 06:35:04 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1458 normal SHIPPED_LIVE libguestfs bug fix update 2014-10-14 01:10:57 UTC

Description Richard W.M. Jones 2014-01-22 13:11:43 UTC
+++ 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

Comment 1 Richard W.M. Jones 2014-01-22 13:12:35 UTC
Upstream fix is: 13bca32e4ec9213e69ea55e837dea846719fb67e
available in libguestfs >= 1.25.26 and >= 1.24.6.

Comment 2 Richard W.M. Jones 2014-01-22 13:21:17 UTC
A test of this is:

# Create an empty file to sparsify:
guestfish -N fs exit

# Create block & char device nodes in the filesystem:
mknod /tmp/block b 0 0
mknod /tmp/char c 0 0

You should have two dummy device nodes in /tmp:

$ ll /tmp/block /tmp/char
brw-r--r--. 1 root root 0, 0 Jan 22 13:16 /tmp/block
crw-r--r--. 1 root root 0, 0 Jan 22 13:16 /tmp/char

Run virt-sparsify like this:

virt-sparsify test1.img /tmp/block

and:

virt-sparsify test1.img /tmp/char

If these two commands run, and you see an error like:

qemu-img: /tmp/block: error while converting qcow2: No such device or address
virt-sparsify: error: external command failed: qemu-img convert -f 
qcow2 -O 'qcow2' '/tmp/sparsify011645.qcow2' '/tmp/block'

then that's bad (demonstrating the bug).

If the commands show a clean error like:

virt-sparsify: error: output '/tmp/block' cannot be a block device, it 
must be a regular file

then that's good (showing the bug is fixed).

Comment 4 bfan 2014-07-02 05:53:35 UTC
Verified with libguestfs-1.20.11-8.el6.x86_64

# guestfish -N fs exit
# mknod /tmp/block b 0 0
# mknod /tmp/char c 0 0
# ll /tmp/block /tmp/char
brw-r--r--. 1 root root 0, 0 Jul  2 13:42 /tmp/block
crw-r--r--. 1 root root 0, 0 Jul  2 13:42 /tmp/char

# virt-sparsify test1.img /tmp/block
virt-sparsify: error: output '/tmp/block' cannot be a block device, it 
must be a regular file

virt-sparsify: If reporting bugs, run virt-sparsify with debugging 
enabled (-v) and include the complete output.

# virt-sparsify test1.img /tmp/char
virt-sparsify: error: output '/tmp/char' 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.


Got the clean error message

Comment 5 errata-xmlrpc 2014-10-14 06:35: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.

http://rhn.redhat.com/errata/RHBA-2014-1458.html


Note You need to log in before you can comment on or make changes to this bug.