Skip to content

pkg/store/disk.go: inspectDiskSize does not need to fallback to qemu-img #3497

Closed
@AkihiroSuda

Description

@AkihiroSuda

lima/pkg/store/disk.go

Lines 64 to 82 in 1f787fb

// inspectDisk attempts to inspect the disk size and format by itself,
// and falls back to inspectDiskWithQemuImg on an error.
func inspectDisk(fName string) (size int64, format string, _ error) {
f, err := os.Open(fName)
if err != nil {
return inspectDiskWithQemuImg(fName)
}
defer f.Close()
img, err := qcow2reader.Open(f)
if err != nil {
return inspectDiskWithQemuImg(fName)
}
sz := img.Size()
if sz < 0 {
return inspectDiskWithQemuImg(fName)
}
return sz, string(img.Type()), nil
}

go-qcow2reader should suffice to inspect the disk size.

I don't remember why I added inspectDiskSizeWithQemuImg fall-back in 20c2224 . Probably go-qcow2reader was immature at that time

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions