Bug 1218934

Summary: virt-sparsify: read all the output from 'qemu-img --help'
Product: Red Hat Enterprise Linux 6 Reporter: Pino Toscano <ptoscano>
Component: libguestfsAssignee: Pino Toscano <ptoscano>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.6CC: huzhan, leiwang, linl, ptoscano, tlavigne, wshi, xchen
Target Milestone: rcKeywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.20.11-16.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-10 19:55:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1301844    

Description Pino Toscano 2015-05-06 08:34:09 UTC
Description of problem:
It seems like `qemu-img --help` may just crash when being run by virt-sparsify to determine its version, causing virt-sparsify to fail.
A workaround to this situation seems to be reading all the output instead of just the first line of it. This does not apply to RHEL 7.1+, as a newer qemu is required and thus there is no need to get the qemu-img version.

Version-Release number of selected component (if applicable):
libguestfs-1.20.11-13.el6 

How reproducible:
Running virt-sparsify, sometimes.

Expected results:
virt-sparsify works.

Comment 2 Pino Toscano 2015-11-10 13:02:46 UTC
This was actually a workaround for what was actually bug #1233292.  Hence not relevant nor needed anymore.

Comment 3 Pino Toscano 2015-11-12 12:18:11 UTC
Actually I take it back: `qemu-img --help` seems to not like much when closing stdout for it while it is still running (that is, closing the process after reading only the first line of its lengthy output.

So yes, we need to read its output to not get into troubles.

Comment 5 Xianghua Chen 2015-12-02 06:10:16 UTC
Verified with the packages:
libguestfs-1.20.11-16.el6.x86_64

Verify steps:
# guestfish -N fs

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> quit

# virt-sparsify test1.img  outdisk.img -x -v
......
guestfsd: main_llibguestfs: recv_from_daemon: 40 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 01 1a | 00 00 00 01 | 00 12 34 0d | ...
libguestfs: trace: internal_autosync = 0
libguestfs: sending SIGTERM to process 17063
libguestfs: trace: shutdown = 0
libguestfs: trace: close
libguestfs: closing guestfs handle 0x1e13d50 (state 0)
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /tmp/libguestfswvXl1p
Copy to destination and make sparse ...
qemu-img convert -f qcow2 -O 'raw' '/tmp/sparsify28214f.qcow2' './outdisk.img'
Sparsify operation completed with no errors.  Before deleting the old 
disk, carefully check that the target disk boots and works correctly.

Repeat the command above for several times, there is no error occurred. 
Can also refer to bug #1233292 which has been fixed, and this bug will be fixed too.


So verified.

Comment 7 errata-xmlrpc 2016-05-10 19:55:58 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.

https://rhn.redhat.com/errata/RHBA-2016-0762.html