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 711F41384C0 for ; Fri, 28 Aug 2015 13:48:32 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7F99D141D5; Fri, 28 Aug 2015 13:48:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1576F141D5 for ; Fri, 28 Aug 2015 13:48:29 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0F03F340BD7 for ; Fri, 28 Aug 2015 13:48:28 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A91EE155 for ; Fri, 28 Aug 2015 13:48:25 +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: <1440769675.5ed04d55b9a56c932128d867b596bebc6e3ff4ce.cardoe@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/libvirt/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: app-emulation/libvirt/files/libvirt-guests.confd app-emulation/libvirt/files/libvirt-guests.init X-VCS-Directories: app-emulation/libvirt/files/ X-VCS-Committer: cardoe X-VCS-Committer-Name: Doug Goldstein X-VCS-Revision: 5ed04d55b9a56c932128d867b596bebc6e3ff4ce X-VCS-Branch: master Date: Fri, 28 Aug 2015 13:48:25 +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: c15208c9-954a-46bd-9c75-4f23229e2346 X-Archives-Hash: 4aaf321f86e9713089e333278305b6ae commit: 5ed04d55b9a56c932128d867b596bebc6e3ff4ce Author: Doug Goldstein gentoo org> AuthorDate: Fri Aug 28 13:35:39 2015 +0000 Commit: Doug Goldstein gentoo org> CommitDate: Fri Aug 28 13:47:55 2015 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5ed04d55 app-emulation/libvirt: tweak libvirt-guests init script After discussing the new init script on bug #558034 there are two tweaks being added: * shift the first argument so that future uses can pass in more arguments to virsh and the wrapper commands. * Added LIBVIRT_IGNORE_AUTOSTART to ignore domains that start marked for autostart in the libvirt XML. Signed-off-by: Doug Goldstein gentoo.org> app-emulation/libvirt/files/libvirt-guests.confd | 10 +++++++ app-emulation/libvirt/files/libvirt-guests.init | 33 +++++++++++++++++++----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/app-emulation/libvirt/files/libvirt-guests.confd b/app-emulation/libvirt/files/libvirt-guests.confd index 6e98dc2..514c8ee 100644 --- a/app-emulation/libvirt/files/libvirt-guests.confd +++ b/app-emulation/libvirt/files/libvirt-guests.confd @@ -39,6 +39,16 @@ #LIBVIRT_MAXWAIT="500" +# LIBVIRT_IGNORE_AUTOSTART +# If the VM is marked for autostart in its XML configuration then we won't +# save its start when the init script is stopped. The result is that when +# the init script starts back up, no attempt will be made to start the VM or +# confirm it is started. +# Valid values are yes or no + +#LIBVIRT_IGNORE_AUTOSTART="no" + + # LIBVIRT_NET_SHUTDOWN # If libvirtd created networks for you (e.g. NATed networks) then this init # script will shut them down for you if this is set to 'yes'. Otherwise, diff --git a/app-emulation/libvirt/files/libvirt-guests.init b/app-emulation/libvirt/files/libvirt-guests.init index 045f04d..2b63dea 100644 --- a/app-emulation/libvirt/files/libvirt-guests.init +++ b/app-emulation/libvirt/files/libvirt-guests.init @@ -38,20 +38,32 @@ do_virsh() { libvirtd_dom_list() { # Only work with domains by their UUIDs - do_virsh "$1" list --uuid $2 + local hvuri=$1 + shift + + do_virsh "${hvuri}" list --uuid $@ } libvirtd_dom_count() { - libvirtd_dom_list "$1" $2 | wc -l + local hvuri=$1 + shift + + libvirtd_dom_list "${hvuri}" $@ | wc -l } libvirtd_net_list() { # Only work with networks by their UUIDs - do_virsh "$1" net-list --uuid $2 + local hvuri=$1 + shift + + do_virsh "${hvuri}" net-list --uuid $@ } libvirtd_net_count() { - libvirtd_net_list "$1" $2 | wc -l + local hvuri=$1 + shift + + libvirtd_net_list "${hvuri}" $@ | wc -l } libvirtd_dom_stop() { @@ -64,6 +76,7 @@ libvirtd_dom_stop() { local shutdown_type=${LIBVIRT_SHUTDOWN} local counter=${LIBVIRT_MAXWAIT} local dom_name= + local dom_as= local dom_ids= local uuid= local dom_count= @@ -80,10 +93,18 @@ libvirtd_dom_stop() { # 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 - echo "${uri} ${uuid}" >> ${gueststatefile} + # 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