mirror of
https://github.com/churchers/vm-bhyve.git
synced 2025-12-13 18:30:20 +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
|
# list virtual machines
|
||||||
#
|
#
|
||||||
core::list(){
|
core::list(){
|
||||||
|
local _running_only
|
||||||
local _name _loader _cpu _our_host
|
local _name _loader _cpu _our_host
|
||||||
local _memory _run _vm _auto _num _vnc _pid
|
local _memory _run _vm _auto _num _vnc _pid
|
||||||
local _state _pcpu _rss _uptime
|
local _state _pcpu _rss _uptime
|
||||||
local _format="%s^%s^%s^%s^%s^%s^%s^%s\n"
|
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 $?
|
shift $?
|
||||||
|
|
||||||
_our_host=$(hostname)
|
_our_host=$(hostname)
|
||||||
@@ -109,6 +117,10 @@ core::list(){
|
|||||||
_run="Locked (${_run})"
|
_run="Locked (${_run})"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${_run}" = "Stopped" -a -n "${_running_only}" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "${VM_OPT_VERBOSE}" ]; then
|
if [ -n "${VM_OPT_VERBOSE}" ]; then
|
||||||
printf "${_format}" "${_name}" "${_ds}" "${_loader}" "${_cpu}" "${_memory}" "${_vnc}" "${_auto}" "${_pcpu}" "${_rss}" "${_uptime}" "${_run}"
|
printf "${_format}" "${_name}" "${_ds}" "${_loader}" "${_cpu}" "${_memory}" "${_vnc}" "${_auto}" "${_pcpu}" "${_rss}" "${_uptime}" "${_run}"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ Usage: vm ...
|
|||||||
datastore add <name> <spec>
|
datastore add <name> <spec>
|
||||||
datastore remove <name>
|
datastore remove <name>
|
||||||
datastore add <name> <path>
|
datastore add <name> <path>
|
||||||
list
|
list [-r]
|
||||||
info [name] [...]
|
info [name] [...]
|
||||||
create [-d datastore] [-t template] [-s size] [-m memory] [-c vCPUs] <name>
|
create [-d datastore] [-t template] [-s size] [-m memory] [-c vCPUs] <name>
|
||||||
install [-fi] <name> <iso>
|
install [-fi] <name> <iso>
|
||||||
|
|||||||
10
vm.8
10
vm.8
@@ -83,6 +83,7 @@
|
|||||||
.Ar name
|
.Ar name
|
||||||
.Nm
|
.Nm
|
||||||
.Cm list
|
.Cm list
|
||||||
|
.Op Fl r
|
||||||
.Nm
|
.Nm
|
||||||
.Cm info
|
.Cm info
|
||||||
.Op Ar name
|
.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
|
.It Cm destroy Ar name
|
||||||
Removes the specified virtual machine from the system, deleting all associated
|
Removes the specified virtual machine from the system, deleting all associated
|
||||||
disk images & configuration.
|
disk images & configuration.
|
||||||
.It Cm list
|
.It Xo
|
||||||
|
.Cm list
|
||||||
|
.Op Fl r
|
||||||
|
.Xc
|
||||||
.br
|
.br
|
||||||
List all the virtual machines in the
|
List all the virtual machines in the
|
||||||
.Pa $vm_dir
|
.Pa $vm_dir
|
||||||
directory.
|
directory.
|
||||||
This will show the basic configuration for each virtual machine, and whether
|
This will show the basic configuration for each virtual machine, and whether
|
||||||
they are currently running.
|
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 ...
|
.It Cm info Op Ar name Op Ar ...
|
||||||
Shows detailed information about the specified virtual machine(s).
|
Shows detailed information about the specified virtual machine(s).
|
||||||
If no names are given, information for all virtual machines is displayed.
|
If no names are given, information for all virtual machines is displayed.
|
||||||
|
|||||||
Reference in New Issue
Block a user