* [gentoo-commits] gentoo-x86 commit in app-emulation/libvirt/files: libvirtd.init-r5
@ 2011-09-29 16:51 Doug Goldstein (cardoe)
0 siblings, 0 replies; only message in thread
From: Doug Goldstein (cardoe) @ 2011-09-29 16:51 UTC (permalink / raw
To: gentoo-commits
cardoe 11/09/29 16:51:08
Added: libvirtd.init-r5
Log:
Version bump. Improvements to the init script to support newer OpenRCs, document the current behaviors and add a halt command.
(Portage version: 2.1.10.19/cvs/Linux x86_64)
Revision Changes Path
1.1 app-emulation/libvirt/files/libvirtd.init-r5
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirtd.init-r5?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirtd.init-r5?rev=1.1&content-type=text/plain
Index: libvirtd.init-r5
===================================================================
#!/sbin/runscript
description="Virtual Machine Management daemon (libvirt)"
extra_commands="halt"
extra_started_commands="reload"
description_halt="Stops the libvirt daemon without stopping your VMs"
description_reload="Restarts the libvirt daemon without stopping your VMs"
depend() {
need net
after ntp-client ntpd nfs iscsid nfsmount portmap rpc.statd iptables ip6tables ebtables ceph corosync sanlock cgconfig
}
libvirtd_virsh() {
# Silence errors because virsh always throws an error about
# not finding the hypervisor version when connecting to libvirtd
LC_ALL=C virsh -c qemu:///system "$@" 2>/dev/null
}
libvirtd_dom_list() {
# Make sure that it wouldn't be confused if the domain name
# contains the word running.
libvirtd_virsh list | awk '$3 == "running" { print $1 }'
}
libvirtd_dom_count() {
# Make sure that it wouldn't be confused if the domain name
# contains the word running.
libvirtd_virsh list | awk 'BEGIN { count = 0 } \
$3 == "running" { count++ } \
END { print count }'
}
libvirtd_net_list() {
# The purpose of the awk is to avoid networks with 'active' in the name
libvirtd_virsh net-list | awk '$2 == "active" { print $1 }'
}
libvirtd_net_count() {
# The purpose of the awk is to avoid networks with 'active' in the name
libvirtd_virsh net-list | awk 'BEGIN { count = 0 } \
$2 == "active" { count++ } \
END { print count }'
}
start() {
ebegin "Starting libvirtd"
start-stop-daemon --start \
--env KRB5_KTNAME=/etc/libvirt/krb5.tab \
--exec /usr/sbin/libvirtd -- -d ${LIBVIRTD_OPTS}
eend $?
}
stop() {
ebegin "Stopping libvirtd"
# try to shutdown all (KVM/Qemu) domains
DOM_COUNT="$(libvirtd_dom_count)"
if [ "${LIBVIRTD_KVM_SHUTDOWN}" != "none" ] \
&& [ "${DOM_COUNT}" != "0" ] ; then
einfo " Shutting down domain(s):"
for DOM_ID in $(libvirtd_dom_list) ; do
NAME="$(libvirtd_virsh domname ${DOM_ID} | head -n 1)"
einfo " ${NAME}"
libvirtd_virsh ${LIBVIRTD_KVM_SHUTDOWN} ${DOM_ID} > /dev/null
done
if [ -n "${LIBVIRTD_KVM_SHUTDOWN_MAXWAIT}" ] ; then
COUNTER="${LIBVIRTD_KVM_SHUTDOWN_MAXWAIT}"
else
COUNTER=500
fi
if [ "${LIBVIRTD_KVM_SHUTDOWN}" = "shutdown" ]; then
einfo " Waiting ${COUNTER} seconds while domains shutdown ..."
DOM_COUNT="$(libvirtd_dom_count)"
while [ ${DOM_COUNT} -gt 0 ] && [ ${COUNTER} -gt 0 ] ; do
DOM_COUNT="$(libvirtd_dom_count)"
sleep 1
COUNTER=$((${COUNTER} - 1))
echo -n "."
done
fi
DOM_COUNT="$(libvirtd_dom_count)"
if [ "${DOM_COUNT}" != "0" ] ; then
eerror " !!! Some guests are still running, stopping anyway"
fi
fi
NET_COUNT="$(libvirtd_net_count)"
if [ "${LIBVIRTD_NET_SHUTDOWN}" != "no" ] \
&& [ "${NET_COUNT}" != "0" ]; then
einfo " Shutting down network(s):"
for NET_NAME in $(libvirtd_net_list); do
einfo " ${NET_NAME}"
libvirtd_virsh net-destroy ${NET_NAME} > /dev/null
done
NET_COUNT="$(libvirtd_net_count)"
if [ "${NET_COUNT}" != "0" ]; then
eerror " !!! Some networks are still active, stopping anyway"
fi
fi
# Now actually stop the daemon
start-stop-daemon --stop --quiet --exec \
/usr/sbin/libvirtd --pidfile=/var/run/libvirtd.pid
eend $?
}
halt() {
ebegin "Stopping libvirtd without shutting down your VMs"
start-stop-daemon --stop --quiet --exec \
/usr/sbin/libvirtd --pidfile=/var/run/libvirtd.pid
eend $?
}
reload() {
halt
start
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-09-29 16:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-29 16:51 [gentoo-commits] gentoo-x86 commit in app-emulation/libvirt/files: libvirtd.init-r5 Doug Goldstein (cardoe)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox