qcow2

package module
v0.0.0-...-93afc73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 9 Imported by: 1

README

qcow2

Go Reference

Package qcow2 provides read-only access to qcow2 disk images, including images with deflate or zstd compression.

Documentation

Overview

Package qcow2 provides read-only access to qcow2 disk images, including images with deflate or zstd compression. Writing qcow2 images is not supported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Image

type Image struct {
	// Stats are incremented by the library during reads. Exporting
	// them to expvar, Prometheus, or other monitoring systems is
	// left to the caller.
	Stats
	// contains filtered or unexported fields
}

Image is a read-only qcow2 disk image. It implements io.ReaderAt over the virtual disk contents.

func Open

func Open(r io.ReaderAt) (*Image, error)

Open opens a qcow2 image for reading. The returned *Image is safe for concurrent use.

func (*Image) ReadAt

func (img *Image) ReadAt(p []byte, off int64) (int, error)

ReadAt reads from the virtual disk image at the given offset. It implements io.ReaderAt.

func (*Image) Size

func (img *Image) Size() int64

Size returns the virtual size of the disk image in bytes.

type Stats

type Stats struct {
	Reads              expvar.Int // number of ReadAt calls
	BytesRead          expvar.Int // total virtual bytes returned
	ClusterReads       expvar.Int // total cluster-level read operations
	ClusterHoles       expvar.Int // reads served from unallocated or zero clusters
	ClusterStandard    expvar.Int // reads served from standard (uncompressed) clusters
	ClusterCompressed  expvar.Int // reads served from compressed clusters
	L2CacheHits        expvar.Int // L2 table found in cache
	L2CacheMisses      expvar.Int // L2 table read from underlying reader
	L2CacheEvictions   expvar.Int // L2 cache full clears
	CompCacheHits      expvar.Int // decompressed cluster found in cache
	CompCacheMisses    expvar.Int // cluster required decompression
	CompCacheEvictions expvar.Int // decompressed cluster cache full clears
}

Stats contains counters for an Image. All fields are safe for concurrent access.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL