RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
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:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1458 0 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.