fakemachine

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 21 Imported by: 12

README

fakemachine - fake a machine

Creates a virtual machine based on the currently running system.

Synopsis

fakemachine [options] <command to run inside machine>
fakemachine [--help]

Application Options:

  -b, --backend=[auto|kvm|uml|qemu] Virtualisation backend to use (default: auto)
  -v, --volume=                     volume to mount
  -i, --image=                      image to add
  -e, --environ-var=                Environment variables (use -e VARIABLE:VALUE syntax)
  -m, --memory=                     Amount of memory for the fakemachine in megabytes
  -c, --cpus=                       Number of CPUs for the fakemachine
  -s, --scratchsize=                On-disk scratch space size (with a unit suffix, e.g. 4G); if unset,
                                    memory backed scratch space is used
      --show-boot                   Show boot/console messages from the fakemachine

Help Options:
  -h, --help                        Show this help message

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackendNames

func BackendNames() []string

A list of backends which are implemented - sorted in order in which the * "auto" backend chooses them.

func GzipDecompressor

func GzipDecompressor(dst io.Writer, src io.Reader) error

func InMachine

func InMachine() (ret bool)

func NullDecompressor

func NullDecompressor(dst io.Writer, src io.Reader) error

func Supported

func Supported() bool

Check whether the auto backend is supported

func XzDecompressor

func XzDecompressor(dst io.Writer, src io.Reader) error

func ZstdDecompressor

func ZstdDecompressor(dst io.Writer, src io.Reader) error

Types

type Arch added in v0.0.5

type Arch string
const (
	Amd64 Arch = "amd64"
	Arm64 Arch = "arm64"
)

type Machine

type Machine struct {
	Environ []string
	// contains filtered or unexported fields
}

func NewMachine

func NewMachine() (*Machine, error)

Create a new machine object with the auto backend

func NewMachineWithBackend

func NewMachineWithBackend(backendName string) (*Machine, error)

Create a new machine object

func (*Machine) AddVolume

func (m *Machine) AddVolume(directory string)

AddVolume mounts directory from the host at the same location in the fake machine

func (*Machine) AddVolumeAt

func (m *Machine) AddVolumeAt(hostDirectory, machineDirectory string)

AddVolumeAt mounts hostDirectory from the host at machineDirectory in the fake machine

func (*Machine) CreateImage

func (m *Machine) CreateImage(imagepath string, size int64) (string, error)

CreateImage does the same as CreateImageWithLabel but lets the library pick the label.

func (*Machine) CreateImageWithLabel

func (m *Machine) CreateImageWithLabel(path string, size int64, label string) (string,
	error)

CreateImageWithLabel creates an image file at path a given size and exposes it in the fake machine using the given label as the serial id. If size is -1 then the image should already exist and the size isn't modified.

label needs to be less then 20 characters due to limitations from qemu

The returned string is the device path of the new image as seen inside fakemachine.

func (*Machine) Run

func (m *Machine) Run(command string) (int, error)

Run creates the machine running the given command

func (*Machine) RunInMachine

func (m *Machine) RunInMachine() (int, error)

RunInMachine runs the caller binary inside the fakemachine with the same commandline arguments as the parent

func (*Machine) RunInMachineWithArgs

func (m *Machine) RunInMachineWithArgs(args []string) (int, error)

RunInMachineWithArgs runs the caller binary inside the fakemachine with the specified commandline arguments

func (*Machine) SetEnviron

func (m *Machine) SetEnviron(environ []string)

func (*Machine) SetMemory

func (m *Machine) SetMemory(memory int)

SetMemory sets the fakemachines amount of memory (in megabytes). Defaults to 2048 MB

func (*Machine) SetNumCPUs

func (m *Machine) SetNumCPUs(numcpus int)

SetNumCPUs sets the number of CPUs exposed to the fakemachine. Defaults to the number of available cores in the system.

func (*Machine) SetQuiet added in v0.0.4

func (m *Machine) SetQuiet(quiet bool)

SetQuiet sets whether fakemachine should print additional information (e.g. the command to be ran) or just print the stdout/stderr of the command to be ran.

func (*Machine) SetScratch

func (m *Machine) SetScratch(scratchsize int64, path string)

SetScratch sets the size and location of on-disk scratch space to allocate (sparsely) for /scratch. If not set /scratch will be backed by memory. If Path is "" then the working directory is used as a default storage location

func (*Machine) SetShowBoot

func (m *Machine) SetShowBoot(showBoot bool)

SetShowBoot sets whether to show boot/console messages from the fakemachine.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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