Skip to content

Instantly share code, notes, and snippets.

@elmarco
Created November 13, 2013 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elmarco/7456234 to your computer and use it in GitHub Desktop.
Save elmarco/7456234 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -x
trap 'kill 0' EXIT
qemu_start() {
local port=$1
qemu-system-x86_64 -m 1024 -vga qxl -spice addr=0.0.0.0,tls-port=$port,disable-ticketing,x509-dir=. -monitor unix:qemu-$port,server,nowait
}
qemu_start_incoming() {
local port=$1
local incoming_port=$2
qemu-system-x86_64 -m 1024 -vga qxl -spice tls-port=$port,addr=0.0.0.0,disable-ticketing,x509-dir=. -incoming tcp:0:$incoming_port -monitor unix:qemu-$port,server,nowait
}
qemu_do () {
local port=$1
local cmd="$2"
echo "$cmd" | socat - UNIX-CONNECT:qemu-$port
}
qemu_migrate () {
local port=$1
local incoming_port=$2
local migrate_info="$3"
qemu_do $port "client_migrate_info $migrate_info"
qemu_do $port "migrate -d tcp:localhost:$incoming_port"
sleep 1 # qemu bug? doesn't wait for migration to complete, weird section error on dest
qemu_do $port "quit"
}
qemu_start 5914 &
QEMU_5914=$!
while true ; do
qemu_start_incoming 5915 4445 &
QEMU_5915=$!
sleep 5
qemu_migrate 5914 4445 "spice 192.168.1.42 0 5915"
wait $QEMU_5914
qemu_start_incoming 5914 4444 &
QEMU_5914=$!
sleep 5
qemu_migrate 5915 4444 "spice 192.168.1.42 0 5914"
wait $QEMU_5915
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment