qemu

package
v1.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package qemu provides an implementation of a Driver driver for job execution. This driver uses the SSH driver to achieve job execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExpectedArch

func GetExpectedArch() string

GetExpectedArch returns the QEMU arch that would be expected for the GOARCH.

func Init

func Init(w io.Writer, cfg driver.Config) runner.Driver

Init initializes a new driver for QEMU using the given io.Writer, and applying the given driver.Config.

func MatchesGOARCH

func MatchesGOARCH(arch string) bool

MatchesGOARCH checks to see if the given QEMU arch matches the GOARCH. This is used by the worker to make sure that virtualization with KVM would be possible on the platform the worker is being run on.

Types

type Config

type Config struct {
	Arch   string // The architecture to use for virtualization.
	CPUs   int64  // The number of CPUs for the virtual machine.
	Memory int64  // The amount of memory in bytes for the virtual machine.
	Disks  string // The location to look for disk images.
	Image  string // The QCOW2 image to boot the virtual machine with.
}

Config is the struct used for initializing a new QEMU driver for build execution.

func (*Config) Apply

func (cfg *Config) Apply(d runner.Driver)

func (*Config) Merge

func (cfg *Config) Merge(m map[string]string) driver.Config

type Driver

type Driver struct {
	io.Writer

	Arch   string // Arch is the machine architecture that will be running the jobs.
	CPUs   int64  // CPUs specifies the number of CPUs to give the machine.
	Memory int64  // Memory specifies the amount of memory in bytes for the machine.
	Image  string // Image is the name of the QEMU image to use for the machine.

	// Realpath is a function callback that will return the full path of the
	// QCOW2 image to use when booting the Driver machine.
	Realpath realpathFunc
	// contains filtered or unexported fields
}

Driver provides an implementation of the runner.Driver interface for running jobs within a QEMU virtual machine. Under the hood this makes use of the ssh.Driver implementation to communicate with the virtual machine.

func (*Driver) Create

func (q *Driver) Create(c context.Context, env []string, objs runner.Passthrough, p runner.Placer) error

Create will boot a new Driver machine based on the configuration given via a previous call to Init. The Driver process will forward ports from the host to the guest to allow for SSH comms. The host port will be 2222, unless already taken in which case it will increment until all TCP ports have been exhausted.

func (*Driver) Destroy

func (q *Driver) Destroy()

Destroy will terminate the SSH connection to the Driver machine, and kill the underlying OS process, then will remove the PIDFILE for that process.

func (*Driver) Execute

func (q *Driver) Execute(j *runner.Job, c runner.Collector)

Execute will perform the given job on the Driver machine via a call to the underlying SSH driver.

Jump to

Keyboard shortcuts

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