mirror of
https://github.com/churchers/vm-bhyve.git
synced 2025-12-11 01:10:01 +01:00
Add option to only list running VMs
This commit is contained in:
14
lib/vm-core
14
lib/vm-core
@@ -28,12 +28,20 @@
|
||||
# list virtual machines
|
||||
#
|
||||
core::list(){
|
||||
local _running_only
|
||||
local _name _loader _cpu _our_host
|
||||
local _memory _run _vm _auto _num _vnc _pid
|
||||
local _state _pcpu _rss _uptime
|
||||
local _format="%s^%s^%s^%s^%s^%s^%s^%s\n"
|
||||
|
||||
cmd::parse_args "$@"
|
||||
while getopts r _opt ; do
|
||||
case $_opt in
|
||||
r) _running_only='true' ;;
|
||||
|
||||
*) util::usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $?
|
||||
|
||||
_our_host=$(hostname)
|
||||
@@ -109,6 +117,10 @@ core::list(){
|
||||
_run="Locked (${_run})"
|
||||
fi
|
||||
|
||||
if [ "${_run}" = "Stopped" -a -n "${_running_only}" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -n "${VM_OPT_VERBOSE}" ]; then
|
||||
printf "${_format}" "${_name}" "${_ds}" "${_loader}" "${_cpu}" "${_memory}" "${_vnc}" "${_auto}" "${_pcpu}" "${_rss}" "${_uptime}" "${_run}"
|
||||
else
|
||||
|
||||
@@ -161,7 +161,7 @@ Usage: vm ...
|
||||
datastore add <name> <spec>
|
||||
datastore remove <name>
|
||||
datastore add <name> <path>
|
||||
list
|
||||
list [-r]
|
||||
info [name] [...]
|
||||
create [-d datastore] [-t template] [-s size] [-m memory] [-c vCPUs] <name>
|
||||
install [-fi] <name> <iso>
|
||||
|
||||
10
vm.8
10
vm.8
@@ -83,6 +83,7 @@
|
||||
.Ar name
|
||||
.Nm
|
||||
.Cm list
|
||||
.Op Fl r
|
||||
.Nm
|
||||
.Cm info
|
||||
.Op Ar name
|
||||
@@ -643,13 +644,20 @@ Unless specified, the guest image will be a sparse file 20GB in size.
|
||||
.It Cm destroy Ar name
|
||||
Removes the specified virtual machine from the system, deleting all associated
|
||||
disk images & configuration.
|
||||
.It Cm list
|
||||
.It Xo
|
||||
.Cm list
|
||||
.Op Fl r
|
||||
.Xc
|
||||
.br
|
||||
List all the virtual machines in the
|
||||
.Pa $vm_dir
|
||||
directory.
|
||||
This will show the basic configuration for each virtual machine, and whether
|
||||
they are currently running.
|
||||
.Pp
|
||||
If the
|
||||
.Ar -r
|
||||
option is specified, only running guests are listed.
|
||||
.It Cm info Op Ar name Op Ar ...
|
||||
Shows detailed information about the specified virtual machine(s).
|
||||
If no names are given, information for all virtual machines is displayed.
|
||||
|
||||
Reference in New Issue
Block a user