[libvirt] [PATCH v2 0/2] fix parallel shutdown in libvirt-guests.sh

Working on a few issues in parallel shutdown. The first is fixing a real issue, while the latter avoids printing a message with an empty variable. *Updates since V1* - added Reviewed-by to patch #1 - added second patch to skip the message without a guest nama Christian Ehrhardt (2): tools: fix check_guests_shutdown loop tools: do not report unknown guests in print_guests_shutdown tools/libvirt-guests.sh.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.7.4

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 Reviewed-by: Dariusz Gadomski <dariusz.gadomski@canonical.com> 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

If another event in background while running libvirt-guests.sh completely undefines a guest it will no more be available for proper reporting of its shutdown. This appears in the log as: Failed to determint state of guest: <UUID>. Not tracking it anymore Shutdown of guest complete The first message already reports that we are giving up on the guest (per UUID which is all we have left at that point). To avoid the message with an empty guest_name in such a case lets check what guest_name returned and only print a report on valid content. Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> --- tools/libvirt-guests.sh.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in index 28fe506..4bc6e86 100644 --- a/tools/libvirt-guests.sh.in +++ b/tools/libvirt-guests.sh.in @@ -363,8 +363,10 @@ print_guests_shutdown() esac name=$(guest_name "$uri" "$guest") - eval_gettext "Shutdown of guest \$name complete." - echo + if [ -n "$name" ]; then + eval_gettext "Shutdown of guest \$name complete." + echo + fi done } -- 2.7.4

On Thu, Apr 19, 2018 at 08:41:03AM +0200, Christian Ehrhardt wrote:
If another event in background while running libvirt-guests.sh completely undefines a guest it will no more be available for proper reporting of its shutdown.
This appears in the log as: Failed to determint state of guest: <UUID>. Not tracking it anymore Shutdown of guest complete
The first message already reports that we are giving up on the guest (per UUID which is all we have left at that point). To avoid the message with an empty guest_name in such a case lets check what guest_name returned and only print a report on valid content.
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> --- tools/libvirt-guests.sh.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Reviewed-by: Dariusz Gadomski <dariusz.gadomski@canonical.com>

On Thu, 2018-04-19 at 08:41 +0200, Christian Ehrhardt wrote:
Working on a few issues in parallel shutdown. The first is fixing a real issue, while the latter avoids printing a message with an empty variable.
*Updates since V1* - added Reviewed-by to patch #1 - added second patch to skip the message without a guest nama
Christian Ehrhardt (2): tools: fix check_guests_shutdown loop tools: do not report unknown guests in print_guests_shutdown
tools/libvirt-guests.sh.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Series: Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

On 04/24/2018 10:23 AM, Andrea Bolognani wrote:
On Thu, 2018-04-19 at 08:41 +0200, Christian Ehrhardt wrote:
Working on a few issues in parallel shutdown. The first is fixing a real issue, while the latter avoids printing a message with an empty variable.
*Updates since V1* - added Reviewed-by to patch #1 - added second patch to skip the message without a guest nama
Christian Ehrhardt (2): tools: fix check_guests_shutdown loop tools: do not report unknown guests in print_guests_shutdown
tools/libvirt-guests.sh.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Series:
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Thank you all. I've pushed this. Michal
participants (4)
-
Andrea Bolognani
-
Christian Ehrhardt
-
Dariusz Gadomski
-
Michal Privoznik