App-FuguVM
view release on metacpan or search on metacpan
lib/App/FuguVM/State.pod view on Meta::CPAN
The VM name becomes a directory name, so it must be one safe path
component: no separator, no NUL byte, and not one of the two directory
entries. A name that is not returns C<undef> and a message in the log.
The method also returns C<undef> when the directory is a symlink, is
not a directory, or cannot be created.
=head2 load, save
Read and write the JSON state. C<new> loads. A corrupt file gives
empty state and does not stop the program that would rewrite it.
=head2 store, state_dir, vm_state_dir, vm_name, data
C<store> returns the L<Fugu::StateFile>. L<App::FuguVM::Guest> gives it to the
proxy, which keeps its port there.
C<state_dir> returns the directory that holds every VM's state, and
C<vm_state_dir> the one that holds this VM's. C<data> returns the
state hash reference for a caller that changes several keys at once.
=head2 vm_pidfile, proxy_pidfile, autoinstall_pidfile
Return the L<Fugu::Pidfile> objects. QEMU writes the first itself,
through its C<-pidfile> option; the proxy supervisor owns the second,
and the autoinstall responder supervisor owns the third. Each file
lives in the state directory of the guest, so an interrupted run
leaves no child that nothing owns.
=head2 get_vm_pid, clear_vm_pid, is_vm_running
The QEMU process. QEMU writes the pid file itself, through its
C<-pidfile> option, so there is no setter.
=head2 disk_path, disk_exists
The working disk of the VM.
=head2 set_runtime, get_runtime, clear_runtime
The runtime record: the facts of one run of one guest. The record
holds C<accel> and the resolved C<ssh_port> and C<console_port>.
L<App::FuguVM::Guest> writes it before it spawns QEMU, and reads it
back for C<status> and for the guest connections.
C<get_runtime> returns the facts as a hash reference, and an empty
hash reference when the guest never ran. The stop verbs call
C<clear_runtime> beside C<clear_vm_pid>, so the record dies with the
run. C<destroy> needs no call, because it empties the whole store.
=head2 is_installed, mark_installed, get_installed_arch
Whether OpenBSD is installed on the disk. An installed system boots
its own disk and never attaches the miniroot again.
C<mark_installed> takes the architecture of the installed disk. The
argument is required, so no path can forget it. C<get_installed_arch>
returns the recorded architecture, or C<undef>. L<App::FuguVM::Guest>
compares it with the configured value before it boots an existing
disk.
=head2 set_root_password, get_root_password
The password that the installer set. The store writes at mode 0600.
=head2 mark_ssh_key_installed, get_installed_ssh_pubkey
Which SSH public key the guest holds. The state records the key
itself, not only that there is one. Thus a key that changed in the
configuration is installed again on the next C<fuguvm up>.
=head2 mark_running, mark_clean_shutdown, mark_unclean_shutdown, was_unclean_shutdown, clear_shutdown_state
Whether the last stop was clean. C<was_unclean_shutdown> also reports
true when the state says running and the process is gone: the VM
crashed or was killed, and the disk may need a check.
=head1 SEE ALSO
L<Fugu::Pidfile>, L<Fugu::StateFile>, L<App::FuguVM::Guest>
=head1 AUTHOR
Dick Olsson <hi@senzilla.io>
( run in 0.867 second using v1.01-cache-2.11-cpan-f5f21f1076c )