Try to reduce number of shell callouts to the bare minimum.
It's slightly more ugly but use setvar to set return values where possible.
Over the top 1000-round testing showed almost a second for $(), and near instant
for setvar. The following functions now take a variable name and set that rather than
echo'ing the response, so can be called inline rather than via $().
__switch_get_ident
__config_get
__vm_running_check
__vm_find_console
__vm_get_disk_path
Also use ${var%%} & ${var##} to parse slot/func numbers from passthru devices rather
than callout to echo/cut.
Add some (admittedly php style) comments to each function to explain what they
do, arguments, and what they output. Useful for anyone who's trying to figure
out how things work and why certain things are done.
Get rid of '-' on the end of the name - Just use $ in grep to make sure we get an entire match
Will need to keep additional search for '{name}-' for now as existing switches may have old style names
until a reboot.
Remove interfaces from configuration first otherwise you have to manually edit configuration if
ifconfig command doesn't complete for any reason.
Hide ifconfig errors and just produce our own messages when things don't work correctly
Replace spaces with tabs
Change __nat_init function name to match other functions in the switch library
Completely rewrite guest support, making vm-core logic much cleaner
Guests are now supported via the lib/vm-guest library
Each guest has a function which unifies the install/run logic in once place rather than two.
Loaders now run in the background; Not 100% ideal in some cases but better for most.
This also fixes the small tap0 issue which will now only present itself if you start a guest
with no networking
All guests need more testing with these changes but should be functional.
Simplify main script and move functions into independent libraries.
Add a Makefile to install everything to the correct places.
Add an initial man page.