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

Implement block status interface for raw image #44

Open
nirs opened this issue Nov 3, 2024 · 0 comments
Open

Implement block status interface for raw image #44

nirs opened this issue Nov 3, 2024 · 0 comments

Comments

@nirs
Copy link
Member

nirs commented Nov 3, 2024

#38 implements this only for qcow2, which is good enough for lima use case, but users of the library that that want read sparse raw file (or backing file) efficiently need a real implementation.

This can be implemented with SEEK_DATA and SEEK_HOLE seek flags:
https://github.com/qemu/qemu/blob/92ec7805190313c9e628f8fc4eb4f932c15247bd/block/file-posix.c#L3190

Can be done using unix.Seek:
https://pkg.go.dev/golang.org/x/sys/unix#Seek
https://cs.opensource.google/go/x/sys/+/refs/tags/v0.26.0:unix/zerrors_linux.go;l=3007
https://cs.opensource.google/go/x/sys/+/refs/tags/v0.26.0:unix/zerrors_darwin_arm64.go;l=1280

If the flags are not available or the Seek fails, the implementation can fallback to report an allocated cluster, which is less efficient but correct.

Possible use of this functionality is Go implementation of blkhash:
https://gitlab.com/nirs/blkhash/-/issues/103

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

1 participant