5 VIRSH_DEFAULT_CONNECT_URI
="qemu:///system"
6 export VIRSH_DEFAULT_CONNECT_URI
8 usage
="Usage: $0 COMMAND [DOMAIN ARGS...]"
9 groups
="$VMCTL_GROUP $USERV_GROUP"
11 case x
${USERV_SERVICE+t} in
12 xt
) set -- "$USERV_SERVICE" "$@" ;;
21 status DOM Show domain status.
22 reset DOM Forcibly restart the domain.
23 stop DOM Forcibly turn off the domain.
24 reboot DOM Send the domain a reboot request.
25 shutdown DOM Send the domain a shutdown request.
26 save DOM Suspend the domain; restart using \`start'.
27 start DOM [-c] Start up the domain (-c: and attach to console).
28 console DOM Attach to the domain's console.
32 0,* |
1,*) echo >&2 "$usage"; exit 1 ;;
33 *) cmd
=$1 dom
=$2; shift 2 ;;
37 while read grps doms
; do
38 case "$grps" in "" | \
#*) continue ;; esac
41 case ",$grps," in *,$g,*) gmatch
=t
;; esac
44 case "$dom" in $d) dmatch
=t
;; esac
46 case $gmatch,$dmatch in t
,t
) allow
=t
; break ;; esac
47 done <$HOME/vmctl.conf
49 case $allow in nil
) echo >&2 "$0: not permitted"; exit 1 ;; esac
52 0,status
) virsh dominfo
"$dom" ;;
53 0,reset) virsh
reset "$dom" ;;
54 0,stop
) virsh destroy
"$dom" ;;
55 0,reboot
) virsh reboot
"$dom" ;;
56 0,shutdown
) virsh shutdown
"$dom" ;;
61 1,-c |
1,--console
) args
="$args --console" ;;
62 *) echo >&2 "Usage: $0 DOMAIN start [-c]"; exit 1 ;;
64 virsh start
"$dom" $args
66 0,save
) virsh managedsave
"$dom" ;;
67 0,console
) virsh console
"$dom" ;;
68 *) echo >&2 "$usage"; exit 1 ;;