summaryrefslogtreecommitdiff
path: root/app-emulation/libvirt
diff options
context:
space:
mode:
authorDoug Goldstein <cardoe@gentoo.org>2015-08-28 08:35:39 -0500
committerDoug Goldstein <cardoe@gentoo.org>2015-08-28 08:47:55 -0500
commit5ed04d55b9a56c932128d867b596bebc6e3ff4ce (patch)
tree1e3396607281542f972d9017cc3e68b3ff4095f0 /app-emulation/libvirt
parentc90c8667004a9efe613c36ec93ff8566b401c854 (diff)
downloadgentoo-5ed04d55b9a56c932128d867b596bebc6e3ff4ce.tar.gz
gentoo-5ed04d55b9a56c932128d867b596bebc6e3ff4ce.tar.xz
app-emulation/libvirt: tweak libvirt-guests init script
After discussing the new init script on bug #558034 there are two tweaks being added: * shift the first argument so that future uses can pass in more arguments to virsh and the wrapper commands. * Added LIBVIRT_IGNORE_AUTOSTART to ignore domains that start marked for autostart in the libvirt XML. Signed-off-by: Doug Goldstein <cardoe@gentoo.org>
Diffstat (limited to 'app-emulation/libvirt')
-rw-r--r--app-emulation/libvirt/files/libvirt-guests.confd10
-rw-r--r--app-emulation/libvirt/files/libvirt-guests.init33
2 files changed, 37 insertions, 6 deletions
diff --git a/app-emulation/libvirt/files/libvirt-guests.confd b/app-emulation/libvirt/files/libvirt-guests.confd
index 6e98dc23da6..514c8eeb4d6 100644
--- a/app-emulation/libvirt/files/libvirt-guests.confd
+++ b/app-emulation/libvirt/files/libvirt-guests.confd
@@ -39,6 +39,16 @@
#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,
diff --git a/app-emulation/libvirt/files/libvirt-guests.init b/app-emulation/libvirt/files/libvirt-guests.init
index 045f04dde14..2b63dea6dce 100644
--- a/app-emulation/libvirt/files/libvirt-guests.init
+++ b/app-emulation/libvirt/files/libvirt-guests.init
@@ -38,20 +38,32 @@ do_virsh() {
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() {
@@ -64,6 +76,7 @@ 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=
@@ -80,10 +93,18 @@ libvirtd_dom_stop() {
# 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