vmm

package module
v0.0.0-...-21d4a55 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: MPL-2.0 Imports: 15 Imported by: 0

README

packer-builder-vmm

This is an OpenBSD VMM plugin for packer.

Installation

Execute the following command to install this plugin:

go get -u github.com/prep/packer-builder-vmm/cmd/packer-builder-vmm

Then move the newly built ~/go/bin/packer-builder-vmm binary to either ~/.packer.d/plugins or in place it in the directory you're going to run packer build from.

Notes

  • It is assumed that you run packer as an unprivileged user and that doas can be used to start vmctl.
  • For now, instances will only be started with a local network interface. The ability to attach a network interface to a virtual switch will be added later.
  • The HTTP server, provisioning and post-processors are current unsupported, so everything has to be packed into the boot_command.
  • The Alpine example needs VM networking to be set up for local interfaces. The vmctl manpage section about local interfaces has some examples on getting that working.

Example

This project has a couple of example packer configurations in the examples directory, like an Alpine Linux 3.8.1 installation and an OpenBSD 6.4 installation. Let's demonstrate what building the OpenBSD example looks like. First, issue the packer build command:

packer build examples/openbsd.json

The build process will create a logfile of what's happening behind the scenes, that you can follow by tailing it in another terminal. This is useful to detect timing errors (commands being issued too soon, etc) or configuration errors in your build script:

tail -f output-vmm/openbsd-example.log

When the build is done, packer should have left you a output-vmm/openbsd-example.qcow2 bootable disk image of a clean OpenBSD installation, which you can immediately boot:

vmctl start openbsd-example -cL -d output-vmm/openbsd-example.qcow2

Hint

If you've built a qcow2 image as was done in the above example, you can also use it as a read-only base for a new image that only contains the changes written by the VM:

vmctl create new-vm.qcow2 -b output-vmm/openbsd-example.qcow2
vmctl start new-vm -cL -d new-vm.qcow2

Documentation

Index

Constants

View Source
const BuilderId = "prep.vmm"

BuilderId references the unique ID of this builder.

Variables

This section is empty.

Functions

This section is empty.

Types

type Artifact

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

Artifact contains references to the things that a build has created.

func (*Artifact) BuilderId

func (artifact *Artifact) BuilderId() string

BuilderId returns the ID of the builder that is used to create this artifact.

func (*Artifact) Destroy

func (artifact *Artifact) Destroy() error

Destroy this artifact.

func (*Artifact) Files

func (artifact *Artifact) Files() []string

Files returns a list of files in this artifact.

func (*Artifact) Id

func (artifact *Artifact) Id() string

Id of this artifact.

func (*Artifact) State

func (artifact *Artifact) State(name string) interface{}

State returns builder-specific state information.

func (*Artifact) String

func (artifact *Artifact) String() string

type Builder

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

Builder is responsible for create a machine and generating an image.

func (*Builder) Cancel

func (builder *Builder) Cancel()

Cancel the build process.

func (*Builder) Prepare

func (builder *Builder) Prepare(raws ...interface{}) ([]string, error)

Prepare the build configuration parameters.

func (*Builder) Run

func (builder *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error)

Run a packer build and returns a packer.Artifact representing a raw image.

type Config

type Config struct {
	common.PackerConfig    `mapstructure:",squash"`
	common.HTTPConfig      `mapstructure:",squash"`
	common.ISOConfig       `mapstructure:",squash"`
	bootcommand.BootConfig `mapstructure:",squash"`

	VMName    string `mapstructure:"vm_name"`
	BiosFile  string `mapstructure:"bios_file"`
	DiskSize  string `mapstructure:"disk_size"`
	Format    string `mapstructure:"format`
	MemSize   string `mapstructure:"mem_size"`
	OutputDir string `mapstructure:"output_directory"`
	// contains filtered or unexported fields
}

Config describes the configuration of this builder.

type Driver

type Driver interface {
	bootcommand.BCDriver

	CreateDisk(path, size string) error
	Start(name string, args ...string) error
	Stop(name string) error
}

Driver describes a VMM driver.

type VmmDriver

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

VmmDriver manages a vmm instance.

func (*VmmDriver) CreateDisk

func (driver *VmmDriver) CreateDisk(path, size string) error

CreateDisk creates a new disk image.

func (*VmmDriver) Flush

func (driver *VmmDriver) Flush() error

Flush doesn't do anything here.

func (*VmmDriver) SendKey

func (driver *VmmDriver) SendKey(key rune, action bootcommand.KeyAction) error

SendKey sends a key press.

func (*VmmDriver) SendSpecial

func (driver *VmmDriver) SendSpecial(special string, action bootcommand.KeyAction) error

SendSpecial sends a special character.

func (*VmmDriver) Start

func (driver *VmmDriver) Start(name string, args ...string) error

Start the VM and create a pipe to insert commands into the VM.

func (*VmmDriver) Stop

func (driver *VmmDriver) Stop(name string) error

Stop the VM and close down the input pipe.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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