Documentation ¶
Index ¶
- Constants
- Variables
- func SetDecompressor(t CompressionType, d Decompressor)
- type AutoclearFeatures
- type CompatibleFeatures
- type CompressionType
- type CryptMethod
- type Decompressor
- type FeatureName
- type FeatureNameTableEntry
- type FeatureNameTableEntryType
- type Features
- type Header
- type HeaderExtension
- type HeaderExtensionType
- type HeaderFieldsAdditional
- type HeaderFieldsV2
- type HeaderFieldsV3
- type IncompatibleFeatures
- type MagicType
- type Namer
- type OffsetLengthPair64
- type Qcow2
Constants ¶
View Source
const ( CryptMethodNone = CryptMethod(0) CryptMethodAES = CryptMethod(1) CryptMethodLUKS = CryptMethod(2) )
View Source
const ( IncompatibleFeaturesDirtyBit = 0 IncompatibleFeaturesCorruptBit = 1 IncompatibleFeaturesExternalDataFileBit = 2 IncompatibleFeaturesCompressionTypeBit = 3 IncompatibleFeaturesExtendedL2EntriesBit = 4 )
View Source
const ( AutoclearFeaturesBitmapsExtensionBit = 0 AutoclearFeaturesRawExternalBit = 1 )
View Source
const ( // CompressionTypeZlib is a misnomer. It is actually deflate without zlib header. CompressionTypeZlib = CompressionType(0) CompressionTypeZstd = CompressionType(1) )
View Source
const ( HeaderExtensionTypeEnd = HeaderExtensionType(0x00000000) HeaderExtensionTypeBackingFileFormatNameString = HeaderExtensionType(0xe2792aca) HeaderExtensionTypeFeatureNameTable = HeaderExtensionType(0x6803f857) HeaderExtensionTypeBitmapsExtension = HeaderExtensionType(0x23852875) HeaderExtensionTypeFullDiskEncryptionHeaderPointer = HeaderExtensionType(0x0537be77) HeaderExtensionTypeExternalDataFileNameString = HeaderExtensionType(0x44415441) )
View Source
const ( FeatureNameTableEntryTypeIncompatible = FeatureNameTableEntryType(0) FeatureNameTableEntryTypeCompatible = FeatureNameTableEntryType(1) FeatureNameTableEntryTypeAutoclear = FeatureNameTableEntryType(2) )
View Source
const (
CompatibleFeaturesLazyRefcountsBit = 0
)
View Source
const Magic = "QFI\xfb"
Magic is the qcow2 magic string.
View Source
const Type = "qcow2"
Variables ¶
View Source
var ( ErrNotQcow2 = fmt.Errorf("%w: image is not qcow2", image.ErrWrongType) ErrUnsupportedBackingFile = errors.New("unsupported backing file") ErrUnsupportedEncryption = errors.New("unsupported encryption method") ErrUnsupportedCompression = errors.New("unsupported compression type") ErrUnsupportedFeature = errors.New("unsupported feature") )
View Source
var AutoclearFeaturesNames = []string{
"bitmaps",
"raw external data",
}
View Source
var CompatibleFeaturesNames = []string{
"lazy refcounts",
}
View Source
var IncompatibleFeaturesNames = []string{
"dirty bit",
"corrupt bit",
"external data file",
"compression type",
"extended L2 entries",
}
Functions ¶
func SetDecompressor ¶
func SetDecompressor(t CompressionType, d Decompressor)
SetDecompressor sets a custom decompressor. By default, flate.NewReader is registered for CompressionTypeZlib. No decompressor is registered by default for CompressionTypeZstd.
Types ¶
type AutoclearFeatures ¶
type AutoclearFeatures uint64
func (AutoclearFeatures) MarshalJSON ¶
func (x AutoclearFeatures) MarshalJSON() ([]byte, error)
type CompatibleFeatures ¶
type CompatibleFeatures uint64
func (CompatibleFeatures) MarshalJSON ¶
func (x CompatibleFeatures) MarshalJSON() ([]byte, error)
type CompressionType ¶
type CompressionType uint8
func (CompressionType) MarshalText ¶
func (x CompressionType) MarshalText() ([]byte, error)
func (CompressionType) String ¶
func (x CompressionType) String() string
type CryptMethod ¶
type CryptMethod uint32
func (CryptMethod) MarshalText ¶
func (x CryptMethod) MarshalText() ([]byte, error)
func (CryptMethod) String ¶
func (x CryptMethod) String() string
type Decompressor ¶
type Decompressor func(r io.Reader) (io.ReadCloser, error)
type FeatureName ¶
type FeatureName [46]byte
type FeatureNameTableEntry ¶
type FeatureNameTableEntry struct { Type FeatureNameTableEntryType `json:"type"` Bit uint8 `json:"bit"` Name string `json:"name"` }
type FeatureNameTableEntryType ¶
type FeatureNameTableEntryType uint8
func (FeatureNameTableEntryType) MarshalText ¶
func (x FeatureNameTableEntryType) MarshalText() ([]byte, error)
func (FeatureNameTableEntryType) String ¶
func (x FeatureNameTableEntryType) String() string
type Header ¶
type Header struct { HeaderFieldsV2 *HeaderFieldsV3 *HeaderFieldsAdditional }
type HeaderExtension ¶
type HeaderExtension struct { Type HeaderExtensionType `json:"type"` Length uint32 `json:"length"` Data interface{} `json:"data,omitempty"` }
type HeaderExtensionType ¶
type HeaderExtensionType uint32
func (HeaderExtensionType) MarshalText ¶
func (x HeaderExtensionType) MarshalText() ([]byte, error)
func (HeaderExtensionType) String ¶
func (x HeaderExtensionType) String() string
type HeaderFieldsAdditional ¶
type HeaderFieldsAdditional struct { CompressionType CompressionType `json:"compression_type"` // Pad is exposed to avoid `panic: reflect: reflect.Value.SetUint using value obtained using unexported field` during [binary.Read]. Pad [7]byte `json:"-"` }
type HeaderFieldsV2 ¶
type HeaderFieldsV2 struct { Magic MagicType `json:"magic"` Version uint32 `json:"version"` // 2 or 3 BackingFileOffset uint64 `json:"backing_file_offset"` // offset of file name (not null terminated) BackingFileSize uint32 `json:"backing_file_size"` // length of file name (<= 1023) ClusterBits uint32 `json:"cluster_bits"` Size uint64 `json:"size"` // Virtual disk size in bytes CryptMethod CryptMethod `json:"crypt_method"` L1Size uint32 `json:"l1_size"` // Number of entries L1TableOffset uint64 `json:"l1_table_offset"` // Offset into the image file RefcountTableOffset uint64 `json:"refcount_table_offset"` RefcountTableClusters uint32 `json:"refcount_table_clusters"` NbSnapshots uint32 `json:"nb_snapshots"` // Number of snapshots SnapshotsOffset uint64 `json:"snapshots_offset"` }
type HeaderFieldsV3 ¶
type HeaderFieldsV3 struct { IncompatibleFeatures IncompatibleFeatures `json:"incompatible_features"` CompatibleFeatures CompatibleFeatures `json:"compatible_features"` AutoclearFeatures AutoclearFeatures `json:"autoclear_features"` RefcountOrder uint32 `json:"refcount_order"` HeaderLength uint32 `json:"header_length"` }
type IncompatibleFeatures ¶
type IncompatibleFeatures uint64
func (IncompatibleFeatures) MarshalJSON ¶
func (x IncompatibleFeatures) MarshalJSON() ([]byte, error)
type MagicType ¶
type MagicType [4]byte
MagicType wraps magic bytes.
func (MagicType) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
type OffsetLengthPair64 ¶
type Qcow2 ¶
type Qcow2 struct { *Header `json:"header"` HeaderExtensions []HeaderExtension `json:"header_extensions"` BackingFile string `json:"backing_file"` BackingFileFullPath string `json:"backing_file_full_path"` BackingFileFormat image.Type `json:"backing_file_format"` // contains filtered or unexported fields }
Qcow2 implements image.Image.
func Open ¶
Open opens an qcow2 image.
To open an image with backing files, ra must implement Namer, and openWithType must be non-nil.
func (*Qcow2) ReadAt ¶
ReadAt implements io.ReaderAt.
Click to show internal directories.
Click to hide internal directories.