file reports negative size for QCOW images

Bug #198232 reported by Adam Buchbinder
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
file (Debian)
Fix Released
Unknown
file (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: file

To reproduce:

$ qemu-img create -f qcow test.qcow 2G
Formatting 'test.qcow', fmt=qcow, size=2097152 kB
$ file test.qcow
test.qcow: QEMU Copy-On-Write disk image version 1, size 0 + -2147483648

The size is a 64-bit number (described in the spec http://www.gnome.org/~markmc/qcow-image-format.html as "uint64_t size; /* in bytes */"); it is unsigned, and so it should show up as a positive number rather than wrapping around for numbers above 2^32-1.

I am running file 4.21-1 on Ubuntu Gutsy.

Revision history for this message
Adam Buchbinder (adam-buchbinder) wrote :

This seems to have gotten worse. The output is now:

 test.qcow: Qemu Image, Format: Qcow , Version: 1 , Disk Size could be: 0 * 256 bytes

The number reported for disk size does not vary with the actual size of the image. qcow2-format images don't have any estimated size reported at all.

This is file 4.23-2 downloaded from the Intrepid repository and running on Gutsy. (I manually specified the just-built magic file.)

Changed in file:
status: Unknown → New
Revision history for this message
Jeff Buchbinder (rufustfirefly) wrote :

Packages:
$ dpkg -l | grep qemu
ii kqemu-common 1.3.0~pre11-8 Common files for the QEMU Accelerator module
ii kqemu-modules-2.6.22-14-generic 1.3.0~pre11-6+2.6.22-14.52 kqemu modules for Linux (kernel 2.6.22-14-gene
ii kqemu-modules-2.6.24-16-generic 1.3.0~pre11-8+2.6.24-16.30 kqemu modules for Linux (kernel 2.6.24-16-gene
ii kqemu-source 1.3.0~pre11-8 Source for the QEMU Accelerator module
ii qemu 0.9.1-1ubuntu1 fast processor emulator
$ uname -r
2.6.24-17-generic
$
Currently running Ubuntu 8.04 with all current updates, backports and security updates, except kernel.

Debug:
$ qemu-img create -f qcow test.qcow 2G
Formatting 'test.qcow', fmt=qcow, size=2097152 kB
$ file test.qcow
test.qcow: QEMU Copy-On-Write disk image version 1, size 0 + -2147483648
$ qemu-img create -f qcow2 test.qcow 2G
Formatting 'test.qcow', fmt=qcow2, size=2097152 kB
$ file test.qcow
test.qcow: QEMU Copy-On-Write disk image version 2, size 0 + -2147483648
$

Changed in file:
status: New → Confirmed
Revision history for this message
Adam Buchbinder (adam-buchbinder) wrote :

Attached find essentially the same debdiff I sent to Debian; it just has the version number in it changed, and the changelog entry refers to the Launchpad bug number rather than the Debian one. Apart from that, it's the same patch.

As I said on the Debian bugtracker, I ran into two non-critical issues. First, the backing-file name isn't stored in a NUL-terminated format; pretending that it's NUL-terminated seems to work, but since I couldn't figure out how to specify a string length based on an indirect value, it's not being done the *right* way. Second, The offset to the backing-file name in qcow2 images is a 64-bit quantity, but there's no way to put in a 64-bit offset. I cheated and assumed that the top four bytes are zero; this works on newly-created images, at least, though I can't guarantee that it'll work in the general case.

Changed in file (Debian):
status: New → Fix Released
Changed in file (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.