qemu
v1.1.1
Documentation
pkg.go.dev ↗Package qemu provides an implementation of a Driver driver for job execution. This driver uses the SSH driver to achieve job execution.
Functions
GetExpectedArch
func GetExpectedArch() string
GetExpectedArch returns the QEMU arch that would be expected for the GOARCH.
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.
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
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.
Config.Apply
func (cfg *Config) Apply(d runner.Driver)
Config.Merge
func (cfg *Config) Merge(m map[string]string) driver.Config
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.
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.
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.
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.