Updated initscript to support managedsave as well as ACPI shutdown. Additionally...
authorDoug Goldstein <cardoe@gentoo.org>
Wed, 7 Jul 2010 18:17:03 +0000 (18:17 +0000)
committerDoug Goldstein <cardoe@gentoo.org>
Wed, 7 Jul 2010 18:17:03 +0000 (18:17 +0000)
Package-Manager: portage-2.1.8.3/cvs/Linux x86_64

app-emulation/libvirt/ChangeLog
app-emulation/libvirt/Manifest
app-emulation/libvirt/files/libvirtd.confd-r1 [new file with mode: 0644]
app-emulation/libvirt/files/libvirtd.init-r1 [new file with mode: 0644]
app-emulation/libvirt/libvirt-0.8.2-r1.ebuild [moved from app-emulation/libvirt/libvirt-0.8.2.ebuild with 97% similarity]

index f5cbfdbc3cbb8b0bce2ff29aedb99871009fc1ec..b0cc517e6e297f596ee7e6ed6e1627d6a0a9afb2 100644 (file)
@@ -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:
index f1dfdab972a824bb19e279fc795b45cff0030be8..25e877e761da01611ff5ed36e4f4e72d7ce670fe 100644 (file)
@@ -1,9 +1,11 @@
 AUX libvirtd.confd 476 RMD160 63b92da0cf0d589c1c6e76551982deb6b5fc8f9a SHA1 5b76082bb28705606758880c19af922dde1ccb01 SHA256 ff2c94d2a64058152be669256d8d2e241cde4356a77bd653eac9fa3b084666f6
+AUX libvirtd.confd-r1 1248 RMD160 ebd5f28c671f2d26e9ff5d4879f959c11d72d7e3 SHA1 4789a80343f06b535d6bc27ef4206704c548c078 SHA256 851ab3f9678f0fa9c3ee03f7fc7bd00c4ee86d5f0777eecf9eb1ffe3243adfd1
 AUX libvirtd.init 2045 RMD160 b544578c242c6f84e2cf07682a06ce261bf40b8a SHA1 81976137c43f6b507e27ac926a6d7947e1a329d3 SHA256 96cbdf8e68a171d170f91167a4217a366325ca668b9e2621ec6800fd35d42c5c
+AUX libvirtd.init-r1 2220 RMD160 e1618e1578f0ce3251329893bf69e004fadabb73 SHA1 fee8f52efd5a27466d6a44fc3794a258b8fdf875 SHA256 047d13443100adfa0dbe440df492b82607b4a1bfac735690f5f9f3c9037d4c2f
 DIST libvirt-0.8.1-backports-1.tar.bz2 7521 RMD160 2d4784ccd1ab4484c77a1eea5184e365631ad39d SHA1 33f95f9313a89962b74b05d723bb221b42f4892c SHA256 89a2fbb9905bb13b0f7d91aa937f825df56e773a8e8bb045a9d21a7afede14ad
 DIST libvirt-0.8.1.tar.gz 11659399 RMD160 d43f46092029a4cc030e302c78929e3e4b36ae90 SHA1 a7e7066b4d2c99ec2c17e65e5bf19d0d9fdf27b0 SHA256 8d3e8d63884c4fd24465e083458edea92d2792339ce6c73c23bc6838df8eb76a
 DIST libvirt-0.8.2.tar.gz 12230368 RMD160 280c95e74c41c56686a50892105b2c41b196a107 SHA1 553c984e1fc1eae288d32ff911ba5614010bece4 SHA256 69d2bbf2d4057bdb2781a2ba45b2628a0f0312597ef7dd15a6a3d34720b33e60
 EBUILD libvirt-0.8.1-r1.ebuild 6314 RMD160 3c1886e786c0c322fa6ac9eaf9ec18e78b371d7e SHA1 06641c72f4a032a7575b98d92a3114ea241f479f SHA256 d7ea34f42e6792df515716cf09e44389c2b8358f24723b70fac79950bfd154df
-EBUILD libvirt-0.8.2.ebuild 6748 RMD160 ce7ea420419f5dce2f140f31607a088442aaea4e SHA1 148ae12614aad0b246953bb37c7ea0b374814306 SHA256 4e3c60c138f909601aeea7c97c24e6061eda65ac12fcfd99681b8e9ef575723b
-MISC ChangeLog 13675 RMD160 f36b424805a25fa512ee0f22e299af15c87c2e32 SHA1 fd5abfaa9b2f0b67af64e84814c7c8e0c92bf397 SHA256 91711da2062cc6e09e3df24baabe89598d4169a3a7dfcac8dd8346d659a4e3a4
+EBUILD libvirt-0.8.2-r1.ebuild 6757 RMD160 4e405473801d66a8ac744e8c131ab72e6af14ea7 SHA1 bd361986257d6e88ad439e28d90c096640abc6dc SHA256 10d3880b68831059beb1524d5c7fe4798ade5aff8860b3b31096b546fbe685c3
+MISC ChangeLog 14029 RMD160 d43489ff1d584ee12534ad8d05a08eb1c04da95d SHA1 d722b6bf7b19cb807bc77c8cc3d3795f28fb86d4 SHA256 b93593b39ce832197609298ea25d3b5f8e74ec47a8a5e28a41723d3396128cae
 MISC metadata.xml 1983 RMD160 c6b39d8d0adfd2a7acd32fecc80ffbdaf667d690 SHA1 1a5a6b78fd2b9e536742301441aebfc4e65bb8ad SHA256 1a781681093c05d500a676f4c72146a87f61144b1b5eabbeb987f1dbb885102d
diff --git a/app-emulation/libvirt/files/libvirtd.confd-r1 b/app-emulation/libvirt/files/libvirtd.confd-r1
new file mode 100644 (file)
index 0000000..d51bdb9
--- /dev/null
@@ -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 (file)
index 0000000..a635d5c
--- /dev/null
@@ -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 $?
+}
similarity index 97%
rename from app-emulation/libvirt/libvirt-0.8.2.ebuild
rename to app-emulation/libvirt/libvirt-0.8.2-r1.ebuild
index c80d9099ec6445223b49f402876798b12373eb34..f30c527a7750ff4563c838ed4908e1015d15f7dc 100644 (file)
@@ -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