[libvirt] [PATCH] libvirt-guests: Remove LISTFILE if it's empty when stopping service

$LISTFILE is created even no domain is running, and the empty $LISTFILE could cause improper service status. stoped ,with saved guests Which is not right, as there is no domain was saved. --- tools/libvirt-guests.init.sh | 42 +++++++++++++++++++++++------------------- 1 files changed, 23 insertions(+), 19 deletions(-) diff --git a/tools/libvirt-guests.init.sh b/tools/libvirt-guests.init.sh index aafb4d4..c0d8a7e 100644 --- a/tools/libvirt-guests.init.sh +++ b/tools/libvirt-guests.init.sh @@ -461,26 +461,30 @@ stop() { done set +f - while read uri list; do - if "$suspending"; then - eval_gettext "Suspending guests on \$uri URI..."; echo - else - eval_gettext "Shutting down guests on \$uri URI..."; echo - fi + if [ -s $LISTFILE ]; then + while read uri list; do + if "$suspending"; then + eval_gettext "Suspending guests on \$uri URI..."; echo + else + eval_gettext "Shutting down guests on \$uri URI..."; echo + fi - if [ "$PARALLEL_SHUTDOWN" -gt 1 ] && - ! "$suspending"; then - shutdown_guests_parallel "$uri" "$list" - else - for guest in $list; do - if "$suspending"; then - suspend_guest "$uri" "$guest" - else - shutdown_guest "$uri" "$guest" - fi - done - fi - done <"$LISTFILE" + if [ "$PARALLEL_SHUTDOWN" -gt 1 ] && + ! "$suspending"; then + shutdown_guests_parallel "$uri" "$list" + else + for guest in $list; do + if "$suspending"; then + suspend_guest "$uri" "$guest" + else + shutdown_guest "$uri" "$guest" + fi + done + fi + done <"$LISTFILE" + else + rm -f $LISTFILE + fi rm -f "$VAR_SUBSYS_LIBVIRT_GUESTS" } -- 1.7.7.3

On 05/14/2012 01:21 AM, Osier Yang wrote:
$LISTFILE is created even no domain is running, and the empty $LISTFILE could cause improper service status.
stoped ,with saved guests
Do we really say "stoped", or is that a typo in the commit message?
Which is not right, as there is no domain was saved. --- tools/libvirt-guests.init.sh | 42 +++++++++++++++++++++++------------------- 1 files changed, 23 insertions(+), 19 deletions(-)
Missing quotes:
+ if [ -s $LISTFILE ]; then
if [ -s "$LISTFILE" ]; then
+ else + rm -f $LISTFILE
rm -f "$LISTFILE" Looks like the rest of the patch is just reindentation after the added if statement; ACK with the quoting fixes. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 2012年05月15日 00:13, Eric Blake wrote:
On 05/14/2012 01:21 AM, Osier Yang wrote:
$LISTFILE is created even no domain is running, and the empty $LISTFILE could cause improper service status.
stoped ,with saved guests
Do we really say "stoped", or is that a typo in the commit message?
Yes, it's a typo. :-)
Which is not right, as there is no domain was saved. --- tools/libvirt-guests.init.sh | 42 +++++++++++++++++++++++------------------- 1 files changed, 23 insertions(+), 19 deletions(-)
Missing quotes:
+ if [ -s $LISTFILE ]; then
if [ -s "$LISTFILE" ]; then
+ else + rm -f $LISTFILE
rm -f "$LISTFILE"
Looks like the rest of the patch is just reindentation after the added if statement; ACK with the quoting fixes.
Thanks, pushed with the quotes added. Regards, Osier
participants (2)
-
Eric Blake
-
Osier Yang