NAME

App::FuguVM::Guest - the lifecycle of one OpenBSD virtual machine

SYNOPSIS

use App::FuguVM::Guest;

my $vm = App::FuguVM::Guest->new(
    config => $config->load_vm('default'),
    state  => $state,
    log    => $log,
);

exit $vm->up;

DESCRIPTION

The module runs QEMU for an OpenBSD guest, installs the system on the first run, and stops it again without corrupting its disk.

Everything that is not QEMU comes from Fugu. Processes and liveness come from Fugu::Process, which reaps: a QEMU that became a zombie reads as stopped, and a caller that is about to start a second one needs that answer. Bounded waits come from Fugu::Timeout. The random root password comes from Fugu::Random. The guest connection comes from Fugu::SSH.

METHODS

new

App::FuguVM::Guest->new(config => \%vm, state => $state, log => $log, ...)

Build a controller. emulate forces TCG instead of hardware acceleration; no_cache ignores the installed-image cache.

up

Make sure the VM runs, and do whatever that needs: verify the backing chain, check the disk after an unclean shutdown, restore from the installed-image cache, start the proxy, download the miniroot, create the disk, start QEMU, install OpenBSD, and install the SSH key.

The method is idempotent. A VM that already runs, and whose SSH key is current, returns success and changes nothing.

down, destroy, start, stop, status

down stops the proxy and then the VM, gracefully, and records a clean shutdown. destroy stops it and deletes the disk. start and stop are the narrow forms that do not touch the proxy. status reports the state.

wait_ssh, ssh_port, console_port, is_running

wait_ssh polls until the guest takes an authenticated connection; with a password argument it authenticates with that password instead of the SSH agent. console_port is the port that telnet reaches the serial console on.

SHUTDOWN

A shutdown syncs the guest filesystems first, then asks the guest to power off through ACPI, and only then forces the process to stop. Every step is bounded: a guest that stops answering must not hold the caller.

The order matters. A force stop of a guest with unwritten buffers leaves a filesystem that the next boot has to repair.

SEE ALSO

Fugu::Process, Fugu::SSH, Fugu::Timeout, App::FuguVM::Disk, App::FuguVM::DiskCache, App::FuguVM::QMP, App::FuguVM::State, fuguvm(1)

AUTHOR

Dick Olsson <hi@senzilla.io>