#LIBVIRT_MAXWAIT="500"
+# LIBVIRT_IGNORE_AUTOSTART
+# If the VM is marked for autostart in its XML configuration then we won't
+# save its start when the init script is stopped. The result is that when
+# the init script starts back up, no attempt will be made to start the VM or
+# confirm it is started.
+# Valid values are yes or no
+
+#LIBVIRT_IGNORE_AUTOSTART="no"
+
+
# LIBVIRT_NET_SHUTDOWN
# If libvirtd created networks for you (e.g. NATed networks) then this init
# script will shut them down for you if this is set to 'yes'. Otherwise,
libvirtd_dom_list() {
# Only work with domains by their UUIDs
- do_virsh "$1" list --uuid $2
+ local hvuri=$1
+ shift
+
+ do_virsh "${hvuri}" list --uuid $@
}
libvirtd_dom_count() {
- libvirtd_dom_list "$1" $2 | wc -l
+ local hvuri=$1
+ shift
+
+ libvirtd_dom_list "${hvuri}" $@ | wc -l
}
libvirtd_net_list() {
# Only work with networks by their UUIDs
- do_virsh "$1" net-list --uuid $2
+ local hvuri=$1
+ shift
+
+ do_virsh "${hvuri}" net-list --uuid $@
}
libvirtd_net_count() {
- libvirtd_net_list "$1" $2 | wc -l
+ local hvuri=$1
+ shift
+
+ libvirtd_net_list "${hvuri}" $@ | wc -l
}
libvirtd_dom_stop() {
local shutdown_type=${LIBVIRT_SHUTDOWN}
local counter=${LIBVIRT_MAXWAIT}
local dom_name=
+ local dom_as=
local dom_ids=
local uuid=
local dom_count=
# Get the name
dom_name=$(do_virsh ${uri} domname ${uuid})
einfo " ${dom_name}"
+ # Get autostart state
+ dom_as=$(do_virsh ${uri} dominfo ${uuid} | \
+ awk '$1 == "Autostart:" { print $2 }')
if [ "${persist}" = "--persistent" ]; then
- # Save our running state
- echo "${uri} ${uuid}" >> ${gueststatefile}
+ # Save our running state only if LIBVIRT_IGNORE_AUTOSTART != yes
+ if [ "x${LIBVIRT_IGNORE_AUTOSTART}" = "xyes" ] && \
+ [ ${dom_as} = "enabled" ]; then
+ :
+ else
+ echo "${uri} ${uuid}" >> ${gueststatefile}
+ fi
fi