[rgmanager] Add optional save/restore to vm resource
authorLon Hohberger <lhh@redhat.com>
Tue, 22 Jul 2008 15:01:53 +0000 (11:01 -0400)
committerLon Hohberger <lhh@redhat.com>
Tue, 22 Jul 2008 15:01:53 +0000 (11:01 -0400)
This patch adds optional save/restore support to virtual machines.
Patch Federico Simoncelli federico dot simoncelli at gmail dot com

rgmanager/src/resources/vm.sh

index 15e1f2a9a418e931f515f3f9303898f73b3131b4..e72cbbbd3021ad8fcd04cdf99524f52595e87cbf 100644 (file)
@@ -211,6 +211,18 @@ meta_data()
             <content type="string" default="live"/>
         </parameter>
 
+       <parameter name="snapshot">
+           <longdesc lang="en">
+               Path to the snapshot directory where the virtual machine
+               image will be stored.
+           </longdesc>
+           <shortdesc lang="en">
+               Path to the snapshot directory where the virtual machine
+               image will be stored.
+           </shortdesc>
+            <content type="string" default=""/>
+        </parameter>
+
         <parameter name="depend">
             <longdesc lang="en">
                Top-level service this depends on, in "service:name" format.
@@ -346,6 +358,8 @@ build_xm_cmdline()
                        ;;
                migrate)
                        ;;
+               snapshot)
+                       ;;
                *)
                        cmdline="$cmdline $varp=\"$val\""
                        ;;
@@ -370,9 +384,21 @@ do_start()
        # doesn't exist...
        #
        declare cmdline
+       declare snapshotimage
 
        status && return 0
 
+       snapshotimage="$OCF_RESKEY_snapshot/$OCF_RESKEY_name"
+
+        if [ -n "$OCF_RESKEY_snapshot" -a -f "$snapshotimage" ]; then
+               eval xm restore $snapshotimage
+               if [ $? -eq 0 ]; then
+                       rm -f $snapshotimage
+                       return 0
+               fi
+               return 1
+       fi
+
        cmdline="`build_xm_cmdline`"
 
        echo "# xm command line: $cmdline"
@@ -392,6 +418,10 @@ do_stop()
        declare -i ret=1
        declare st
 
+       if [ -n "$OCF_RESKEY_snapshot" ]; then
+               xm save $OCF_RESKEY_name "$OCF_RESKEY_snapshot/$OCF_RESKEY_name"
+       fi
+
        for op in $*; do
                echo xm $op $OCF_RESKEY_name ...
                xm $op $OCF_RESKEY_name
This page took 0.088517 seconds and 5 git commands to generate.