Documentation
¶
Overview ¶
Package vm provides an exec-like interface to VMs running cpud. It is designed to make running commands in a vm as easy as using exec.
For purposes of convenience, this package provides, via embed, a set of kernels and initramfs, for several architectures. Currently, it provides Linux kernels and initramfs for amd64, arm, arm64, and riscv64.
The kernels are minimal, hence small; but enable enough options to run cpud and u-root programs. The initramfs only contain the cpud and dhclient commands, and are also small.
The package asssumes that qemu for a target architecture is available on the system.
Users can not yet provide their own kernel and initramfs, though that is planned.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Image ¶
type Image struct {
Kernel []byte
InitRAMFS []byte
Cmd []string
Env []string
GOOS string
GOARCH string
Opts []string
// contains filtered or unexported fields
}
Image defines an image, including []byte for a kernel and initramfs; a []string for the Cmd and its args; and its environment; and a directory in which to run.
func New ¶
New creates an Image, using the kernel and arch to select the Image. It will return an error if there is a problem uncompressing the kernel and initramfs.
func (*Image) CPUCommand ¶
CPUCommand runs a command in a guest running cpud. It is similar to exec.Command, in that it accepts an arg and a set of optional args. It differs in that it can return an error. If there are no errors, it returns a client.Cmd. The returned client.Cmd can be called with CombinedOutput, to make it easier to scan output from a command for error messages.
func (*Image) CommandContext ¶
func (image *Image) CommandContext(ctx context.Context, d string, extra ...string) (*exec.Cmd, error)
CommandContext starts qemu, given a context, directory in which to run the command. The variadic arguments are a set of cpios which will be merged into Image.InitRAMFS. A typical use of the extra arguments will be to extend the initramfs; they are usually not needed.