From nobody Thu May 2 04:52:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516115281474598.0225323905651; Tue, 16 Jan 2018 07:08:01 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D1EE31A0FC; Tue, 16 Jan 2018 15:07:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94CDC869F2; Tue, 16 Jan 2018 15:07:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B91BC539A1; Tue, 16 Jan 2018 15:06:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0GF5w48009942 for ; Tue, 16 Jan 2018 10:05:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0918960499; Tue, 16 Jan 2018 15:05:58 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03F506EE41 for ; Tue, 16 Jan 2018 15:05:49 +0000 (UTC) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DBD57E428 for ; Tue, 16 Jan 2018 15:05:30 +0000 (UTC) Received: from 178.43.177.64.ipv4.supernova.orange.pl ([178.43.177.64] helo=leonard.home) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ebSno-0005kY-V2 for libvir-list@redhat.com; Tue, 16 Jan 2018 15:05:29 +0000 From: Dariusz Gadomski To: libvir-list@redhat.com Date: Tue, 16 Jan 2018 16:05:26 +0100 Message-Id: <20180116150526.7655-1-dariusz.gadomski@canonical.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 16 Jan 2018 15:05:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 16 Jan 2018 15:05:30 +0000 (UTC) for IP:'91.189.89.112' DOMAIN:'youngberry.canonical.com' HELO:'youngberry.canonical.com' FROM:'dariusz.gadomski@canonical.com' RCPT:'' X-RedHat-Spam-Score: -5.01 (RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD) 91.189.89.112 youngberry.canonical.com 91.189.89.112 youngberry.canonical.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tools: avoid text spilling into variables X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 16 Jan 2018 15:07:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Christian Ehrhardt While libvirt-guests.sh is running cases can let guest_is_on fail which causes check_guests_shutdown to print output. That output shall not spill into the users of function check_guests_shutdown which is therefore now returning values in a variable like guest_is_on already did. Original-Author: Christian Ehrhardt Modified-By: Jorge Niedbalski --- tools/libvirt-guests.sh.in | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in index 8a158cca4..91a2f3283 100644 --- a/tools/libvirt-guests.sh.in +++ b/tools/libvirt-guests.sh.in @@ -329,12 +329,13 @@ guest_count() # check_guests_shutdown URI GUESTS # check if shutdown is complete on guests in "GUESTS" and returns only # guests that are still shutting down +# Result is returned in "guests_shutting_down" check_guests_shutdown() { uri=3D$1 guests=3D$2 =20 - guests_up=3D + guests_shutting_down=3D for guest in $guests; do if ! guest_is_on "$uri" "$guest" >/dev/null 2>&1; then eval_gettext "Failed to determine state of guest: \$guest. Not= tracking it anymore." @@ -342,10 +343,9 @@ check_guests_shutdown() continue fi if "$guest_running"; then - guests_up=3D"$guests_up $guest" + guests_shutting_down=3D"$guests_shutting_down $guest" fi done - echo "$guests_up" } =20 # print_guests_shutdown URI BEFORE AFTER @@ -392,8 +392,10 @@ shutdown_guests_parallel() guest=3D$1 shift guests=3D$* - shutdown_guest_async "$uri" "$guest" - on_shutdown=3D"$on_shutdown $guest" + if [ -z "$(echo $on_shutdown | grep $guest)" -a -n "$(guest_na= me "$uri" "$guest")" ]; then + shutdown_guest_async "$uri" "$guest" + on_shutdown=3D"$on_shutdown $guest" + fi done sleep 1 =20 @@ -420,7 +422,8 @@ shutdown_guests_parallel() fi =20 on_shutdown_prev=3D$on_shutdown - on_shutdown=3D$(check_guests_shutdown "$uri" "$on_shutdown") + check_guests_shutdown "$uri" "$on_shutdown" + on_shutdown=3D"$guests_shutting_down" print_guests_shutdown "$uri" "$on_shutdown_prev" "$on_shutdown" done } --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list