summaryrefslogtreecommitdiffstats
path: root/kvm-wrapper.sh
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2015-07-02 18:25:00 +0200
committerDominique Martinet <asmadeus@codewreck.org>2015-07-02 18:26:37 +0200
commit7bcf291638705541cf11eb01a091d8f95c8ae21c (patch)
tree3287b629c5714b70f3a0168d1f858fdefc124359 /kvm-wrapper.sh
parentd44e741817745a700c036cded2826605d3909957 (diff)
Migrate stuff: allow for different protocol (RDMA, woo), wait more accurately for when VM is ready for receive, wait for migrate to finish properly to work around qemu bug
Diffstat (limited to 'kvm-wrapper.sh')
-rwxr-xr-xkvm-wrapper.sh35
1 files changed, 23 insertions, 12 deletions
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index 51ba179..dc2cfc1 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -861,25 +861,33 @@ function kvm_migrate_vm ()
PORT=$((RANDOM%1000+4000))
# Launch new instance (on pre-configured node)
- "$SCRIPT_PATH" receive-migrate "$VM_NAME" "$PORT"
+ if ! "$SCRIPT_PATH" receive-migrate "$VM_NAME" "$PORT"; then
+ desc_revert_setting "KVM_CLUSTER_NODE"
+ fail_exit "Could not receive migrate on remote host"
+ fi
+
+ sleep 0.5
- monitor_send_cmd "migrate_set_speed 1024m"
+ # default speed is 32MiB/s, apparently. Set it higher.
+ monitor_send_cmd "migrate_set_speed 100g"
# monitor_send_cmd "migrate \"exec: ssh `get_cluster_host $REMOTE_NODE` socat - unix:$RUN_DIR/migrate-$REMOTE_NODE.sock\""
- monitor_send_cmd "migrate tcp:`get_cluster_host $REMOTE_NODE`:$PORT"
+ monitor_send_cmd "migrate ${KVM_MIGRATE_TRANSPORT:-tcp}:`get_cluster_host $REMOTE_NODE`:$PORT"
+ while ! echo "info migrate" | socat - unix:"$MONITOR_FILE" | grep -q "Migration status: completed"; do
+ sleep 1
+ done
monitor_send_cmd "quit"
}
function kvm_receive_migrate_vm ()
{
- local PORT="$2"
+ local PORT="$2"
- eval KVM_SCREEN="yes" $SCREEN_START_DETACHED "$SCREEN_SESSION_NAME" $SCREEN_EXTRA_OPTS "$SCRIPT_PATH" receive-migrate-here "$VM_NAME" "$PORT"
+ eval KVM_SCREEN="yes" $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
+ # Wait for the receiving qemu is ready.
+ while ! monitor_send_cmd "info status" >&/dev/null; do
+ sleep 0.1
+ done
}
function kvm_receive_migrate_here_vm ()
@@ -887,7 +895,7 @@ function kvm_receive_migrate_here_vm ()
local PORT="$2"
# KVM_ADDITIONNAL_PARAMS+=" -incoming unix:$RUN_DIR/migrate-$VM_NAME.sock"
- KVM_ADDITIONNAL_PARAMS+=" -incoming tcp:`get_cluster_host $(hostname -s)`:$PORT"
+ KVM_ADDITIONNAL_PARAMS+=" -incoming ${KVM_MIGRATE_TRANSPORT:-tcp}:`get_cluster_host $(hostname -s)`:$PORT"
FORCE="yes"
kvm_start_vm "$VM_NAME"
}
@@ -897,8 +905,11 @@ kvm_save_state_vm ()
! test_exist "$PID_FILE" && fail_exit "Error: $VM_NAME doesn't seem to be running."
! test_socket_rw "$MONITOR_FILE" && fail_exit "Error: could not open monitor socket $MONITOR_FILE."
monitor_send_cmd "stop"
- monitor_send_cmd "migrate_set_speed 4095m"
+ monitor_send_cmd "migrate_set_speed 100g"
monitor_send_cmd "migrate \"exec:gzip -c > $CACHE_DIR/$VM_NAME-state.gz\""
+ while ! echo "info migrate" | socat - unix:"$MONITOR_FILE" | grep -q "Migration status: completed"; do
+ sleep 1
+ done
monitor_send_cmd "quit"
}