vmdk

package
v0.0.0-...-79a645e Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Magic           = 0x564d444b
	SectorSize      = 0x200
	GrainSize       = 0x10000
	SectorsPerGrain = GrainSize / SectorSize
	TableMaxRows    = 512
	TableRowSize    = 4
	TableSectors    = TableMaxRows * TableRowSize / SectorSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EOSMarker

type EOSMarker struct {
	Val  uint64
	Size uint32
	Type uint32
	Pad  [496]byte
}

EOSMarker marks the end of the stream-optimized VMDK.

type Header struct {
	MagicNumber        uint32 // 0
	Version            uint32 // 4
	Flags              uint32 // 8
	Capacity           uint64 // 12
	GrainSize          uint64 // 20
	DescriptorOffset   uint64 // 28
	DescriptorSize     uint64 // 36
	NumGTEsPerGT       uint32 // 44
	RGDOffset          uint64 // 48
	GDOffset           uint64 // 56
	OverHead           uint64 // 64
	UncleanShutdown    byte   // 72
	SingleEndLineChar  byte   // 73
	NonEndLineChar     byte   // 74
	DoubleEndLineChar1 byte   // 75
	DoubleEndLineChar2 byte   // 76
	CompressAlgorithm  uint16 // 77
	Pad                [433]uint8
}

type HolePredictor

type HolePredictor interface {
	Size() int64
	RegionIsHole(begin, size int64) bool
}

type Sizer

type Sizer interface {
	Size() int64
}

Sizer is an interface that shouldn't exist in a vacuum, but does because our other image formats follow a similar patten and need more information. A Sizer should return the true and final RAW size of the image and be callable before the first byte of data is written to the Writer. Note that our vimg.Builder implements this interface and is the intended argument in most cases.

type SparseWriter

type SparseWriter struct {
	// contains filtered or unexported fields
}

func NewSparseWriter

func NewSparseWriter(w io.WriteSeeker, h HolePredictor) (*SparseWriter, error)

func (*SparseWriter) Close

func (w *SparseWriter) Close() error

func (*SparseWriter) Seek

func (w *SparseWriter) Seek(offset int64, whence int) (int64, error)

func (*SparseWriter) Write

func (w *SparseWriter) Write(p []byte) (int, error)

type StreamOptimizedWriter

type StreamOptimizedWriter struct {
	// contains filtered or unexported fields
}

StreamOptimizedWriter implements io.Closer, io.Writer, and io.Seeker interfaces. Creating a stream-optimized VMDK image is as simple as getting one of these writers and copying a raw image into it.

func NewStreamOptimizedWriter

func NewStreamOptimizedWriter(w io.WriteSeeker, h Sizer) (*StreamOptimizedWriter, error)

NewStreamOptimizedWriter returns a StreamOptimizedWriter to which a RAW image can be copied in order to create an XVA format disk image. The Sizer 'h' must accurately return the true and final RAW size of the image.

func (*StreamOptimizedWriter) Close

func (w *StreamOptimizedWriter) Close() error

Close implements io.Closer.

func (*StreamOptimizedWriter) Seek

func (w *StreamOptimizedWriter) Seek(offset int64, whence int) (int64, error)

Seek implements io.Seeker.

func (*StreamOptimizedWriter) Write

func (w *StreamOptimizedWriter) Write(p []byte) (int, error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

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