taskcluster-worker: github.com/taskcluster/taskcluster-worker/engines/qemu/image Index | Files

package image

import "github.com/taskcluster/taskcluster-worker/engines/qemu/image"

Package image exposes methods and abstractions for extracting and managing virtual machine images. Amongst other things this involves securing that the images don't reference external files as backing store.

Index

Package Files

doc.go extract.go inspect.go manager.go mutableimage.go util.go

func RandomMAC Uses

func RandomMAC() string

RandomMAC generates a new random MAC with the local bit set.

type Downloader Uses

type Downloader func(imageFile string) error

Downloader is a function capable of downloading an image to an imageFile. The downloader writes the image file to the imageFile supplied, and returns an error if all retries etc. fails.

func DownloadImage Uses

func DownloadImage(url string) Downloader

DownloadImage returns a Downloader that will download the image from the given url. This will attempt multiple retries if necessary.

If there is a non-200 response this will return a MalformedPayloadError.

type Instance Uses

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

Instance represents an instance of an image.

func (*Instance) DiskFile Uses

func (i *Instance) DiskFile() string

DiskFile returns the qcow2 file this image instance is backed by.

func (*Instance) Format Uses

func (i *Instance) Format() string

Format returns the image format: 'qcow2'

func (*Instance) Machine Uses

func (i *Instance) Machine() vm.Machine

Machine returns the virtual machine configuration for this instance.

func (*Instance) Release Uses

func (i *Instance) Release()

Release frees the resources held by an instance.

type Manager Uses

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

Manager loads and tracks images.

func NewManager Uses

func NewManager(imageFolder string, gc gc.ResourceTracker, monitor runtime.Monitor) (*Manager, error)

NewManager creates a new image manager using the imageFolder for storing images and instances of images.

func (*Manager) Instance Uses

func (m *Manager) Instance(imageID string, download Downloader) (*Instance, error)

Instance will return an Instance of the image with imageID. If no such image exists in the cache, download() will be called to download it to a temporary filename.

This method will insert the downloaded image into the cache, and ensures that if won't be downloaded twice, if another invocation already is downloading an image with the same imageID.

It is the responsibility of the caller to make sure that imageID is a string that uniquely identifies the image. Sane patterns includes "url:<url>", or "taskId:<taskId>/<runId>/<artifact>". It also the callers responsibility to enforce any sort of access control.

type MutableImage Uses

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

MutableImage is an vm.MutableImage implementation that keeps the image in a single folder. This can be used for testing images and building new images.

func NewMutableImage Uses

func NewMutableImage(folder string, size int, machine *vm.Machine) (*MutableImage, error)

NewMutableImage creates a new blank MutableImage of given size in GiB, and using the given machine configuration.

This is used when building new images.

func NewMutableImageFromFile Uses

func NewMutableImageFromFile(imageFile, imageFolder string) (*MutableImage, error)

NewMutableImageFromFile creates a mutable image from an existing compressed image tar archive.

func (*MutableImage) DiskFile Uses

func (img *MutableImage) DiskFile() string

DiskFile returns path to disk file to use in QEMU. This also marks the image as being in-use.

func (*MutableImage) Dispose Uses

func (img *MutableImage) Dispose()

Dispose will delete all resources hold by the MutableImage

func (*MutableImage) Format Uses

func (img *MutableImage) Format() string

Format returns the image format: 'raw'.

func (*MutableImage) Machine Uses

func (img *MutableImage) Machine() vm.Machine

Machine returns the vm.Machine definition of the virtual machine.

func (*MutableImage) Package Uses

func (img *MutableImage) Package(targetFile string) error

Package will write an zstd compressed tar archive of the image to targetFile. This method cannot be called the image is in-use.

func (*MutableImage) Release Uses

func (img *MutableImage) Release()

Release marks the MutableImage as no longer in use. This allows Package() or Dispose() to be called.

Package image imports 18 packages (graph) and is imported by 3 packages. Updated 2017-03-13. Refresh now. Tools for package owners.