summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2012-11-22 13:14:56 +0100
committerDominique Martinet <asmadeus@codewreck.org>2012-11-22 13:22:25 +0100
commit23807de6c7b3296eac292a5ec5d9d10beaf67794 (patch)
tree5f282ec8297e27778a9e25732f66fbb8595f2c79
parentfba0e40a1bd5f2b1710ecac156c0b28dc7611d97 (diff)
migrate: wait the proper amount of time for the migration receiver to be ready
-rwxr-xr-xkvm-wrapper.sh21
1 files changed, 16 insertions, 5 deletions
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index 84f4145..4f09aa2 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -805,8 +805,7 @@ function kvm_migrate_vm ()
PORT=$((RANDOM%1000+4000))
# Launch new instance (on pre-configured node)
- "$SCRIPT_PATH" receive-migrate "$VM_NAME" $PORT
- sleep 1
+ "$SCRIPT_PATH" receive-migrate "$VM_NAME" "$PORT"
monitor_send_cmd "migrate_set_speed 1024m"
# monitor_send_cmd "migrate \"exec: ssh `get_cluster_host $REMOTE_NODE` socat - unix:$RUN_DIR/migrate-$REMOTE_NODE.sock\""
@@ -816,6 +815,19 @@ function kvm_migrate_vm ()
function kvm_receive_migrate_vm ()
{
+ local PORT="$2"
+
+ $SCREEN_START_DETACHED "$SCREEN_SESSION_NAME" $SCREEN_EXTRA_OPTS "$SCRIPT_PATH" receive-migrate-here "$VM_NAME" "$PORT"
+
+ # Wait for the receiving qemu is ready.
+ #while ! test_exist $RUN_DIR/migrate-$VM_NAME.sock; do
+ while ! netstat -nplt | grep -q ":$PORT "; do
+ sleep 1;
+ done
+}
+
+function kvm_receive_migrate_here_vm ()
+{
local PORT="$2"
# KVM_ADDITIONNAL_PARAMS+=" -incoming unix:$RUN_DIR/migrate-$VM_NAME.sock"
@@ -1091,13 +1103,12 @@ case "$1" in
;;
receive-migrate-here)
if [[ $# -eq 3 ]]; then
- kvm_receive_migrate_vm "$2" "$3"
+ kvm_receive_migrate_here_vm "$2" "$3"
else print_help; fi
;;
receive-migrate)
if [[ $# -eq 3 ]]; then
- $SCREEN_START_DETACHED "$SCREEN_SESSION_NAME" $SCREEN_EXTRA_OPTS "$SCRIPT_PATH" receive-migrate-here "$VM_NAME" "$3"
- sleep 1
+ kvm_receive_migrate_vm "$VM_NAME" "$3"
else print_help; fi
;;
save-state)