[libvirt] [PATCH 2/4] libvirt-guests: Don't try to do a managed-save of transient guests

Peter Krempa pkrempa at redhat.com
Tue Feb 28 18:00:38 UTC 2012


The libvirt-guests script tried to do a managed save of transient guest
that failed. This patch notifies which guests are transient (and not
being saved) and saves only the persistent ones.
---
 tools/libvirt-guests.init.sh |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/tools/libvirt-guests.init.sh b/tools/libvirt-guests.init.sh
index 0d2fc24..21a7d31 100644
--- a/tools/libvirt-guests.init.sh
+++ b/tools/libvirt-guests.init.sh
@@ -293,13 +293,46 @@ stop() {
                 printf %s "$(guest_name "$uri" "$uuid")"
                 empty=false
             done
+
             if "$empty"; then
-                gettext "no running guests."; echo
+                gettext "no running guests."
+            fi
+            echo
+        fi
+
+        if "$suspending"; then
+            transient=$(list_guests "$uri" "--transient")
+            if [ $? -eq 0 ]; then
+                empty=true
+                for uuid in $transient; do
+                    if "$empty"; then
+                        eval_gettext "Not suspending transient guests on URI: \$uri: "
+                        empty=false
+                    else
+                        printf ", "
+                    fi
+                    printf %s "$(guest_name "$uri" "$uuid")"
+                done
+                echo
+                # reload domain list to contain only persistent guests
+                list=$(list_guests "$uri" "--persistent")
+                if [ $? -ne 0 ]; then
+                    eval_gettext "Failed to list persistent guests on \$uri"
+                    echo
+                    RETVAL=1
+                    return
+                fi
             else
+                gettext "Failed to list transient guests"
                 echo
-                echo "$uri" "$list" >>"$LISTFILE"
+                RETVAL=1
+                return
             fi
         fi
+
+        if [ -n "$list" ]; then
+            echo "$uri" "$list" >>"$LISTFILE"
+        fi
     done
     set +f

-- 
1.7.3.4




More information about the libvir-list mailing list