image

package
v1.59.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 23 Imported by: 11

Documentation

Index

Constants

View Source
const (
	// ExtImg is a constant for the .img extenstion
	ExtImg = ".img"
	// ExtIso is a constant for the .iso extenstion
	ExtIso = ".iso"
	// ExtGz is a constant for the .gz extenstion
	ExtGz = ".gz"
	// ExtQcow2 is a constant for the .qcow2 extenstion
	ExtQcow2 = ".qcow2"
	// ExtVmdk is a constant for the .vmdk VMware extenstion
	ExtVmdk = ".vmdk"
	// ExtVdi is a constant for the .vdi VirtualBox extenstion
	ExtVdi = ".vdi"
	// ExtVhd is a constant for the .vhd Microsoft Virtual Server Virtual Hard Disk extenstion
	ExtVhd = ".vhd"
	// ExtVhdx is a constant for the .vhd Hyper-V Virtual Hard Disk V.2 extenstion
	ExtVhdx = ".vhdx"
	// ExtTar is a constant for the .tar extenstion
	ExtTar = ".tar"
	// ExtXz is a constant for the .xz extenstion
	ExtXz = ".xz"
	// ExtZst is a constant for the .zst extenstion
	ExtZst = ".zst"
	// ExtTarXz is a constant for the .tar.xz extenstion
	ExtTarXz = ExtTar + ExtXz
	// ExtTarGz is a constant for the .tar.gz extenstion
	ExtTarGz = ExtTar + ExtGz
)
View Source
const MaxExpectedHdrSize = 512

MaxExpectedHdrSize defines the Size of buffer used to read file headers. Note: this is the size of tar's header. If a larger number is used the tar unarchive operation

creates the destination file too large, by the difference between this const and 512.

Variables

This section is empty.

Functions

func ConvertToRawStream added in v1.8.0

func ConvertToRawStream(url *url.URL, dest string, preallocate bool) error

ConvertToRawStream converts an http accessible image to raw format without locally caching the image

func CreateBlankImage added in v1.4.0

func CreateBlankImage(dest string, size resource.Quantity, preallocate bool) error

CreateBlankImage creates empty raw image

func PreallocateBlankBlock added in v1.30.0

func PreallocateBlankBlock(dest string, size resource.Quantity) error

PreallocateBlankBlock writes requested amount of zeros to block device mounted at dest

func Resize added in v1.29.0

func Resize(image string, size resource.Quantity, preallocate bool) error

Resize resizes the given image to size

func Validate

func Validate(url *url.URL, availableSize int64) error

Validate does basic validation of a qemu image

Types

type Header struct {
	Format string

	SizeOff int // in bytes
	SizeLen int // in bytes
	// contains filtered or unexported fields
}

Header represents our parameters for a file format header

func (Header) Match

func (h Header) Match(b []byte) bool

Match performs a check to see if the provided byte slice matches the bytes in our header data

func (Header) Size

func (h Header) Size(b []byte) (int64, error)

Size uses the Header receiver offset and length fields to extract, from the passed-in file header slice (b), the size of the original file. It is not guaranteed that the header is known to cdi and thus 0 may be returned as the size.

type Headers

type Headers map[string]Header

Headers provides a map for header info, key is file format, eg. "gz" or "tar", value is metadata describing the layout for this hdr

func CopyKnownHdrs

func CopyKnownHdrs() Headers

CopyKnownHdrs performs a simple map copy since := assignment copies the reference to the map, not contents.

type ImgInfo added in v1.4.0

type ImgInfo struct {
	// Format contains the format of the image
	Format string `json:"format"`
	// BackingFile is the file name of the backing file
	BackingFile string `json:"backing-filename"`
	// VirtualSize is the disk size of the image which will be read by vm
	VirtualSize int64 `json:"virtual-size"`
	// ActualSize is the size of the qcow2 image
	ActualSize int64 `json:"actual-size"`
}

ImgInfo contains the virtual image information.

func Info added in v1.29.0

func Info(url *url.URL) (*ImgInfo, error)

Info returns information about the image from the url

type Nbdkit added in v1.29.0

type Nbdkit struct {
	NbdPidFile string

	Socket     string
	Env        []string
	LogWatcher NbdkitLogWatcher
	// contains filtered or unexported fields
}

Nbdkit represents struct for an nbdkit instance

func NewNbdkit added in v1.29.0

func NewNbdkit(plugin NbdkitPlugin, nbdkitPidFile string) *Nbdkit

NewNbdkit creates a new Nbdkit instance with an nbdkit plugin and pid file

func (*Nbdkit) AddEnvVariable added in v1.32.0

func (n *Nbdkit) AddEnvVariable(v string)

AddEnvVariable adds an environmental variable to the nbdkit command

func (*Nbdkit) AddFilter added in v1.29.0

func (n *Nbdkit) AddFilter(filter NbdkitFilter)

AddFilter adds a nbdkit filter if it doesn't already exist

func (*Nbdkit) KillNbdkit added in v1.32.0

func (n *Nbdkit) KillNbdkit() error

KillNbdkit stops the nbdkit process

func (*Nbdkit) StartNbdkit added in v1.32.0

func (n *Nbdkit) StartNbdkit(source string) error

StartNbdkit starts nbdkit process

type NbdkitFilter added in v1.29.0

type NbdkitFilter string

NbdkitFilter represents s filter for nbdkit

const (
	NbdkitXzFilter           NbdkitFilter = "xz"
	NbdkitTarFilter          NbdkitFilter = "tar"
	NbdkitGzipFilter         NbdkitFilter = "gzip"
	NbdkitRetryFilter        NbdkitFilter = "retry"
	NbdkitCacheExtentsFilter NbdkitFilter = "cacheextents"
	NbdkitReadAheadFilter    NbdkitFilter = "readahead"
)

Nbdkit filters

type NbdkitLogWatcher added in v1.34.3

type NbdkitLogWatcher interface {
	Start(*bufio.Reader)
	Stop()
}

NbdkitLogWatcher allows custom handling of nbdkit log messages

type NbdkitOperation added in v1.32.0

type NbdkitOperation interface {
	StartNbdkit(source string) error
	KillNbdkit() error
	AddEnvVariable(v string)
	AddFilter(filter NbdkitFilter)
}

NbdkitOperation defines the interface for executing nbdkit

func NewMockNbdkitCurl added in v1.32.0

func NewMockNbdkitCurl(nbdkitPidFile, user, password, certDir, socket string, extraHeaders, secretExtraHeaders []string) NbdkitOperation

NewMockNbdkitCurl creates a mock nbdkit curl plugin for testing

func NewNbdkitCurl added in v1.29.0

func NewNbdkitCurl(nbdkitPidFile, user, password, certDir, socket string, extraHeaders, secretExtraHeaders []string) NbdkitOperation

NewNbdkitCurl creates a new Nbdkit instance with the curl plugin

func NewNbdkitVddk added in v1.32.0

func NewNbdkitVddk(nbdkitPidFile, socket, server, username, password, thumbprint, moref string) (NbdkitOperation, error)

NewNbdkitVddk creates a new Nbdkit instance with the vddk plugin

type NbdkitPlugin added in v1.29.0

type NbdkitPlugin string

NbdkitPlugin represents a plugin for nbdkit

const (
	NbdkitCurlPlugin     NbdkitPlugin = "curl"
	NbdkitFilePlugin     NbdkitPlugin = "file"
	NbdkitVddkPlugin     NbdkitPlugin = "vddk"
	NbdkitVddkMockPlugin NbdkitPlugin = "/opt/testing/libvddk-test-plugin.so"
)

Nbdkit plugins

type QEMUOperations

type QEMUOperations interface {
	ConvertToRawStream(*url.URL, string, bool) error
	Resize(string, resource.Quantity, bool) error
	Info(url *url.URL) (*ImgInfo, error)
	Validate(*url.URL, int64) error
	CreateBlankImage(string, resource.Quantity, bool) error
	Rebase(backingFile string, delta string) error
	Commit(image string) error
}

QEMUOperations defines the interface for executing qemu subprocesses

func NewQEMUOperations

func NewQEMUOperations() QEMUOperations

NewQEMUOperations returns the default implementation of QEMUOperations

Jump to

Keyboard shortcuts

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