Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't parse qcow2 file: Malformed qcow2 file: header is 112 bytes, file claims 112 #4

Open
Sjord opened this issue May 11, 2021 · 9 comments

Comments

@Sjord
Copy link

Sjord commented May 11, 2021

I created an image using qemu-img create -f qcow2 hda.qcow2 5G and installed Debian. When I run qcow2-fuse -d -f hda.qcow2 mount, it gives the error:

Can't parse qcow2 file: Malformed qcow2 file: header is 112 bytes, file claims 112

I am using MacOS 11.3.1.

$ qemu-img info hda.qcow2
image: hda.qcow2
file format: qcow2
virtual size: 5 GiB (5368709120 bytes)
disk size: 1.51 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false
@ghost
Copy link

ghost commented May 14, 2021

Hi,

I am having the same issue running Arch Linux.

$ qemu-img info disk.qcow2
image: disk.qcow2
file format: qcow2
virtual size: 24 GiB (25769803776 bytes)
disk size: 1.18 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false

@Sjord
Copy link
Author

Sjord commented May 15, 2021

Error originates here.

        let actual_length = io.position();
        try!(self.read_extensions(io));
...
        if self.v3.header_length as u64 != actual_length {
            return Err(Error::FileFormat(format!("header is {} bytes, file claims {}",
                                                 io.position(),
                                                 self.v3.header_length)));
        }

It compares header_length with actual_length, but prints header_length and io.position(). Line 249 assigns io.position() to actual_length, but apparently the io.position() changes after that. My guess is because of read_extensions.

@corwin-of-amber
Copy link

@Sjord thanks for finding these! Did you find a fix as well? Would swapping the first two lines work?

@Sjord
Copy link
Author

Sjord commented Dec 2, 2021

No, unfortunately I didn't find a fix for this.

@corwin-of-amber
Copy link

corwin-of-amber commented Dec 2, 2021

Commenting out the check worked 😆 And I was able to mount an underlying ext4 filesystem using ext4fuse (on masOS).

So perhaps it's just the check that's wrong... Maybe it should be this?

        if self.v3.header_length as u64 != io.position() {

corwin-of-amber added a commit to corwin-of-amber/qcow2-rs that referenced this issue Dec 3, 2021
twz123 added a commit to twz123/k0s-libvirt-machines that referenced this issue Mar 15, 2022
@ShadowJonathan
Copy link

I have this same problem

@xycainoff
Copy link

having same issue
macos 13.4.1

@avlec
Copy link

avlec commented Jul 21, 2023

Encountering on MacOS 13.3.1 (a)
Do we have any idea at a solution @vasi ?

@preland
Copy link

preland commented Jul 25, 2023

Just encountered this issue as well; idk what's causing it, but I am guessing its an issue of mismatched types or a failure to convert between types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants