Bug 679737

Summary: libguestfs: improve error message when zerofree is not available in the appliance
Product: Red Hat Enterprise Linux 6 Reporter: Jinxin Zheng <jzheng>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: jyang, leiwang, moli, yuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: libguestfs-1.16.5-1.el6 Doc Type: Bug Fix
Doc Text:
No Documentation needed
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 06:59:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jinxin Zheng 2011-02-23 11:36:12 UTC
Description of problem:
zerofree is unavailable in RHEL 6.

Version-Release number of selected component (if applicable):
libguestfs-1.7.17-14.el6

How reproducible:
Always

Steps to Reproduce:

$ guestfish
><fs> alloc test.img 100M
><fs> run
><fs> mkfs ext2 /dev/sda
><fs> zerofree /dev/sda
libguestfs: error: zerofree: /dev/vda: zerofree: No such file or directory

Comment 1 Richard W.M. Jones 2011-02-24 06:54:08 UTC
In some sense this is correct :-)

Try doing the following command in guestfish (requires the "run"
command to have been done first):

><fs> supported

At the end of the list you should see "zerofree no" indicating that
the zerofree command isn't available in the daemon.

Also:
http://libguestfs.org/guestfs.3.html#availability

However it may be that we need to either:
(1) Add zerofree as a new package to RHEL 6 (probably not
advisable, it's a rather experimental package which can destroy
filesystems if it is not used correctly)

(2) Improve the error message.

Anyway, this is a 6.2 thing I think, so I have reset the flags
to 6.2 ...

Comment 2 Jinxin Zheng 2011-02-24 08:00:57 UTC
Well. If zerofree is too dangerous to RHEL 6, why is it still in libguestfs since it could be impossibly available?

Some groups (like ntfs3g) are optional by providing a separate support package. But we'll never get zerofree. Shouldn't it be removed from libguestfs like in 6.0?

Comment 3 Richard W.M. Jones 2011-02-25 00:15:37 UTC
The problem is that if we remove the underlying API (ie.
guestfs_zerofree) then some programs wouldn't compile.

If programmers are following the documentation, then
they should be calling guestfs_available first before
using guestfs_zerofree, and they should also check the
return value from guestfs_zerofree for errors.

We could remove it leave it in the API but remove it from
guestfish, but that just makes guestfish irregular -- we
document that guestfish has an equivalent for every
libguestfs API call.

Also it is conceivable that a RHEL 6 user could prepare a
package containing zerofree + the relevant supermin
appliance changes which would transparently add zerofree
support back into libguestfs.  This is roughly what
libguestfs-winsupport does for ntfs-3g.

I don't think there is a good answer to this, although
improving the error message would be a good idea.

Comment 4 Richard W.M. Jones 2011-06-10 09:20:13 UTC
6.3 material, unless a customer complains about this.

zerofree is dangerous.  To add it to RHEL we'd need to
have the code fully and properly checked by Ric Wheeler
and friends.

Comment 5 Richard W.M. Jones 2012-02-01 11:21:31 UTC
Reproducer:

$ guestfish -N fs zerofree /dev/sda1
libguestfs: error: zerofree: /dev/vda1: zerofree: No such file or directory

Note this creates/overwrites a file in the current directory
called 'test1.img', so:

$ rm test1.img

Comment 6 Richard W.M. Jones 2012-02-01 12:21:55 UTC
Patch posted:

https://www.redhat.com/archives/libguestfs/2012-February/msg00000.html

Comment 7 Richard W.M. Jones 2012-02-01 15:13:38 UTC
Updated patch posted:

https://www.redhat.com/archives/libguestfs/2012-February/msg00002.html

Comment 8 Richard W.M. Jones 2012-02-01 16:07:10 UTC
Committed upstream:

https://github.com/libguestfs/libguestfs/commit/330fbea5b2d6bd7db84f7ea7afe87cf1bcd438e0

Comment 11 Richard W.M. Jones 2012-02-13 09:34:45 UTC
The patch is incomplete and causes the daemon to
segfault in some circumstances.  Patch posted to
fix that:

https://www.redhat.com/archives/libguestfs/2012-February/msg00057.html

Comment 12 Richard W.M. Jones 2012-02-13 15:42:58 UTC
Fix included in libguestfs 1.17.7:
https://github.com/libguestfs/libguestfs/commit/ba443ae0486ae30ea597c4e126de63371f8fa7a8
and this will be backported to 1.16 branch and RHEL 6.3.

Comment 13 Richard W.M. Jones 2012-02-13 17:51:56 UTC
The fix is included in upstream stable branch version
1.16.5, and in RHEL 6.3 build (same version).

Comment 17 Richard W.M. Jones 2012-04-26 12:15:13 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
No Documentation needed

Comment 19 errata-xmlrpc 2012-06-20 06:59:28 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-2012-0774.html