vdisk

package
Version: v0.0.0-...-cd5610b Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllFormatStrings

func AllFormatStrings() []string

AllFormatStrings returns a list of all supported disk image formats.

func Build

func Build(ctx context.Context, w io.WriteSeeker, args *BuildArgs) error

Build writes a virtual disk image to w using the provided args.

func CreateBuilder

func CreateBuilder(ctx context.Context, args *vimg.BuilderArgs) (*vimg.Builder, error)

CreateBuilder creates a vimg.Builder with args provided.

func DeregisterFilesystemCompiler

func DeregisterFilesystemCompiler(name string) error

DeregisterFilesystemCompiler deregisters a FSCompilerInstantiator for the given name.

func FilesystemCompilers

func FilesystemCompilers() []string

FilesystemCompilers returns an alphabetised list of all registered file-system compilers. Note that a single compiler may appear multiple times in the list under different names.

func NegotiateSize

func NegotiateSize(ctx context.Context, vimgBuilder *vimg.Builder, cfg *vcfg.VCFG, args *BuildArgs) error

NegotiateSize prebuilds the minimum amount for a disk.

func NewFilesystemCompiler

func NewFilesystemCompiler(name string, log elog.Logger, tree vio.FileTree, args interface{}) (vimg.FSCompiler, error)

NewFilesystemCompiler returns a vimg.FSCompiler object that can be used to start a Vorteil image build, if the named file-system compiler has been registered.

func RegisterFilesystemCompiler

func RegisterFilesystemCompiler(name string, fn FSCompilerInstantiator) error

RegisterFilesystemCompiler registers a FSCompilerInstantiator with a given name.

func RegisterNewDiskFormat

func RegisterNewDiskFormat(format Format, extention string, alignment int64, mtu uint, builderFunc BuildWriterInstantiator) error

RegisterNewDiskFormat registers a new disk format that can be used with the vdisk package. Example: RegisterNewDiskFormat(Format("vmdk-custom"), ".vmdk", 0x200000, 1500, customVMDKBuilder)

Types

type BuildArgs

type BuildArgs struct {
	PackageReader    vpkg.Reader
	Format           Format
	SizeAlign        int64
	KernelOptions    KernelOptions
	Logger           elog.View
	WithVCFGDefaults bool
}

BuildArgs contains all arguments a caller can use to customize the behaviour of the Build function.

type BuildWriterInstantiator

type BuildWriterInstantiator func(io.WriteSeeker, *vimg.Builder, *vcfg.VCFG) (io.WriteSeeker, error)

BuildWriterInstantiator is a function that returns a new io.WriteSeeker that can be used to handle the writing of a raw image.

type FSCompilerInstantiator

type FSCompilerInstantiator func(log elog.Logger, tree vio.FileTree, args interface{}) (vimg.FSCompiler, error)

FSCompilerInstantiator is a function that returns a new file-system compiler when provided with common arguments (any uncommon arguments can be passed through 'args').

type Format

type Format string

Format is a string representing a supported disk image format.

const (
	// RAWFormat is a disk type that returns "raw"
	RAWFormat Format = "raw"
	// VMDKFormat is a disk type that returns "vmdk"
	VMDKFormat Format = "vmdk"
	// VMDKSparseFormat is a disk type that returns "vmdk-sparse"
	VMDKSparseFormat Format = "vmdk-sparse"
	// VMDKStreamOptimizedFormat is a disk type that returns "vmdk-stream-optimized"
	VMDKStreamOptimizedFormat Format = "vmdk-stream-optimized"
	// GCPFArchiveFormat is a disk type that returns "gcp"
	GCPFArchiveFormat Format = "gcp"
	// XVAFormat is a disk type that returns "xva"
	XVAFormat Format = "xva"
	// VHDFormat is a disk type that returns "vhd"
	VHDFormat Format = "vhd"
	// VHDFixedFormat is a disk type that returns "vhd-fixed"
	VHDFixedFormat Format = "vhd-fixed"
	// VHDDynamicFormat is a disk type that returns "vhd-dynamic"
	VHDDynamicFormat Format = "vhd-dynamic"
	// QCOW2Format is a disk type that returns "qcow2"
	QCOW2Format Format = "qcow2"
)

Supported disk image formats.

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat resolves a string into a Format.

func (*Format) Alignment

func (x *Format) Alignment() int64

Alignment returns a size in bytes that a RAW image must be aligned to (an integer multiple of) to be compatible with the virtual disk image format.

func (*Format) Build

func (x *Format) Build(ctx context.Context, log elog.View, w io.WriteSeeker, b *vimg.Builder, cfg *vcfg.VCFG) error

Build creates the disk for the correct format ...

func (*Format) DefaultMTU

func (x *Format) DefaultMTU() uint

DefaultMTU returns the default MTU setting for the image format.

func (Format) MarshalJSON

func (x Format) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Format) MarshalText

func (x Format) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler.

func (Format) String

func (x Format) String() string

String returns a string representation of the Format.

func (*Format) Suffix

func (x *Format) Suffix() string

Suffix returns an appropriate file extension for files containing the format.

func (*Format) UnmarshalJSON

func (x *Format) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Format) UnmarshalText

func (x *Format) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type KernelOptions

type KernelOptions struct {
	Record bool
	Shell  bool
}

KernelOptions contains all kernel configuration settings.

Jump to

Keyboard shortcuts

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