Index: /drbl-virt/sbin/check_drbl_VM
===================================================================
--- /drbl-virt/sbin/check_drbl_VM	(revision 222)
+++ /drbl-virt/sbin/check_drbl_VM	(revision 222)
@@ -0,0 +1,80 @@
+#!/bin/bash
+# Program:
+#   Check DRBL client status
+# Author: 
+#   Jazz, Rock {jazz, rock}@nchc.org.tw
+# Version:
+#    1.0
+# History:                                                                                          
+#   2010/08/29  Rock    First release (1.0) 
+
+source /opt/drbl-virt/conf/drbl-virt.conf
+source $Work_Path/functions_drbl_virt
+
+
+# [Varliables]
+client_IPs=$(cat $Work_Home/etc/IP_HOST_TABLE | grep -v "#" | awk '{print $1}')
+drbl_vm_file="/tmp/drbl_vm_status.$$"
+drbl_vm_xentop_file="/tmp/drbl_vm_xentop.$$"
+# check Xen or KVM
+hypervisior=$(cat $Work_Home/etc/hypervisior)
+
+
+# [Main] 
+check_root
+
+case $hypervisior in
+    "Xen")
+    for client_IP in $client_IPs
+    do
+        # local variables
+        IP_status="online"
+        client_hostname="$(cat $Work_Home/etc/IP_HOST_TABLE | grep -v "#" | grep $client_IP | awk '{print $2}')"
+        vm_numbers=""
+        vm_hostnames=""
+        vm_IP=""
+        vm_CPU_core=""
+        vm_Ram=""
+        vm_CPU_loading=""
+        vm_Ram_loading=""
+        # check network status
+        ping -c1 -w1 $client_IP > /dev/null 2>&1 || IP_status="offline"
+    
+        if [ $IP_status == "online" ]; then
+            ssh -o StrictHostKeyChecking=no $client_IP "xentop -d1 -b -i2 | awk '/^.*NAME/{i++}i==2'" > $drbl_vm_xentop_file
+            vm_hostnames="$(cat $drbl_vm_xentop_file | sed -n '3,$p' | awk '{print $1}')"
+    
+            # printf "[$client_hostname] " >> $drbl_vm_file
+            printf "[$client_hostname] "
+            declare -i i=1
+
+            vm_numbers=$(echo $vm_hostnames | wc -w)
+
+           # printf "[Running VM: $vm_numbers]\n" >> $drbl_vm_file
+            printf "[Running VM: $vm_numbers]\n"
+
+            for vm_hostname in $vm_hostnames
+            do  
+                vm_CPU_core="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $9}')"
+                vm_Ram="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $5}')"
+                vm_CPU_loading="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $4}')"
+                vm_Ram_loading="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $6}')"
+               # printf "VM$i: $vm_hostname $vm_CPU_core ${vm_Ram}K $vm_CPU_loading%% $vm_Ram_loading%%\n" >> $drbl_vm_file
+                printf "VM$i: $vm_hostname VCPU=$vm_CPU_core Mem=${vm_Ram}K VCPU_loading=$vm_CPU_loading%% Mem_usage=$vm_Ram_loading%%\n"
+                i=i+1
+            done
+            echo "" 
+        else
+            echo "[Error] $client_hostname $client_IP is offline !"
+
+        fi
+
+    done
+    ;;
+
+    "KVM")
+        echo "KVM"
+    ;;
+esac
+# dlete tmp file
+rm -f $drbl_vm_xentop_file
Index: bl-virt/sbin/check_drbl_XenVM
===================================================================
--- /drbl-virt/sbin/check_drbl_XenVM	(revision 221)
+++ 	(revision )
@@ -1,69 +1,0 @@
-#!/bin/bash
-# Program:
-#   Check DRBL client status
-# Author: 
-#   Jazz, Rock {jazz, rock}@nchc.org.tw
-# Version:
-#    1.0
-# History:                                                                                          
-#   2010/08/29  Rock    First release (1.0) 
-
-source /opt/drbl-virt/conf/drbl-virt.conf
-source $Work_Path/functions_drbl_virt
-
-
-# [Varliables]
-client_IPs=$(cat $Work_Home/etc/IP_HOST_TABLE | grep -v "#" | awk '{print $1}')
-drbl_vm_file="/tmp/drbl_vm_status.$$"
-drbl_vm_xentop_file="/tmp/drbl_vm_xentop.$$"
-
-# [Main] 
-check_root
-for client_IP in $client_IPs
-do
-    # local variables
-    IP_status="online"
-    client_hostname="$(cat $Work_Home/etc/IP_HOST_TABLE | grep -v "#" | grep $client_IP | awk '{print $2}')"
-    vm_numbers=""
-    vm_hostnames=""
-    vm_IP=""
-    vm_CPU_core=""
-    vm_Ram=""
-    vm_CPU_loading=""
-    vm_Ram_loading=""
-    # check network status
-    ping -c1 -w1 $client_IP > /dev/null 2>&1 || IP_status="offline"
-    
-    if [ $IP_status == "online" ]; then
-        ssh -o StrictHostKeyChecking=no $client_IP "xentop -d1 -b -i2 | awk '/^.*NAME/{i++}i==2'" > $drbl_vm_xentop_file
-        vm_hostnames="$(cat $drbl_vm_xentop_file | sed -n '3,$p' | awk '{print $1}')"
-    
-#        printf "[$client_hostname] " >> $drbl_vm_file
-        printf "[$client_hostname] "
-        declare -i i=1
-
-        vm_numbers=$(echo $vm_hostnames | wc -w)
-
-#        printf "[Running VM: $vm_numbers]\n" >> $drbl_vm_file
-        printf "[Running VM: $vm_numbers]\n"
-
-        for vm_hostname in $vm_hostnames
-        do  
-            vm_CPU_core="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $9}')"
-            vm_Ram="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $5}')"
-            vm_CPU_loading="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $4}')"
-            vm_Ram_loading="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $6}')"
-#            printf "VM$i: $vm_hostname $vm_CPU_core ${vm_Ram}K $vm_CPU_loading%% $vm_Ram_loading%%\n" >> $drbl_vm_file
-            printf "VM$i: $vm_hostname VCPU=$vm_CPU_core Mem=${vm_Ram}K VCPU_loading=$vm_CPU_loading%% Mem_usage=$vm_Ram_loading%%\n"
-            i=i+1
-        done
-        echo "" 
-    else
-        echo "[Error] $client_hostname $client_IP is offline !"
-
-    fi
-
-done
-
-# dlete tmp file
-rm -f $drbl_vm_xentop_file
Index: /drbl-virt/sbin/drbl_VM_migration
===================================================================
--- /drbl-virt/sbin/drbl_VM_migration	(revision 222)
+++ /drbl-virt/sbin/drbl_VM_migration	(revision 222)
@@ -0,0 +1,119 @@
+#!/bin/bash
+# Program:
+#   Deploy PXE PV VM to DRBL client
+# Author: 
+#   Jazz, Rock {jazz, rock}@nchc.org.tw
+# Version:
+#    1.0
+# History:                                                                                          
+#   2010/08/27  Rock    First release (1.0) 
+
+# [Source]
+source /opt/drbl-virt/conf/drbl-virt.conf
+source $Work_Path/functions_drbl_virt
+#source ./functions_drbl_PXE_PV-VM_create
+
+
+# [Declation]
+# = 1. Varibales declation =
+#vm_dir="/home/domains"
+hypervisior=$(cat $Work_Home/etc/hypervisior)
+
+# = 2. Functions declation =
+Usage(){
+echo "Usage: drbl_VM_migrate options"
+echo "Options:"
+echo "-l|--live           live migration"
+echo "-h|--host           host name"
+echo "-v|--vm             vm name"
+echo "Example:"
+echo "drbl_VM_migrate -l -h pc102 -v pc131"
+}
+
+
+# [Main]
+check_root
+# = 1. Parse parameters = 
+if [ $# -eq 0 ]; then
+Usage && exit
+fi
+
+while [ $# -gt 0 ]; do
+    case "$1" in
+        -h|--host)
+            shift 
+            if [ -z "$(echo $1 |grep ^-.)" ]; then
+                if [ -n "$(echo $1)" ]; then
+                    host="$1"
+                else
+                    echo "-h host value is null"
+                    Usage && exit 2
+                fi
+            shift 
+            fi 
+            ;; 
+        -v|--vm)
+            shift 
+            if [ -z "$(echo $1 |grep ^-.)" ]; then
+                if [ -n "$(echo $1)" ]; then
+                    vm="$1"
+                else
+                    echo "-v vm value is null"
+                    Usage && exit 2
+                fi  
+            shift 
+            fi  
+            ;;
+        -l|--live)
+            shift
+            xm_option="live"
+            ;;
+        -*)
+            echo "$0 $1 invalid option" >&2
+            echo ""
+            Usage >&2
+            exit 2
+            ;;
+        *)  Usage >&2
+            exit 2
+            ;;
+    esac
+done
+
+
+# = 2. Check null value =
+[ -z "$host" ] && echo "[Error] no host" && Usage && exit 2
+[ -z "$vm" ] && echo "[Error] no vm" && Usage && exit 2
+
+
+# = 3. ssh client to execute command  =
+# check network
+IP_status="online"
+ping -c1 -w1 $host > /dev/null 2>&1 || IP_status="offline"
+
+if [ $IP_status == "offline" ]; then
+    echo "[Error] $host's network is offline !!!"
+else
+    host_hostnames="$(grep -v "#" $Work_Home/etc/IP_HOST_TABLE | awk '{print $2}')"
+
+    for host_hostname in $host_hostnames
+    do
+        ssh -o StrictHostKeyChecking=no $host_hostname "xm list | grep $vm" > /tmp/vm_in_host_file$$
+        vm_in_host=$(cat /tmp/vm_in_host_file$$)
+        if [ -n "$vm_in_host" ]; then
+            right_host=$host_hostname
+            break
+        fi
+    echo "$host_name"
+    done
+
+    if [ -z $xm_option ]; then
+        ssh -o StrictHostKeyChecking=no $right_host "xm migrate $vm $host"
+    else
+        ssh -o StrictHostKeyChecking=no $right_host "xm migrate --$xm_option $vm $host"
+    fi
+fi
+
+rm /tmp/vm_in_host_file$$
+check_drbl_VM 
+
Index: /drbl-virt/sbin/drbl_client_cmd
===================================================================
--- /drbl-virt/sbin/drbl_client_cmd	(revision 221)
+++ /drbl-virt/sbin/drbl_client_cmd	(revision 222)
@@ -22,10 +22,10 @@
 # = 2. Functions declation =
 Usage(){
-echo "Usage: drbl_xen_cmd.sh options"
+echo "Usage: drbl_xen_cmd options"
 echo "Options:"
 echo "-c|--client         client name"
 echo "-x|--execute        execute command"
 echo "Example:"
-echo "drbl_xen_cmd.sh -c drbl101 -x 'shutdown'"
+echo "drbl_xen_cmd -c drbl101 -x 'shutdown'"
 }
 
@@ -46,5 +46,5 @@
                     client_name=$1
                 else
-                    echo "-h host_value is null"
+                    echo "-h client value is null"
                     Usage && exit 2
                 fi
