diff options
author | 2012-09-30 05:07:07 +0000 | |
---|---|---|
committer | 2012-09-30 05:07:07 +0000 | |
commit | 37ef1197653f2f85250024bd80f1ffa6eee32a79 (patch) | |
tree | 0e67cfa543e62be45761690d8e8983a9d441f0d5 /app-emulation/libvirt | |
parent | Update the live ebuild to the latest tweak in 0.10.2. (diff) | |
download | gentoo-2-37ef1197653f2f85250024bd80f1ffa6eee32a79.tar.gz gentoo-2-37ef1197653f2f85250024bd80f1ffa6eee32a79.tar.bz2 gentoo-2-37ef1197653f2f85250024bd80f1ffa6eee32a79.zip |
Bump the init script to fix an issue where the halt command could not be used during the correct phase with OpenRC.
(Portage version: 2.1.11.9/cvs/Linux x86_64)
Diffstat (limited to 'app-emulation/libvirt')
-rw-r--r-- | app-emulation/libvirt/ChangeLog | 7 | ||||
-rwxr-xr-x | app-emulation/libvirt/files/libvirtd.init-r9 | 128 | ||||
-rw-r--r-- | app-emulation/libvirt/libvirt-0.10.2.ebuild | 4 | ||||
-rw-r--r-- | app-emulation/libvirt/libvirt-9999.ebuild | 4 |
4 files changed, 138 insertions, 5 deletions
diff --git a/app-emulation/libvirt/ChangeLog b/app-emulation/libvirt/ChangeLog index f334af941906..b229741a84de 100644 --- a/app-emulation/libvirt/ChangeLog +++ b/app-emulation/libvirt/ChangeLog @@ -1,6 +1,11 @@ # ChangeLog for app-emulation/libvirt # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/ChangeLog,v 1.213 2012/09/30 03:34:54 cardoe Exp $ +# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/ChangeLog,v 1.214 2012/09/30 05:07:07 cardoe Exp $ + + 30 Sep 2012; Doug Goldstein <cardoe@gentoo.org> libvirt-0.10.2.ebuild, + libvirt-9999.ebuild, +files/libvirtd.init-r9: + Bump the init script to fix an issue where the halt command could not be used + during the correct phase with OpenRC. 30 Sep 2012; Doug Goldstein <cardoe@gentoo.org> libvirt-9999.ebuild: Update the live ebuild to the latest tweak in 0.10.2. diff --git a/app-emulation/libvirt/files/libvirtd.init-r9 b/app-emulation/libvirt/files/libvirtd.init-r9 new file mode 100755 index 000000000000..05852877b07c --- /dev/null +++ b/app-emulation/libvirt/files/libvirtd.init-r9 @@ -0,0 +1,128 @@ +#!/sbin/runscript + +description="Virtual Machine Management daemon (libvirt)" +extra_started_commands="reload halt" +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() { + local mode=$1 + shift + + # Silence errors because virsh always throws an error about + # not finding the hypervisor version when connecting to libvirtd + LC_ALL=C virsh -c ${mode}:///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 $1 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 $1 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 $1 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 $1 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() { + local counter= + local vm_name= + local net_name= + local dom_id= + + ebegin "Stopping libvirtd" + # try to shutdown all (KVM/Qemu) domains + if [ "${LIBVIRTD_KVM_SHUTDOWN}" != "none" ] \ + && [ "$(libvirtd_dom_count qemu)" != "0" ] ; then + + einfo " Shutting down domain(s):" + for dom_id in $(libvirtd_dom_list qemu) ; do + vm_name="$(libvirtd_virsh qemu domname ${dom_id} | head -n 1)" + einfo " ${vm_name}" + libvirtd_virsh qemu ${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 qemu)" + while [ ${DOM_COUNT} -gt 0 ] && [ ${counter} -gt 0 ] ; do + DOM_COUNT="$(libvirtd_dom_count qemu)" + sleep 1 + counter=$((${counter} - 1)) + echo -n "." + done + fi + + if [ "$(libvirtd_dom_count qemu)" != "0" ] ; then + eerror " !!! Some guests are still running, stopping anyway" + fi + + fi + + if [ "${LIBVIRTD_KVM_NET_SHUTDOWN}" != "no" ] \ + && [ "$(libvirtd_net_count qemu)" != "0" ]; then + + einfo " Shutting down network(s):" + for net_name in $(libvirtd_net_list qemu); do + einfo " ${net_name}" + libvirtd_virsh qemu net-destroy ${net_name} > /dev/null + done + + if [ "$(libvirtd_net_count qemu)" != "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 +} diff --git a/app-emulation/libvirt/libvirt-0.10.2.ebuild b/app-emulation/libvirt/libvirt-0.10.2.ebuild index 34c16b9b5719..4a7e904ea592 100644 --- a/app-emulation/libvirt/libvirt-0.10.2.ebuild +++ b/app-emulation/libvirt/libvirt-0.10.2.ebuild @@ -1,6 +1,6 @@ # Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/libvirt-0.10.2.ebuild,v 1.1 2012/09/30 02:45:55 cardoe Exp $ +# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/libvirt-0.10.2.ebuild,v 1.2 2012/09/30 05:07:07 cardoe Exp $ EAPI=4 @@ -316,7 +316,7 @@ src_install() { use libvirtd || return 0 # From here, only libvirtd-related instructions, be warned! - newinitd "${FILESDIR}/libvirtd.init-r8" libvirtd || die + newinitd "${FILESDIR}/libvirtd.init-r9" libvirtd || die newconfd "${FILESDIR}/libvirtd.confd-r3" libvirtd || die keepdir /var/lib/libvirt/images diff --git a/app-emulation/libvirt/libvirt-9999.ebuild b/app-emulation/libvirt/libvirt-9999.ebuild index 825cf65aabb0..e4ba27e81b82 100644 --- a/app-emulation/libvirt/libvirt-9999.ebuild +++ b/app-emulation/libvirt/libvirt-9999.ebuild @@ -1,6 +1,6 @@ # Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/libvirt-9999.ebuild,v 1.39 2012/09/30 03:34:54 cardoe Exp $ +# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/libvirt-9999.ebuild,v 1.40 2012/09/30 05:07:07 cardoe Exp $ EAPI=4 @@ -304,7 +304,7 @@ src_install() { use libvirtd || return 0 # From here, only libvirtd-related instructions, be warned! - newinitd "${FILESDIR}/libvirtd.init-r8" libvirtd || die + newinitd "${FILESDIR}/libvirtd.init-r9" libvirtd || die newconfd "${FILESDIR}/libvirtd.confd-r3" libvirtd || die keepdir /var/lib/libvirt/images |