Bug 695881

Summary: virt-make-fs generates qemu-img command line containing decimal point: "qemu-img: Invalid image size specified!"
Product: Red Hat Enterprise Linux 6 Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1CC: jzheng, leiwang, mbooth, qwan, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.7.17-19.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 10:31:43 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:
Attachments:
Description Flags
build.log none

Description Richard W.M. Jones 2011-04-12 20:58:52 UTC
Created attachment 491585 [details]
build.log

Description of problem:

test-virt-make-fs: parameters: --type=ext2 --format=qcow2 --partition=gpt  --debug
test-virt-make-fs: size of test file: 4437 KB
4437+0 records in
4437+0 records out
4543488 bytes (4.5 MB) copied, 0.013313 s, 341 MB/s
input format = POSIX tar archive (GNU)
estimate = 4546560 bytes (4440 1K blocks, 1110 4K blocks)
qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for 
qemu-img: kilobytes, megabytes, gigabytes and terabytes.
qemu-img create: failed to create disk image, see earlier error messages
FAIL: test-virt-make-fs.sh

Version-Release number of selected component (if applicable):

libguestfs 1.7.17 (from RHEL 6)

How reproducible:

?

Comment 1 Richard W.M. Jones 2011-04-13 15:24:45 UTC
Not reproducible with libguestfs 1.11.0, qemu-img 0.14.0-4.fc15.

Not reproducible with libguestfs 1.7.17-17, qemu-img-0.12.1.2-2.120.el6.

However it *fails* with qemu-img-0.12.1.2-2.158.el6.

This is because we are generating a qemu-img command line like this:

  qemu-img create -f qcow2 output.img 5289574.4

Notice the incorrect decimal space in the output.  Old qemu-img
used to ignore that, but the qemu-img with backports from upstream
no longer ignores this but gives an error instead.

This has already been fixed upstream in the commits below.  We
need to backport these commits for RHEL 6.2.

commit eda9826d25336bcf661700270c580d4d62128750
Author: Richard W.M. Jones <rjones>
Date:   Fri Mar 4 12:13:32 2011 +0000

    virt-make-fs: Round disk size to integer, fix for qemu-img 0.14.
    
    qemu-img used to allow you to specify a fractional image size in bytes
    (or at least, it used to ignore the part after the decimal place).  In
    qemu-img 0.14 it no longer does this so we round down the size to a
    whole number of bytes.

commit 29b3ffdad5d6774f988fd0e25f9c8242e5dd577a
Author: Richard W.M. Jones <rjones>
Date:   Fri Mar 4 12:13:12 2011 +0000

    virt-make-fs: In debug mode, print qemu-img command line.

Comment 2 Richard W.M. Jones 2011-04-13 15:29:07 UTC
Reproducer:

dd if=/dev/zero of=test.file bs=1024 count=4437
tar -c -f test.tar test.file
virt-make-fs --type=ext2 --format=qcow2 --partition=gpt --debug -- \
  test.tar output.img
rm test.tar output.img test.file

With the broken virt-make-fs you'll get an error like this:

input format = POSIX tar archive (GNU)
estimate = 4546560 bytes (4440 1K blocks, 1110 4K blocks)
qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for 
qemu-img: kilobytes, megabytes, gigabytes and terabytes.
qemu-img create: failed to create disk image, see earlier error messages

If virt-make-fs is working you should see the command completing:

input format = POSIX tar archive (GNU)
estimate = 4546560 bytes (4440 1K blocks, 1110 4K blocks)
running: qemu-img create -f qcow2 output.img 5289574
Formatting 'output.img', fmt=qcow2 size=5289574 encryption=off cluster_size=0 
starting libguestfs ...
creating ext2 filesystem on /dev/sda1 ...
reading directly from test.tar
Before uploading ...
$VAR1 = {
          'bsize' => 1024,
          'bfree' => 4902,
          'blocks' => 4935,
          'files' => 1280,
          'flag' => 4096,
          'favail' => 1269,
          'bavail' => 4647,
          'ffree' => 1269,
          'namemax' => 255,
          'frsize' => 1024,
          'fsid' => '-2236784364615602695'
        };
Uploading from test.tar to / ...
After uploading ...
$VAR1 = {
          'bsize' => 1024,
          'bfree' => 446,
          'blocks' => 4935,
          'files' => 1280,
          'flag' => 4096,
          'favail' => 1268,
          'bavail' => 191,
          'ffree' => 1268,
          'namemax' => 255,
          'frsize' => 1024,
          'fsid' => '-2236784364615602695'
        };
finishing off

Comment 3 Richard W.M. Jones 2011-07-04 15:05:43 UTC
Upstream commit:
eda9826d25336bcf661700270c580d4d62128750

Comment 4 Richard W.M. Jones 2011-07-04 16:50:19 UTC
https://brewweb.devel.redhat.com/taskinfo?taskID=3462253

Comment 6 Jinxin Zheng 2011-07-07 09:41:24 UTC
Reproduced on libguestfs-1.7.17-17.el6 and qemu-img-0.12.1.2-2.160.el6, using the reproducer in comment 2.
The output is:

input format = POSIX tar archive (GNU)
estimate = 4546560 bytes (4440 1K blocks, 1110 4K blocks)
qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for 
qemu-img: kilobytes, megabytes, gigabytes and terabytes.
qemu-img create: failed to create disk image, see earlier error messages


On libguestfs-1.7.17-19.el6 the output is:

input format = POSIX tar archive (GNU)
estimate = 4546560 bytes (4440 1K blocks, 1110 4K blocks)
Formatting 'output.img', fmt=qcow2 size=5289574 encryption=off cluster_size=0 
starting libguestfs ...
Using CPU model "cpu64-rhel6"
creating ext2 filesystem on /dev/sda1 ...
reading directly from test.tar
Before uploading ...
$VAR1 = {
          'bsize' => 1024,
          'bfree' => 4902,
          'blocks' => 4935,
          'files' => 1280,
          'flag' => 0,
          'favail' => 1269,
          'bavail' => 4647,
          'ffree' => 1269,
          'namemax' => 255,
          'frsize' => 1024,
          'fsid' => '-6520943318142091501'
        };
Uploading from test.tar to / ...
After uploading ...
$VAR1 = {
          'bsize' => 1024,
          'bfree' => 446,
          'blocks' => 4935,
          'files' => 1280,
          'flag' => 0,
          'favail' => 1268,
          'bavail' => 191,
          'ffree' => 1268,
          'namemax' => 255,
          'frsize' => 1024,
          'fsid' => '-6520943318142091501'
        };
finishing off


So this is verified.

Comment 7 errata-xmlrpc 2011-12-06 10:31:43 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-2011-1512.html