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 1056556 - virt-sparsify overwrites block devices if used as output files
Summary: virt-sparsify overwrites block devices if used as output files
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 1056290 1062533 1062890 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)
7 users (show)

Fixed In Version: libguestfs-1.22.6-19.el7
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-06-13 11:53:15 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2014-01-22 13:11:41 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:43 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:13 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 3 bfan 2014-02-06 02:43:33 UTC
Reproduced with libguestfs-1.22.6-18.el7.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 Feb  6 10:39 /tmp/block
crw-r--r--. 1 root root 0, 0 Feb  6 10:39 /tmp/char

# virt-sparsify test1.img /tmp/block
qemu-img version 1.5
Create overlay file to protect source disk ...
Examine source disk ...
Fill free space in /dev/sda1 with zero ...
Copy to destination and make sparse ...
qemu-img: /tmp/block: error while converting raw: Could not open device: No such device or address
virt-resize: error: external command failed: qemu-img convert -f qcow2 
-O 'raw' '/tmp/sparsify892f5e.qcow2' '/tmp/block'

If reporting bugs, run virt-resize with the '-d' option and include the 
complete output.

# virt-sparsify test1.img /tmp/char
qemu-img version 1.5
Create overlay file to protect source disk ...
Examine source disk ...
Fill free space in /dev/sda1 with zero ...
Copy to destination and make sparse ...
qemu-img: /tmp/char: error while converting raw: Could not open device: No such device or address
virt-resize: error: external command failed: qemu-img convert -f qcow2 
-O 'raw' '/tmp/sparsify6c2b0d.qcow2' '/tmp/char'

If reporting bugs, run virt-resize with the '-d' option and include the 
complete output.

Comment 5 bfan 2014-02-10 08:10:51 UTC
Verified with libguestfs-1.22.6-19.el7.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 Feb 10 16:08 /tmp/block
crw-r--r--. 1 root root 0, 0 Feb 10 16:08 /tmp/char
# virt-sparsify test1.img /tmp/block
virt-resize: error: output '/tmp/block' cannot be a block device, it 
must be a regular file

If reporting bugs, run virt-resize with the '-d' option and include the 
complete output.


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

If reporting bugs, run virt-resize with the '-d' option and include the 
complete output.

Comment 6 Ludek Smid 2014-06-13 11:53:15 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.


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