diff options
author | Doug Goldstein <cardoe@gentoo.org> | 2010-07-07 18:17:03 +0000 |
---|---|---|
committer | Doug Goldstein <cardoe@gentoo.org> | 2010-07-07 18:17:03 +0000 |
commit | 054c8c40dd8bac153bf56307d78b6fc62d0ff1ef (patch) | |
tree | df24d23b708ae02cdd4e17a6e35373e2d2f93e76 /app-emulation/libvirt | |
parent | old (diff) | |
download | gentoo-2-054c8c40dd8bac153bf56307d78b6fc62d0ff1ef.tar.gz gentoo-2-054c8c40dd8bac153bf56307d78b6fc62d0ff1ef.tar.bz2 gentoo-2-054c8c40dd8bac153bf56307d78b6fc62d0ff1ef.zip |
Updated initscript to support managedsave as well as ACPI shutdown. Additionally support a reload operation that just restarts libvirt without killing your VMs
(Portage version: 2.1.8.3/cvs/Linux x86_64)
Diffstat (limited to 'app-emulation/libvirt')
-rw-r--r-- | app-emulation/libvirt/ChangeLog | 11 | ||||
-rw-r--r-- | app-emulation/libvirt/files/libvirtd.confd-r1 | 27 | ||||
-rw-r--r-- | app-emulation/libvirt/files/libvirtd.init-r1 | 79 | ||||
-rw-r--r-- | app-emulation/libvirt/libvirt-0.8.2-r1.ebuild (renamed from app-emulation/libvirt/libvirt-0.8.2.ebuild) | 6 |
4 files changed, 119 insertions, 4 deletions
diff --git a/app-emulation/libvirt/ChangeLog b/app-emulation/libvirt/ChangeLog index f5cbfdbc3cbb..b0cc517e6e29 100644 --- a/app-emulation/libvirt/ChangeLog +++ b/app-emulation/libvirt/ChangeLog @@ -1,6 +1,15 @@ # ChangeLog for app-emulation/libvirt # Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/ChangeLog,v 1.58 2010/07/06 17:20:49 cardoe Exp $ +# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/ChangeLog,v 1.59 2010/07/07 18:17:02 cardoe Exp $ + +*libvirt-0.8.2-r1 (07 Jul 2010) + + 07 Jul 2010; Doug Goldstein <cardoe@gentoo.org> -libvirt-0.8.2.ebuild, + +libvirt-0.8.2-r1.ebuild, +files/libvirtd.confd-r1, + +files/libvirtd.init-r1: + Updated initscript to support managedsave as well as ACPI shutdown. + Additionally support a reload operation that just restarts libvirt without + killing your VMs 06 Jul 2010; Doug Goldstein <cardoe@gentoo.org> -files/libvirt-0.7.6-virt-pki-validate-sysconfdir.patch, metadata.xml: diff --git a/app-emulation/libvirt/files/libvirtd.confd-r1 b/app-emulation/libvirt/files/libvirtd.confd-r1 new file mode 100644 index 000000000000..d51bdb99d1fd --- /dev/null +++ b/app-emulation/libvirt/files/libvirtd.confd-r1 @@ -0,0 +1,27 @@ +# /etc/conf.d/libvirtd + +# You may want to add '--listen' to have libvirtd listen for tcp/ip connections +# if you want to use libvirt for remote control + +# Please consult 'libvirtd --help' for more options + +#LIBVIRTD_OPTS="--listen" + +# Valid options: +# * shutdown - Sends an ACPI shutdown (think when you tap the power button +# on your machine and it begins a graceful shutdown). If your +# VM ignores this, it will have the power yanked out from under +# it in LIBVIRTD_KVM_SHUTDOWN_MAXWAIT seconds. +# * managedsave - Performs a state save external to the VM. qemu-kvm will stop +# stop the CPU and save off all state to a separate file. When +# the machine is started again, it will resume like nothing ever +# happened. This is guarenteed to always successfully stop your +# machine and restart it. However it may take some time to finish. +# * none - No attempts will be made to stop any VMs. If you are restarting your +# machine the qemu-kvm process will be simply killed, which may result +# in your VMs having disk corruption. +LIBVIRTD_KVM_SHUTDOWN="managedsave" + +# Timeout in seconds until stopping libvirtd and "pulling the plug" on the +# remaining VM's still in a running state +#LIBVIRTD_KVM_SHUTDOWN_MAXWAIT="500" diff --git a/app-emulation/libvirt/files/libvirtd.init-r1 b/app-emulation/libvirt/files/libvirtd.init-r1 new file mode 100644 index 000000000000..a635d5cc9535 --- /dev/null +++ b/app-emulation/libvirt/files/libvirtd.init-r1 @@ -0,0 +1,79 @@ +#!/sbin/runscript + +opts="start stop status reload restart" + +depend() { + need net + before sshd ntp-client ntpd nfs nfsmount rsyncd portmap dhcp +} + +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() { + libvirtd_virsh list | grep running | awk '{ print $1 }' +} + +libvirtd_dom_count() { + libvirtd_dom_list | wc -l +} + +start() { + ebegin "Starting libvirtd" + start-stop-daemon --start --quiet --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 managedsave ${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 anyways" + fi + + fi + start-stop-daemon --stop --quiet --exec /usr/sbin/libvirtd --pidfile=/var/run/libvirtd.pid + eend $? +} + +reload() { + ebegin "Reloading libvirtd without shutting down your VMs" + start-stop-daemon --stop --quiet --exec /usr/sbin/libvirtd --pidfile=/var/run/libvirtd.pid + if [ $? -ne 0 ]; then + eend $? + fi + start-stop-daemon --start --quiet --exec /usr/sbin/libvirtd -- -d ${LIBVIRTD_OPTS} + eend $? +} diff --git a/app-emulation/libvirt/libvirt-0.8.2.ebuild b/app-emulation/libvirt/libvirt-0.8.2-r1.ebuild index c80d9099ec64..f30c527a7750 100644 --- a/app-emulation/libvirt/libvirt-0.8.2.ebuild +++ b/app-emulation/libvirt/libvirt-0.8.2-r1.ebuild @@ -1,6 +1,6 @@ # Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/libvirt-0.8.2.ebuild,v 1.2 2010/07/06 17:10:35 cardoe Exp $ +# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/libvirt-0.8.2-r1.ebuild,v 1.1 2010/07/07 18:17:02 cardoe Exp $ #BACKPORTS=1 @@ -164,8 +164,8 @@ src_install() { EXAMPLE_DIR=/usr/share/doc/${PF}/python/examples \ || die "emake install failed" - newinitd "${FILESDIR}/libvirtd.init" libvirtd || die - newconfd "${FILESDIR}/libvirtd.confd" libvirtd || die + newinitd "${FILESDIR}/libvirtd.init-r1" libvirtd || die + newconfd "${FILESDIR}/libvirtd.confd-r1" libvirtd || die keepdir /var/lib/libvirt/images |