On Wed, Aug 20, 2014 at 8:15 AM, John Baldwin <j...@freebsd.org> wrote:
> It probably would be good to document the return codes in the man page, but
> eventually they will all go away.  The long term plan is to make bhyve operate
> more like other hypervisors in which case a single process invocation will
> mimic a power-on to power-off cycle of a machine and you wouldn't need
> vmrun.sh at all (you would just run bhyve with appropriate args / config
> file).  In that case, the return codes will change since it won't exit for
> reboots anymore.


Hi,

I wasn't aware of the longer term direction of bhyve.  If the return
codes may change
in the future, I don't know if it is a good idea to document them in
the man page.

However, documenting the return codes in comments in the vmrun.sh
script might be OK, since it
is just an example that can be changed easily.

What do you think of these changes to vmrun.sh:

 (1)  Move bhyvectl --destroy outside of the while loop.  It doesn't
need to run if the VM has been reset.
 (2)  Write some comments about return code of bhyve process.


--
Craig
--- share/examples/bhyve/vmrun.sh.orig  2014-08-20 11:38:09.788714905 -0700
+++ share/examples/bhyve/vmrun.sh       2014-08-20 11:43:14.158706821 -0700
@@ -173,9 +173,9 @@
 
 virtio_diskdev="$disk_dev0"
 
-while [ 1 ]; do
-       ${BHYVECTL} --vm=${vmname} --destroy > /dev/null 2>&1
+${BHYVECTL} --vm=${vmname} --destroy > /dev/null 2>&1
 
+while [ 1 ]; do
        file ${virtio_diskdev} | grep "boot sector" > /dev/null
        rc=$?
        if [ $rc -ne 0 ]; then
@@ -237,6 +237,14 @@
                -l com1,${console}                                      \
                ${installer_opt}                                        \
                ${vmname}
+       #
+       # bhyve returns the following status codes:
+       #  0 - VM has been reset
+       #  1 - VM has been powered off
+       #  2 - VM has been halted
+       #  3 - VM generated a triple fault
+       #  all other non-zero status codes are errors
+       #
        if [ $? -ne 0 ]; then
                break
        fi
_______________________________________________
freebsd-virtualization@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"

Reply via email to