Documentation
¶
Overview ¶
Package qcow2 implements manage the QEMU qcow2 image format written in pure Go.
Index ¶
- Constants
- Variables
- func AllocClusters(bs *BlockDriverState, size uint64) (int64, error)
- func AllocClustersNoref(bs *BlockDriverState, size uint64) (int64, error)
- func BEUint16(b []byte) uint16
- func BEUint32(b []byte) uint32
- func BEUint64(b []byte) uint64
- func BEUvarint16(i uint16) []byte
- func BEUvarint32(i uint32) []byte
- func BEUvarint64(i uint64) []byte
- func BEUvarint8(i uint8) []byte
- func CreateFile(filename string, opts *BlockOption) (*os.File, error)
- func GetRefcountFunc(refcountArray map[uint64]uintptr, index uint64) uint64
- func MAX(a, b int) int
- func MIN(a, b int) int
- func Open(bs *BlockDriverState, options *QDict, flag int) error
- func PrintByte(buf []byte)
- func SetRefcountFunc(refcountArray map[uint64]uintptr, index uint64)
- type BDRVState
- type BdrvChild
- type BitmapExtension
- type BlockBackend
- type BlockDriver
- type BlockDriverInfo
- type BlockDriverState
- type BlockLimits
- type BlockOption
- type CLUSTER
- type Cache
- type CryptMethod
- type DiscardRegion
- type DiscardType
- type DriverFmt
- type Extension
- type Feature
- type FeatureNameTable
- type FeatureType
- type Header
- type HeaderExtensionType
- type Opt
- type OptDesc
- type OptType
- type Opts
- type OptsList
- type PreallocMode
- type QCow2
- type QDict
- type QObject
- type QType
- type QemuOpts
- type Snapshot
- type SnapshotExtraData
- type SnapshotHeader
- type Truncater
- type UnknownHeaderExtension
- type Version
Constants ¶
const ( BLK_DATA writeStatus = iota BLK_ZERO BLK_BACKING_FILE )
const ( // UINT16_SIZE results of sizeof(uint16_t) in C. UINT16_SIZE = 2 // UINT32_SIZE results of sizeof(uint32_t) in C. UINT32_SIZE = 4 // UINT64_SIZE results of sizeof(uint64_t) in C. UINT64_SIZE = 8 )
const ( // Version2HeaderSize is the image header at the beginning of the file. Version2HeaderSize = 72 // Version3HeaderSize is directly following the v2 header, up to 104. Version3HeaderSize = 104 )
const ( // CRYPT_NONE no encryption. CRYPT_NONE CryptMethod = iota // CRYPT_AES AES encryption. CRYPT_AES MAX_CRYPT_CLUSTERS = 32 MAX_SNAPSHOTS = 65536 )
const ( // indicate that the refcount of the referenced cluster is exactly one. OFLAG_COPIED = 1 << 63 // indicate that the cluster is compressed (they never have the copied flag) OFLAG_COMPRESSED = 1 << 62 // The cluster reads as all zeros OFLAG_ZERO = 1 << 0 )
const ( // MIN_CLUSTER_BITS minimum of cluster bits size. MIN_CLUSTER_BITS = 9 // MAX_CLUSTER_BITS maximum of cluster bits size. MAX_CLUSTER_BITS = 21 )
const ( // INCOMPAT_DIRTY_BITNR represents a incompatible dirty bit number. INCOMPAT_DIRTY_BITNR = 0 // INCOMPAT_CORRUPT_BITNR represents a incompatible corrupt bit number. INCOMPAT_CORRUPT_BITNR = 1 // INCOMPAT_DIRTY incompatible corrupt bit number. INCOMPAT_DIRTY = 1 << INCOMPAT_DIRTY_BITNR // INCOMPAT_CORRUPT incompatible corrupt bit number. INCOMPAT_CORRUPT = 1 << INCOMPAT_CORRUPT_BITNR // INCOMPAT_MASK mask of incompatible feature. INCOMPAT_MASK = INCOMPAT_DIRTY | INCOMPAT_CORRUPT )
const ( // COMPAT_LAZY_REFCOUNTS_BITNR represents a compatible dirty bit number. COMPAT_LAZY_REFCOUNTS_BITNR = 0 // COMPAT_LAZY_REFCOUNTS refcounts of lazy compatible. COMPAT_LAZY_REFCOUNTS = 1 << COMPAT_LAZY_REFCOUNTS_BITNR // COMPAT_FEAT_MASK mask of compatible feature. COMPAT_FEAT_MASK = COMPAT_LAZY_REFCOUNTS )
const ( L1E_OFFSET_MASK = uint64(72057594037927424) // 0x00fffffffffffe00ULL L2E_OFFSET_MASK = uint64(72057594037927424) // 0x00fffffffffffe00ULL L2E_COMPRESSED_OFFSET_SIZE_MASK = uint64(4611686018427387903) // 0x3fffffffffffffffULL REFT_OFFSET_MASK = uint64(1844674407370955110) // 0xfffffffffffffe00ULL )
const ( BDRV_BLOCK_DATA = 0x01 BDRV_BLOCK_ZERO = 0x02 BDRV_BLOCK_OFFSET_VALID = 0x04 BDRV_BLOCK_RAW = 0x08 BDRV_BLOCK_ALLOCATED = 0x10 )
const ( INT8_MAX = math.MaxInt8 // 127 INT16_MAX = math.MaxInt16 // 32767 INT32_MAX = math.MaxInt32 // 2147483647 INT64_MAX = math.MaxInt64 // 9223372036854775807LL INT_MAX = math.MaxInt32 // INT_MAX == INT32_MAX on darwin,amd64 )
const ( INT8_MIN = math.MinInt8 // -128 INT16_MIN = math.MinInt16 // -32768 // Note (from stdint.h): // the literal "most negative int" cannot be written in C -- // the rules in the standard (section 6.4.4.1 in C99) will give it // an unsigned type, so INT32_MIN (and the most negative member of // any larger signed type) must be written via a constant expression. INT32_MIN = math.MinInt32 // (-INT32_MAX-1) INT64_MIN = math.MinInt64 // (-INT64_MAX-1) )
const ( UINT8_MAX = math.MaxUint8 // 255 UINT16_MAX = math.MaxUint16 // 65535 UINT32_MAX = math.MaxUint32 // 4294967295U UINT64_MAX = math.MaxUint64 // 18446744073709551615ULL )
const BDRV_SECTOR_BITS = 9
const BLOCK_FLAG_ENCRYPT = 1
const BLOCK_FLAG_LAZY_REFCOUNTS = 8
const BLOCK_PROBE_BUF_SIZE = 512
const DEBUG_ALLOC2 = false
const DEFAULT_CLUSTER_SIZE = 65536
const DEFAULT_L2_CACHE_BYTE_SIZE = 1048576 // bytes
const DEFAULT_L2_CACHE_CLUSTERS = 8 // clusters
Whichever is more
const DEFAULT_L2_REFCOUNT_SIZE_RATIO = 4
DEFAULT_L2_REFCOUNT_SIZE_RATIO the refblock cache needs only a fourth of the L2 cache size to cover as many clusters.
const (
ENOMEDIUM = syscall.ENODEV
)
const IO_BUF_SIZE = (2 * 1024 * 1024)
const MAX_L1_SIZE = 0x2000000
MAX_L1_SIZE 32 MB L1 table is enough for 2 PB images at 64k cluster size (128 GB for 512 byte clusters, 2 EB for 2 MB clusters)
const MAX_REFTABLE_SIZE = 0x800000
MAX_REFTABLE_SIZE 8 MB refcount table is enough for 2 PB images at 64k cluster size (128 GB for 512 byte clusters, 2 EB for 2 MB clusters)
const MAX_SNAPSHOTS_SIZE = 1024 * MAX_SNAPSHOTS
Allow for an average of 1k per snapshot table entry, should be plenty of * space for snapshot names and IDs
const MIN_L2_CACHE_SIZE = 2 // clusters
MIN_L2_CACHE_SIZE must be at least 2 to cover COW.
const MIN_REFCOUNT_CACHE_SIZE = 4 // clusters
MIN_REFCOUNT_CACHE_SIZE must be at least 4 to cover all cases of refcount table growth.
const (
SIZE_MAX = math.MaxUint64 // #if __WORDSIZE == 64; UINT64_MAX; #else; #define SIZE_MAX UINT32_MAX; #endif
)
Variables ¶
var ( BDRV_SECTOR_SIZE = 1 << BDRV_SECTOR_BITS // (1ULL << BDRV_SECTOR_BITS) BDRV_SECTOR_MASK = ^(BDRV_SECTOR_SIZE - 1) // ~(BDRV_SECTOR_SIZE - 1) )
var BDRV_BLOCK_OFFSET_MASK = BDRV_SECTOR_MASK
var BDRV_REQUEST_MAX_SECTORS = MIN(SIZE_MAX>>BDRV_SECTOR_BITS, INT_MAX>>BDRV_SECTOR_BITS)
var MAGIC = []byte{0x51, 0x46, 0x49, 0xFB}
MAGIC qemu QCow(2) magic ("QFI\xfb").
#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
Functions ¶
func AllocClusters ¶
func AllocClusters(bs *BlockDriverState, size uint64) (int64, error)
func AllocClustersNoref ¶
func AllocClustersNoref(bs *BlockDriverState, size uint64) (int64, error)
func BEUvarint16 ¶
BEUvarint16 convert the uint16 type of varint(varying-length integer) to the binary data of big endian format byte order.
func BEUvarint32 ¶
BEUvarint32 convert the uint32 type of varint(varying-length integer) to the binary data of big endian format byte order.
func BEUvarint64 ¶
BEUvarint64 convert the uint64 type of varint(varying-length integer) to the binary data of big endian format byte order.
func BEUvarint8 ¶
BEUvarint8 convert the uint8 type of varint(varying-length integer) to the binary data of big endian format byte order.
func CreateFile ¶
func CreateFile(filename string, opts *BlockOption) (*os.File, error)
CreateFile creates the new file based by block driver backend.
func GetRefcountFunc ¶
GetRefcountFunc typedef uint64_t Qcow2GetRefcountFunc(const void *refcount_array, uint64_t index);
func Open ¶
func Open(bs *BlockDriverState, options *QDict, flag int) error
Open open the QCow2 block-backend image file. callgraph:
qemu-img.c:img_create -> bdrv_img_create -> bdrv_open -> bdrv_open_inherit -> bdrv_open_common -> drv->bdrv_open -> .bdrv_open = qcow2_open
func SetRefcountFunc ¶
SetRefcountFunc typedef void Qcow2SetRefcountFunc(void *refcount_array, uint64_t index, uint64_t value);
Types ¶
type BDRVState ¶
type BDRVState struct { ClusterBits int // int ClusterSize int // int ClusterSectors int // int L2Bits int // int L2Size int // int L1Size int // int L1VmStateIndex int // int RefcountBlockBits int // int RefcountBlockSize int // int Csize_shift int // int Csize_mask int // int ClusterOffsetMask uint64 // uint64_t L1TableOffset uint64 // uint64_t L1Table uint64 // uint64_t L2TableCache *Cache // *Qcow2Cache RefcountBlockCache *Cache // *Qcow2Cache // cache_clean_timer *QEMUTimer CacheCleanInterval uintptr // unsigned ClusterCache uint8 // uint8_t ClusterData uint8 // uint8_t ClusterCacheOffset uint64 // uint64_t // RefcountTable map[uint64]int64 // uint64_t RefcountTable [8][]byte // uint64_t RefcountTableOffset uint64 // uint64_t RefcountTableSize uint32 // uint32_t FreeClusterIndex uint64 // uint64_t FreeByteOffset uint64 // uint64_t // cipher *QCryptoCipher // current cipher, nil if no key yet CryptMethodHeader uint32 // uint32_t SnapshotsOffset uint64 // uint64_t SnapshotsSize int // int NbSnapshots uintptr // unsigend int Flags int // int Version Version // int UseLazyRefcounts bool // bool RefcountOrder int // int RefcountBits int // int RefcountMax uint64 // uint64_t GetRefcount func(refcountArray interface{}, index uint64) uint64 // *Qcow2GetRefcountFunc SetRefcount func(refcountArray interface{}, index uint64, value uint64) // *Qcow2SetRefcountFunc DiscardPassthrough bool // bool discard_passthrough[QCOW2_DISCARD_MAX] OverlapCheck int // int: bitmask of Qcow2MetadataOverlap values SignaledCorruption bool // bool IncompatibleFeatures uint64 // uint64_t CompatibleFeatures uint64 // uint64_t AutoclearFeatures uint64 // uint64_t UnknownheaderFieldsSize int // size_t UnknownHeaderFields []byte // void* // unknown_header_ext QLIST_HEAD(, Qcow2UnknownHeaderExtension) // discards QTAILQ_HEAD (, Qcow2DiscardRegion) CacheDiscards bool // bool // Backing file path and format as stored in the image (this is not the // effective path/format, which may be the result of a runtime option // override) ImageBackingFile string // char * ImageBackingFormat []byte // char * }
type BitmapExtension ¶
type BitmapExtension struct { // NbBitmaps the number of bitmaps contained in the image. Must be greater than ro equal to 1. [1:4] NbBitmaps int // Reserved reserved, must be zero. [4:8] Reserved int // BitmapDirectorySize size of the bitmap directory in bytes. It is the cumulative size of all (nb_bitmaps) bitmap headers. [8:16] BitmapDirectorySize int // BitmapDirectoryOffset offste into the image file at which the bitmap directory starts. [16:24] BitmapDirectoryOffset int }
BitmapExtension represents a optional header extension.
type BlockBackend ¶
type BlockBackend struct { File *os.File Header Header BlockDriverState *BlockDriverState Error error // contains filtered or unexported fields }
BlockBackend represents a backend of the QCow2 image format block driver.
func (*BlockBackend) Open ¶
func (blk *BlockBackend) Open(filename, reference string, options *BlockOption, flag int) error
Open open the QCow2 block-backend image file.
type BlockDriver ¶
type BlockDriver struct {
// contains filtered or unexported fields
}
BlockDriver represents a block driver.
type BlockDriverInfo ¶
type BlockDriverInfo struct {
// contains filtered or unexported fields
}
type BlockDriverState ¶
type BlockDriverState struct { TotalSectors int64 // int64_t: if we are reading a disk image, give its size in sectors OpenFlags int // int: flags used to open the file, re-used for re-open ReadOnly bool // bool: if true, the media is read only Encrypted bool // bool: if true, the media is encrypted ValidKey bool // bool: if true, a valid encryption key has been set SG bool // bool: if true, the device is a /dev/sg* (scsi-generic devices) Probed bool // bool: if true, format was probed rather than specified CopyOnRead int // int: if nonzero, copy read backing sectors into image. note this is a reference count. // flush_queue // CoQueue: Serializing flush queue // TODO // active_flush_req // *BdrvTrackedRequest: Flush request in flight // TODO WriteGen uint // unsigned int: Current data generation FlushedGen uint // unsigned int: Flushed write generation Drv *BlockDriver // BlockDriver *: NULL means no media Opaque *BDRVState // void * // long-running tasks intended to always use the same AioContext as this // BDS may register themselves in this list to be notified of changes // regarding this BDS's context // AioNotifiers QLIST_HEAD(, BdrvAioNotifier) // TODO WalkingAioNotifiers bool // bool: to make removal during iteration safe Filename string // char: filename[PATH_MAX] BackingFile string // char: if non zero, the image is a diff of this file image BackingFormat string // char: if non-zero and backing_file exists // FullOpenOptions *QDict // *QDict * TODO ExactFilename string // char: exact_filename[PATH_MAX] Backing *BdrvChild File *os.File // SerialisingInFlight number of in-flight serialising requests SerialisingInFlight uint // unsigned int // Offset after the highest byte written to WrHighestOffset uint64 // uint64_t // I/O Limits BL BlockLimits // unsigned int: Flags honored during pwrite (so far: BDRV_REQ_FUA) SupportedWriteFlags uint // unsigned int: Flags honored during pwrite_zeroes (so far: BDRV_REQ_FUA, *BDRV_REQ_MAY_UNMAP) SupportedZeroFlags uint // NodeName the following member gives a name to every node on the bs graph. NodeName string // char node_name[32] // NodeList element of the list of named nodes building the graph // NodeList QTAILQ_ENTRY(BlockDriverState) // TODO // BsList element of the list of all BlockDriverStates (all_bdrv_states) // BsList QTAILQ_ENTRY(BlockDriverState) // TODO // MonitorList element of the list of monitor-owned BDS // MonitorList QTAILQ_ENTRY(BlockDriverState) // TODO // DirtyBitmaps QLIST_HEAD(, BdrvDirtyBitmap) // TODO Refcnt int // int // The error object in use for blocking operations on backing_hd BackingBlocker error // threshold limit for writes, in bytes. "High water mark" WriteThresholdOffset uint64 // Counters for nested bdrv_io_plug and bdrv_io_unplugged_begin IOPlugged uintptr // unsigned: TODO IOPlugDisabled uintptr // unsigned: TODO QuiesceCounter int // int // contains filtered or unexported fields }
BlockDriverState represents a state of block driver.
Note: the function bdrv_append() copies and swaps contents of BlockDriverStates, so if you add new fields to this struct, please inspect bdrv_append() to determine if the new fields need to be copied as well.
type BlockLimits ¶
type BlockLimits struct { // RequestAlignment alignment requirement, in bytes, for offset/length of I/O // requests. Must be a power of 2 less than INT_MAX; defaults to // 1 for drivers with modern byte interfaces, and to 512 // otherwise. RequestAlignment uint32 // uint32_t // MaxPdiscard maximum number of bytes that can be discarded at once (since it // is signed, it must be < 2G, if set). Must be multiple of // pdiscard_alignment, but need not be power of 2. May be 0 if no // inherent 32-bit limit MaxPdiscard int32 // int32_t // PdiscardAlignment optimal alignment for discard requests in bytes. A power of 2 // is best but not mandatory. Must be a multiple of // bl.request_alignment, and must be less than max_pdiscard if // that is set. May be 0 if bl.request_alignment is good enough PdiscardAlignment uint32 // uint32_t // MaxPwriteZeroes maximum number of bytes that can zeroized at once (since it is // signed, it must be < 2G, if set). Must be multiple of // pwrite_zeroes_alignment. May be 0 if no inherent 32-bit limit MaxPwriteZeroes int32 // int32_t // PwriteZeroesAlignment optimal alignment for write zeroes requests in bytes. A power // of 2 is best but not mandatory. Must be a multiple of // bl.request_alignment, and must be less than max_pwrite_zeroes // if that is set. May be 0 if bl.request_alignment is good // enough PwriteZeroesAlignment uint32 // uint32_t // OptTransfer optimal transfer length in bytes. A power of 2 is best but not // mandatory. Must be a multiple of bl.request_alignment, or 0 if // no preferred size OptTransfer uint32 // uint32_t // MaxTransfer maximal transfer length in bytes. Need not be power of 2, but // must be multiple of opt_transfer and bl.request_alignment, or 0 // for no 32-bit limit. For now, anything larger than INT_MAX is // clamped down. MaxTransfer uint32 // uint32_t // MinMemAlignment memory alignment, in bytes so that no bounce buffer is needed MinMemAlignment uint32 // size_t // OptMemAlignment memory alignment, in bytes, for bounce buffer OptMemAlignment uint32 // size_t // MaxIov maximum number of iovec elements MaxIov int // int }
type BlockOption ¶
type BlockOption struct {
Driver BlockDriver
}
BlockOption represents a block options.
type CryptMethod ¶
type CryptMethod uint32
CryptMethod represents a whether encrypted qcow2 image. 0 for no enccyption 1 for AES encryption
func (CryptMethod) String ¶
func (cm CryptMethod) String() string
String implementations of fmt.Stringer.
type DiscardRegion ¶
type DiscardRegion struct { Bs *BlockDriverState Offset uint64 // uint64_t // contains filtered or unexported fields }
type DiscardType ¶
type DiscardType int
DiscardType represents a type of discard.
const ( // DISCARD_NEVER discard never. DISCARD_NEVER DiscardType = iota // DISCARD_ALWAYS discard always. DISCARD_ALWAYS // DISCARD_REQUEST discard request. DISCARD_REQUEST // DISCARD_SNAPSHOT discard snapshot. DISCARD_SNAPSHOT // DISCARD_OTHER discard other. DISCARD_OTHER // DISCARD_MAX discard max. DISCARD_MAX )
type Extension ¶
type Extension struct { Magic HeaderExtensionType // [:4] Header extension type Len uint32 // [4:8] Length of the header extension data }
Extension represents a optional header extension.
type FeatureNameTable ¶
type FeatureNameTable struct { // Type type of feature [0:1] Type int // BitNumber bit number within the selected feature bitmap [1:2] BitNumber int // FeatureName feature name. padded with zeros [2:48] FeatureName int }
FeatureNameTable represents a optional header extension that contains the name for features used by the image.
type FeatureType ¶
type FeatureType uint8
FeatureType represents a type of feature.
const ( // FEAT_TYPE_INCOMPATIBLE incompatible feature. FEAT_TYPE_INCOMPATIBLE FeatureType = iota // FEAT_TYPE_COMPATIBLE compatible feature. FEAT_TYPE_COMPATIBLE // FEAT_TYPE_AUTOCLEAR Autoclear feature. FEAT_TYPE_AUTOCLEAR )
type Header ¶
type Header struct { Magic uint32 // [0:3] magic: QCOW magic string ("QFI\xfb") Version Version // [4:7] Version number BackingFileOffset uint64 // [8:15] Offset into the image file at which the backing file name is stored. BackingFileSize uint32 // [16:19] Length of the backing file name in bytes. ClusterBits uint32 // [20:23] Number of bits that are used for addressing an offset whithin a cluster. Size uint64 // [24:31] Virtual disk size in bytes CryptMethod CryptMethod // [32:35] Crypt method L1Size uint32 // [36:39] Number of entries in the active L1 table L1TableOffset uint64 // [40:47] Offset into the image file at which the active L1 table starts RefcountTableOffset uint64 // [48:55] Offset into the image file at which the refcount table starts RefcountTableClusters uint32 // [56:59] Number of clusters that the refcount table occupies NbSnapshots uint32 // [60:63] Number of snapshots contained in the image SnapshotsOffset uint64 // [64:71] Offset into the image file at which the snapshot table starts IncompatibleFeatures uint64 // [72:79] for version >= 3: Bitmask of incomptible feature CompatibleFeatures uint64 // [80:87] for version >= 3: Bitmask of compatible feature AutoclearFeatures uint64 // [88:95] for version >= 3: Bitmask of auto-clear feature RefcountOrder uint32 // [96:99] for version >= 3: Describes the width of a reference count block entry HeaderLength uint32 // [100:103] for version >= 3: Length of the header structure in bytes }
Header represents a header of qcow2 image format.
type HeaderExtensionType ¶
type HeaderExtensionType uint32
HeaderExtensionType represents a indicators the the entries in the optional header area
const ( // HeaderExtensionEndOfArea End of the header extension area. HeaderExtensionEndOfArea HeaderExtensionType = 0x00000000 // HeaderExtensionBackingFileFormat Backing file format name. HeaderExtensionBackingFileFormat HeaderExtensionType = 0xE2792ACA // HeaderExtensionFeatureNameTable Feature name table. HeaderExtensionFeatureNameTable HeaderExtensionType = 0x6803f857 // HeaderExtensionBitmapsExtension Bitmaps extension. // TODO(zchee): qemu does not implements? HeaderExtensionBitmapsExtension HeaderExtensionType = 0x23852875 )
type OptType ¶
type OptType int
const ( OPT_STRING OptType = 0 // no parsing (use string as-is) OPT_BOOL // on/off OPT_NUMBER // simple number OPT_SIZE // size, accepts (K)ilo, (M)ega, (G)iga, (T)era postfix )
type Opts ¶
type Opts struct { // Filename filename of create image. Filename string // Fmt format of create image. Fmt DriverFmt // BaseFliename base filename of create image. BaseFilename string // BaseFmt base format of create image. BaseFmt string // BLOCK_OPT // Size size of create image virtual size. Size int64 // Encryption option is if this option is set to "on", the image is encrypted with 128-bit AES-CBC. Encryption bool // BackingFile file name of a base image (see create subcommand). BackingFile string // BackingFormat image format of the base image. BackingFormat string // ClusterSize option is changes the qcow2 cluster size (must be between 512 and 2M). // Smaller cluster sizes can improve the image file size whereas larger cluster sizes generally provide better performance. ClusterSize int TableSize int // Preallocation mode of pre-allocation metadata (allowed values: "off", "metadata", "falloc", "full"). // An image with preallocated metadata is initially larger but can improve performance when the image needs to grow. // "falloc" and "full" preallocations are like the same options of "raw" format, but sets up metadata also. Preallocation PreallocMode SubFormat string // Compat QCow2 image format compatible. "compat=0.10": uses the traditional image format that can be read by any QEMU since 0.10. // "compat=1.1": enables image format extensions that only QEMU 1.1 and newer understand (this is the default). Compat string // LazyRefcounts option is if this option is set to "on", reference count updates are postponed with the goal of avoiding metadata I/O and improving performance. // This is particularly interesting with cache=writethrough which doesn't batch metadata updates. // The tradeoff is that after a host crash, the reference count tables must be rebuilt, // i.e. on the next open an (automatic) "qemu-img check -r all" is required, which may take some time. // This option can only be enabled if "compat=1.1" is specified. LazyRefcounts bool // LazyRefcounts Avoiding metadata I/O and improving performance with the postponed updates reference count. AdapterType string Redundancy bool // NoCow option is if this option is set to "on", it will turn off COW of the file. It's only valid on btrfs, no effect on other file systems. // Btrfs has low performance when hosting a VM image file, even more when the guest on the VM also using btrfs as file system. // Turning off COW is a way to mitigate this bad performance. Generally there are two ways to turn off COW on btrfs: a) // Disable it by mounting with nodatacow, then all newly created files will be NOCOW. b) // For an empty file, add the NOCOW file attribute. That's what this option does. // Note: this option is only valid to new or empty files. // If there is an existing file which is COW and has data blocks already, it couldn't be changed to NOCOW by setting "nocow=on". // One can issue "lsattr filename" to check if the NOCOW flag is set or not (Capital 'C' is NOCOW flag). NoCow bool ObjectSize int RefcountBits int }
Opts options of the create qcow2 image format.
type PreallocMode ¶
type PreallocMode int
PreallocMode represents a mode of Pre-allocation feature.
const ( // PREALLOC_MODE_OFF turn off preallocation. PREALLOC_MODE_OFF PreallocMode = iota // PREALLOC_MODE_METADATA preallocation of metadata only mode. PREALLOC_MODE_METADATA // PREALLOC_MODE_FALLOC preallocation of falloc only mode. PREALLOC_MODE_FALLOC // PREALLOC_MODE_FULL full preallocation mode. PREALLOC_MODE_FULL // PREALLOC_MODE__MAX preallocation maximum preallocation mode. PREALLOC_MODE__MAX )
type QCow2 ¶
type QCow2 struct {
// contains filtered or unexported fields
}
QCow2 represents a QEMU QCow2 image format.
type SnapshotExtraData ¶
type SnapshotExtraData struct { }
SnapshotExtraData represents a extra data of snapshot.
type SnapshotHeader ¶
type SnapshotHeader struct { }
SnapshotHeader represents a header of snapshot.
type Truncater ¶
type Truncater interface {
Truncate(bs *BlockDriverState, offset int64) error
}
type UnknownHeaderExtension ¶
type UnknownHeaderExtension struct { Magic uint32 Len uint32 // Next QLIST_ENTRY(Qcow2UnknownHeaderExtension) Data []int8 }
UnknownHeaderExtension represents a unknown of header extension.