From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 198C759CA3 for ; Mon, 14 Mar 2016 21:20:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 51C5721C015; Mon, 14 Mar 2016 21:20:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D8B6D21C015 for ; Mon, 14 Mar 2016 21:20:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 34830340C36 for ; Mon, 14 Mar 2016 21:20:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 861BC84F for ; Mon, 14 Mar 2016 21:20:38 +0000 (UTC) From: "Doug Goldstein" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Doug Goldstein" Message-ID: <1457990352.8d5b9e4b342a1a8b1e750373c882260a4fd34a9d.cardoe@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/libvirt/files/, app-emulation/libvirt/ X-VCS-Repository: repo/gentoo X-VCS-Files: app-emulation/libvirt/files/libvirt-guests.init-r2 app-emulation/libvirt/libvirt-1.3.1-r1.ebuild app-emulation/libvirt/libvirt-1.3.2-r1.ebuild app-emulation/libvirt/libvirt-1.3.2.ebuild X-VCS-Directories: app-emulation/libvirt/files/ app-emulation/libvirt/ X-VCS-Committer: cardoe X-VCS-Committer-Name: Doug Goldstein X-VCS-Revision: 8d5b9e4b342a1a8b1e750373c882260a4fd34a9d X-VCS-Branch: master Date: Mon, 14 Mar 2016 21:20:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 68b137c9-36de-49d1-8005-bcca27b796be X-Archives-Hash: 1a8f613dbe33da00fccf2519fca6564e commit: 8d5b9e4b342a1a8b1e750373c882260a4fd34a9d Author: Doug Goldstein gentoo org> AuthorDate: Mon Mar 14 21:18:34 2016 +0000 Commit: Doug Goldstein gentoo org> CommitDate: Mon Mar 14 21:19:12 2016 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8d5b9e4b app-emulation/libvirt: fix libvirt-guests init script The libvirt-guests script incorrectly 'needed' libvirt instead of 'used'. Gentoo-Bug: 576750 Package-Manager: portage-2.2.26 Signed-off-by: Doug Goldstein gentoo.org> app-emulation/libvirt/files/libvirt-guests.init-r2 | 235 +++++++++++++++++++++ ...ibvirt-1.3.2.ebuild => libvirt-1.3.1-r1.ebuild} | 4 +- ...ibvirt-1.3.2.ebuild => libvirt-1.3.2-r1.ebuild} | 2 +- 3 files changed, 238 insertions(+), 3 deletions(-) diff --git a/app-emulation/libvirt/files/libvirt-guests.init-r2 b/app-emulation/libvirt/files/libvirt-guests.init-r2 new file mode 100644 index 0000000..ab2cf3d --- /dev/null +++ b/app-emulation/libvirt/files/libvirt-guests.init-r2 @@ -0,0 +1,235 @@ +#!/sbin/runscript + +description="Virtual Machine Management (libvirt) Guests" + +depend() { + use libvirtd +} + +# set the default to QEMU +[ -z "${LIBVIRT_URIS}" ] && LIBVIRT_URIS="qemu:///system" + +# default to suspending the VM via managedsave +case "${LIBVIRT_SHUTDOWN}" in + managedsave|shutdown|destroy) ;; + *) LIBVIRT_SHUTDOWN="managedsave" ;; +esac + +# default to 500 seconds +[ -z ${LIBVIRT_MAXWAIT} ] && LIBVIRT_MAXWAIT=500 + +gueststatefile="/var/lib/libvirt/libvirt-guests.state" +netstatefile="/var/lib/libvirt/libvirt-net.state" + +do_virsh() { + local hvuri=$1 + shift + + # if unset, default to qemu + [ -z ${hvuri} ] && hvuri="qemu:///system" + # if only qemu was supplied then correct the value + [ "xqemu" = x${hvuri} ] && hvuri="qemu:///system" + + # Silence errors because virsh always throws an error about + # not finding the hypervisor version when connecting to libvirtd + # lastly strip the blank line at the end + LC_ALL=C virsh -c ${hvuri} "$@" 2>/dev/null | head -n -1 +} + +libvirtd_dom_list() { + # Only work with domains by their UUIDs + local hvuri=$1 + shift + + do_virsh "${hvuri}" list --uuid $@ +} + +libvirtd_dom_count() { + local hvuri=$1 + shift + + libvirtd_dom_list "${hvuri}" $@ | wc -l +} + +libvirtd_net_list() { + # Only work with networks by their UUIDs + local hvuri=$1 + shift + + do_virsh "${hvuri}" net-list --uuid $@ +} + +libvirtd_net_count() { + local hvuri=$1 + shift + + libvirtd_net_list "${hvuri}" $@ | wc -l +} + +libvirtd_dom_stop() { + # stops all persistent or transient domains for a given URI + # $1 - uri + # $2 - persisent/transient + + local uri=$1 + local persist=$2 + local shutdown_type=${LIBVIRT_SHUTDOWN} + local counter=${LIBVIRT_MAXWAIT} + local dom_name= + local dom_as= + local dom_ids= + local uuid= + local dom_count= + + [ "${persist}" = "--transient" ] && shutdown_type="shutdown" + [ -n "${counter}" ] || counter=500 + + einfo " Shutting down domain(s) ..." + + # grab all persistent or transient domains running + dom_ids=$(libvirtd_dom_list ${uri} ${persist}) + + for uuid in ${dom_ids}; do + # Get the name + dom_name=$(do_virsh ${uri} domname ${uuid}) + einfo " ${dom_name}" + # Get autostart state + dom_as=$(do_virsh ${uri} dominfo ${uuid} | \ + awk '$1 == "Autostart:" { print $2 }') + + if [ "${persist}" = "--persistent" ]; then + # Save our running state only if LIBVIRT_IGNORE_AUTOSTART != yes + if [ "x${LIBVIRT_IGNORE_AUTOSTART}" = "xyes" ] && \ + [ ${dom_as} = "enabled" ]; then + : + else + echo "${uri} ${uuid}" >> ${gueststatefile} + fi + + fi + + # Now let's stop it + do_virsh "${uri}" ${shutdown_type} ${uuid} > /dev/null + + done + + dom_count="$(libvirtd_dom_count ${uri} ${persist})" + while [ ${dom_count} -gt 0 ] && [ ${counter} -gt 0 ] ; do + dom_count="$(libvirtd_dom_count ${uri} ${persist})" + sleep 1 + if [ "${shutdown_type}" = "shutdown" ]; then + counter=$((${counter} - 1)) + fi + echo -n "." + done + + if [ "${shutdown_type}" = "shutdown" ]; then + # grab all domains still running + dom_ids=$(libvirtd_dom_list ${uri} ${persist}) + for uuid in ${dom_ids}; do + dom_name=$(do_virsh ${uri} domname ${uuid}) + eerror " ${dom_name} forcibly stopped" + do_virsh "${uri}" destroy ${uuid} > /dev/null + done + fi +} + +libvirtd_net_stop() { + # stops all persistent or transient domains for a given URI + # $1 - uri + # $2 - persisent/transient + + local uri=$1 + local persist=$2 + local uuid= + local net_name= + + if [ "${LIBVIRT_NET_SHUTDOWN}" != "no" ]; then + + einfo " Shutting down network(s):" + for uuid in $(libvirtd_net_list ${uri} ${persist}); do + net_name=$(do_virsh ${uri} net-name ${uuid}) + einfo " ${net_name}" + + if [ "${persist}" = "--persistent" ]; then + # Save our running state + echo "${uri} ${uuid}" >> ${netstatefile} + + fi + + # Actually stop the network + do_virsh qemu net-destroy ${uuid} > /dev/null + done + + fi +} + +start() { + local uri= + local uuid= + local name= + + for uri in ${LIBVIRT_URIS}; do + do_virsh "${uri}" connect + if [ $? -ne 0 ]; then + eerror "Failed to connect to '${uri}'. Domains may not start." + fi + done + + [ ! -e "${netstatefile}" ] && touch "${netstatefile}" + [ ! -e "${gueststatefile}" ] && touch "${gueststatefile}" + + # if the user didn't want to start any guests up then respect their wish + [ "x${LIBVIRT_START}" = "xno" ] && return 0 + + # start networks + ebegin "Starting libvirt networks" + while read -r uri uuid + do + # ignore trash + [ -z "${uri}" ] || [ -z "${uuid}" ] && continue + + name=$(do_virsh "${uri}" net-name ${uuid}) + einfo " ${name}" + do_virsh "${uri}" net-start ${uuid} > /dev/null + done <"${netstatefile}" + eend 0 + + # start domains + ebegin "Starting libvirt domains" + while read -r uri uuid + do + # ignore trash + [ -z "${uri}" ] || [ -z "${uuid}" ] && continue + + name=$(do_virsh "${uri}" domname ${uuid}) + einfo " ${name}" + do_virsh "${uri}" start ${uuid} > /dev/null + done <"${gueststatefile}" + eend 0 +} + +stop() { + local counter= + local dom_name= + local net_name= + local dom_ids= + local uuid= + local dom_count= + + rm -f "${gueststatefile}" + [ $? -ne 0 ] && eerror "Unable to save domain state" + rm -f "${netstatefile}" + [ $? -ne 0 ] && eerror "Unable to save net state" + + for uri in ${LIBVIRT_URIS}; do + einfo "Stopping libvirt domains and networks for ${uri}" + + libvirtd_dom_stop "${uri}" "--persistent" + libvirtd_dom_stop "${uri}" "--transient" + libvirtd_net_stop "${uri}" "--persistent" + libvirtd_net_stop "${uri}" "--transient" + + einfo "Done stopping domains and networks for ${uri}" + done +} diff --git a/app-emulation/libvirt/libvirt-1.3.2.ebuild b/app-emulation/libvirt/libvirt-1.3.1-r1.ebuild similarity index 98% copy from app-emulation/libvirt/libvirt-1.3.2.ebuild copy to app-emulation/libvirt/libvirt-1.3.1-r1.ebuild index c963b6a..04ab3c9 100644 --- a/app-emulation/libvirt/libvirt-1.3.2.ebuild +++ b/app-emulation/libvirt/libvirt-1.3.1-r1.ebuild @@ -220,7 +220,7 @@ src_prepare() { epatch \ "${FILESDIR}"/${PN}-1.3.0-do_not_use_sysconf.patch \ "${FILESDIR}"/${PN}-1.2.16-fix_paths_in_libvirt-guests_sh.patch \ - "${FILESDIR}"/${PN}-1.3.1-fix_paths_for_apparmor.patch \ + "${FILESDIR}"/${P}-fix_paths_for_apparmor.patch \ "${FILESDIR}"/${PN}-1.2.21-avoid_deprecated_pc_file.patch [[ -n ${BACKPORTS} ]] && @@ -348,7 +348,7 @@ src_install() { systemd_newtmpfilesd "${FILESDIR}"/libvirtd.tmpfiles.conf libvirtd.conf newinitd "${S}/libvirtd.init" libvirtd || die - newinitd "${FILESDIR}/libvirt-guests.init-r1" libvirt-guests || die + newinitd "${FILESDIR}/libvirt-guests.init-r2" libvirt-guests || die newinitd "${FILESDIR}/virtlockd.init-r1" virtlockd || die newinitd "${FILESDIR}/virtlogd.init-r1" virtlogd || die diff --git a/app-emulation/libvirt/libvirt-1.3.2.ebuild b/app-emulation/libvirt/libvirt-1.3.2-r1.ebuild similarity index 99% rename from app-emulation/libvirt/libvirt-1.3.2.ebuild rename to app-emulation/libvirt/libvirt-1.3.2-r1.ebuild index c963b6a..667ff6e 100644 --- a/app-emulation/libvirt/libvirt-1.3.2.ebuild +++ b/app-emulation/libvirt/libvirt-1.3.2-r1.ebuild @@ -348,7 +348,7 @@ src_install() { systemd_newtmpfilesd "${FILESDIR}"/libvirtd.tmpfiles.conf libvirtd.conf newinitd "${S}/libvirtd.init" libvirtd || die - newinitd "${FILESDIR}/libvirt-guests.init-r1" libvirt-guests || die + newinitd "${FILESDIR}/libvirt-guests.init-r2" libvirt-guests || die newinitd "${FILESDIR}/virtlockd.init-r1" virtlockd || die newinitd "${FILESDIR}/virtlogd.init-r1" virtlogd || die