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

package vm

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

Package vm provides virtual machine abstractions for QEMU.


Package Files

doc.go image.go machine.go network.go options.go vm.go


var MachineOptionsSchema = schematypes.Object{
    Title: "Machine Options",
    Description: util.Markdown("" /* 184 byte string literal not displayed */,
    Properties: schematypes.Properties{
        "maxMemory": schematypes.Integer{
            Title: "Max Memory",
            Description: util.Markdown("" /* 239 byte string literal not displayed */,
            Minimum: 0,
            Maximum: 1024 * 1024,
        "maxCores": schematypes.Integer{
            Title: "Max CPU Cores",
            Description: util.Markdown("" /* 311 byte string literal not displayed */,
            Minimum: 1,
            Maximum: 255,
    Required: []string{

MachineOptionsSchema is the schema for MachineOptions.

type Image Uses

type Image interface {
    DiskFile() string // Primary disk file to be used as boot disk.
    Format() string   // Image format 'qcow2', 'raw', etc.
    Machine() Machine // Machine configuration.
    Release()         // Free resources held by this image instance.

An Image provides an instance of a virtual machine image that a virtual machine can be started from.

type Machine Uses

type Machine struct {
    UUID   string `json:"uuid"`
    Memory int    `json:"memory,omitempty"`
    CPU    struct {
        Threads int `json:"threads,omitempty"`
        Cores   int `json:"cores,omitempty"`
        Sockets int `json:"sockets,omitempty"`
    }   `json:"cpu"`
    Network struct {
        Device string `json:"device"`
        MAC    string `json:"mac"`
    }   `json:"network"`
    Keyboard struct {
        Layout string `json:"layout"`
    }   `json:"keyboard"`
    Sound *struct {
        Device     string `json:"device"`
        Controller string `json:"controller"`
    }   `json:"sound,omitempty"`

Machine specifies arguments for various QEMU options.

This only allows certain arguments to be specified.

func LoadMachine Uses

func LoadMachine(machineFile string) (*Machine, error)

LoadMachine will load machine definition from file

func (*Machine) Clone Uses

func (m *Machine) Clone() *Machine

Clone returns a copy of this machine definition

func (Machine) Options Uses

func (m Machine) Options() MachineOptions

Options will return a set of MachineOptions that allows the current machine definition, and otherwise contains sane defaults. This is for utilities only.

func (*Machine) SetDefaults Uses

func (m *Machine) SetDefaults(options MachineOptions) error

SetDefaults will validate limitations and set defaults from options

func (*Machine) Validate Uses

func (m *Machine) Validate() error

Validate returns a MalformedPayloadError if the Machine definition isn't valid and legal.

type MachineOptions Uses

type MachineOptions struct {
    MaxMemory int `json:"maxMemory"`
    MaxCores  int `json:"maxCores"`

MachineOptions specifies the limits on the virtual machine limits, default values and options.

type MutableImage Uses

type MutableImage interface {
    Package(targetFile string) error // Package the as zstd compressed tar archive

A MutableImage is an instance of a virtual machine image similar to to Image, except that it can also be packaged into a compressed image tar archive as used for input by image manager.

type Network Uses

type Network interface {
    NetDev(ID string) string         // Argument for the QEMU -netdev option
    SetHandler(handler http.Handler) // Set http.Handler for
    Release()                        // Release the network after use

A Network provides a -netdev argument for QEMU, isolation and an HTTP server that will handle requests for Ensuring that the requests orignates from the virtual machine wit hthe -netdev argument.

type VirtualMachine Uses

type VirtualMachine struct {
    Done  <-chan struct{} // Closed when the virtual machine is done
    Error error           // Error, to be read after Done is closed
    // contains filtered or unexported fields

VirtualMachine holds the QEMU process and associated resources. This is useful as the VM remains alive in the ResultSet stage, as we use guest tools to copy files from the virtual machine.

func NewVirtualMachine Uses

func NewVirtualMachine(
    machineOptions MachineOptions,
    image Image, network Network, socketFolder, cdrom1, cdrom2 string,
    monitor runtime.Monitor,
) (*VirtualMachine, error)

NewVirtualMachine constructs a new virtual machine using the given machineOptions, image, network and cdroms.

Returns engines.MalformedPayloadError if machineOptions and image definition are conflicting. If this returns an error, caller is responsible for releasing all resources, otherwise, they will be held by the VirtualMachine object.

func (*VirtualMachine) Kill Uses

func (vm *VirtualMachine) Kill()

Kill the virtual machine, can only be called after Start()

func (*VirtualMachine) Screenshot Uses

func (vm *VirtualMachine) Screenshot() (image.Image, error)

Screenshot takes a screenshot of the virtual machine screen as is running.

func (*VirtualMachine) SetHTTPHandler Uses

func (vm *VirtualMachine) SetHTTPHandler(handler http.Handler)

SetHTTPHandler sets the HTTP handler for the meta-data service.

func (*VirtualMachine) Start Uses

func (vm *VirtualMachine) Start()

Start the virtual machine.

func (*VirtualMachine) VNCSocket Uses

func (vm *VirtualMachine) VNCSocket() string

VNCSocket returns the path to VNC socket, empty-string if closed.

Package vm imports 25 packages (graph) and is imported by 4 packages. Updated 2017-05-09. Refresh now. Tools for package owners.