diff options
Diffstat (limited to 'app-emulation/libvirt/files')
-rw-r--r-- | app-emulation/libvirt/files/libvirt-0.4.6-qemu-img-name.patch | 18 | ||||
-rw-r--r-- | app-emulation/libvirt/files/libvirtd.confd | 15 | ||||
-rwxr-xr-x | app-emulation/libvirt/files/libvirtd.init | 73 |
3 files changed, 106 insertions, 0 deletions
diff --git a/app-emulation/libvirt/files/libvirt-0.4.6-qemu-img-name.patch b/app-emulation/libvirt/files/libvirt-0.4.6-qemu-img-name.patch new file mode 100644 index 0000000..a1c27d2 --- /dev/null +++ b/app-emulation/libvirt/files/libvirt-0.4.6-qemu-img-name.patch @@ -0,0 +1,18 @@ +--- libvirt-0.4.6/configure.in.orig 2008-11-20 22:44:26.000000000 -0500 ++++ libvirt-0.4.6/configure.in 2008-11-20 23:06:29.000000000 -0500 +@@ -698,7 +698,14 @@ + [Location or name of the showmount program]) + fi + +-AC_PATH_PROG([QEMU_IMG], [qemu-img], [], [$PATH:/sbin:/usr/sbin:/bin:/usr/bin]) ++AC_ARG_WITH([qemu-img-name], [AC_HELP_STRING([--with-qemu-img-name=[name of binary|qemu-img]], [Name of the qemu-img binary])]) ++if test "x$with_qemu_img_name" == "x" ; then ++ QEMU_IMG_BIN="qemu-img" ++else ++ QEMU_IMG_BIN="$with_qemu_img_name" ++fi ++ ++AC_PATH_PROG([QEMU_IMG], [$QEMU_IMG_BIN], [], [$PATH:/sbin:/usr/sbin:/bin:/usr/bin]) + if test -n "$QEMU_IMG" ; then + AC_DEFINE_UNQUOTED([HAVE_QEMU_IMG], 1, [whether qemu-img is available for non-raw files]) + AC_DEFINE_UNQUOTED([QEMU_IMG],["$QEMU_IMG"], diff --git a/app-emulation/libvirt/files/libvirtd.confd b/app-emulation/libvirt/files/libvirtd.confd new file mode 100644 index 0000000..705b785 --- /dev/null +++ b/app-emulation/libvirt/files/libvirtd.confd @@ -0,0 +1,15 @@ +# /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" + +# Automatically shutdown KVM domains when stopping libvirtd +LIBVIRTD_KVM_SHUTDOWN="yes" + +# Timeout in seconds until stopping libvirtd and "pulling the plug" on the +# remaining VM's still in a running state +#LIBVIRTD_KVM_SHUTDOWN_MAXWAIT="100" diff --git a/app-emulation/libvirt/files/libvirtd.init b/app-emulation/libvirt/files/libvirtd.init new file mode 100755 index 0000000..10765f5 --- /dev/null +++ b/app-emulation/libvirt/files/libvirtd.init @@ -0,0 +1,73 @@ +#!/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}" = "yes" ] \ + && [ "${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 shutdown ${DOM_ID} > /dev/null + done + + if [ -n "${LIBVIRTD_KVM_SHUTDOWN_MAXWAIT}" ] ; then + COUNTER="${LIBVIRTD_KVM_SHUTDOWN_MAXWAIT}" + else + COUNTER=100 + fi + + 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 + + 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" + start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/libvirtd.pid --oknodo + eend $? +} |