[libvirt] [PATCH] tools: fix check_guests_shutdown loop

Christian Ehrhardt posted 1 patch 6 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1523956517-26888-1-git-send-email-christian.ehrhardt@canonical.com
Test syntax-check passed
tools/libvirt-guests.sh.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[libvirt] [PATCH] tools: fix check_guests_shutdown loop
Posted by Christian Ehrhardt 6 years ago
The recent fix to libvirt-guests.sh.in works for what it intended to fix
(variable scope) but failed to adapt the loop in check_guests_shutdown
correctly. Due to that it currently might detect all guests as "Failed to
determine state of guest" by bad var content or just assumes they are shut
down by picking up an empty variable.

This commit fixes loop to use the passed value and the call in the loop
to actually use the variable assigned in the iterated.

Fixes: 7e476356 "tools: fix variable scope in in check_guests_shutdown"
Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1764668

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
---
 tools/libvirt-guests.sh.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
index fcada31..28fe506 100644
--- a/tools/libvirt-guests.sh.in
+++ b/tools/libvirt-guests.sh.in
@@ -336,8 +336,8 @@ check_guests_shutdown()
     guests_to_check=$2
 
     guests_shutting_down=
-    for guest in $guests; do
-        if ! guest_is_on "$uri" "$guests_to_check" >/dev/null 2>&1; then
+    for guest in $guests_to_check; 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."
             echo
             continue
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tools: fix check_guests_shutdown loop
Posted by Dariusz Gadomski 6 years ago
On Tue, Apr 17, 2018 at 11:15:17AM +0200, Christian Ehrhardt wrote:
> The recent fix to libvirt-guests.sh.in works for what it intended to fix
> (variable scope) but failed to adapt the loop in check_guests_shutdown
> correctly. Due to that it currently might detect all guests as "Failed to
> determine state of guest" by bad var content or just assumes they are shut
> down by picking up an empty variable.
> 
> This commit fixes loop to use the passed value and the call in the loop
> to actually use the variable assigned in the iterated.
> 
> Fixes: 7e476356 "tools: fix variable scope in in check_guests_shutdown"
> Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1764668
> 
> Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> ---
>  tools/libvirt-guests.sh.in | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Dariusz Gadomski <dariusz.gadomski@canonical.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list