Skip to content

[WIP] migration: Support the migration for multi-host #4297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions qemu/tests/cfg/migrate.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
# you can uncomment the following line to enable the state
# check
# vmstate_check = yes
take_regular_screendumps = no # FIXME:
store_vm_info = no # FIXME:
nodes = node1 node2
node_selectors_node1 = [{"key": "cpu_vendor_id", "operator": "eq", "values": "AuthenticAMD"}, {"key": "hostname", "operator": "contains", "values": "redhat.com"}]
node_selectors_node2 = [{"key": "cpu_vendor_id", "operator": "==", "values": "AuthenticAMD"}, {"key": "hostname", "operator": "contains", "values": "redhat.com"}]
pools = p1
vm_node = node1
mig_dest_node = node2
pool_selectors_p1 = [{"key": "type", "operator": "==", "values": "nfs"}, {"key": "access.nodes", "operator": "contains", "values": ["node1", "node2"]}]
image_pool_name_image1 = p1
variants:
- @default:
- with_filter_off:
Expand Down
3 changes: 3 additions & 0 deletions qemu/tests/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@ def guest_stress_deamon():
for func in pre_migrate:
func(vm, params, test)
if i % 2 == 0:
dst_node = params.get("mig_dest_node")
test.log.info("Round %s ping...", str(i / 2))
else:
dst_node = params.get("vm_node")
test.log.info("Round %s pong...", str(i / 2))
try:
vm.migrate(
Expand All @@ -239,6 +241,7 @@ def guest_stress_deamon():
mig_cancel_delay,
offline,
check,
dest_host=dst_node,
migration_exec_cmd_src=mig_exec_cmd_src,
migration_exec_cmd_dst=mig_exec_cmd_dst,
migrate_capabilities=capabilities,
Expand Down
19 changes: 13 additions & 6 deletions qemu/tests/migration_with_file_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ def run(test, params, env):
host_path = "/tmp/file-%s" % utils_misc.generate_random_string(6)
host_path_returned = "%s-returned" % host_path
guest_path = params.get("guest_path", "/tmp/file")
file_size = params.get("file_size", "500")
file_size = params.get("file_size", "1000")
transfer_timeout = int(params.get("transfer_timeout", "240"))
if mig_protocol == "exec":
mig_file = os.path.join(
test.tmpdir, "tmp-%s" % utils_misc.generate_random_string(8)
)

cnt = 0
try:
process.run("dd if=/dev/urandom of=%s bs=1M count=%s" % (host_path, file_size))
process.run("dd if=/dev/zero of=%s bs=1M count=%s" % (host_path, file_size))

def run_and_migrate(bg):
def run_and_migrate(bg, cnt):
bg.start()
try:
while bg.is_alive():
Expand All @@ -54,21 +54,28 @@ def run_and_migrate(bg):
if mig_protocol == "exec" and migration_exec_cmd_src:
migration_exec_cmd_src %= mig_file # pylint: disable=E0606
migration_exec_cmd_dst %= mig_file
if cnt % 2 == 0:
dest_host = params.get("mig_dest_node")
else:
dest_host = params.get("vm_node")
vm.migrate(
mig_timeout,
mig_protocol,
mig_cancel_delay,
dest_host=dest_host,
env=env,
migration_exec_cmd_src=migration_exec_cmd_src,
migration_exec_cmd_dst=migration_exec_cmd_dst,
)
cnt += 1
except Exception:
# If something bad happened in the main thread, ignore
# exceptions raised in the background thread
bg.join(suppress_exception=True)
raise
else:
bg.join()
return cnt

error_context.context(
"transferring file to guest while migrating", test.log.info
Expand All @@ -78,7 +85,7 @@ def run_and_migrate(bg):
(host_path, guest_path),
dict(verbose=True, timeout=transfer_timeout),
)
run_and_migrate(bg)
cnt = run_and_migrate(bg, cnt)

error_context.context(
"transferring file back to host while migrating", test.log.info
Expand All @@ -88,7 +95,7 @@ def run_and_migrate(bg):
(guest_path, host_path_returned),
dict(verbose=True, timeout=transfer_timeout),
)
run_and_migrate(bg)
run_and_migrate(bg, cnt)

# Make sure the returned file is identical to the original one
error_context.context("comparing hashes", test.log.info)
Expand Down
12 changes: 11 additions & 1 deletion qemu/tests/migration_with_netperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,20 @@ def run(test, params, env):
m_count = 0
while netperf_client_h.is_netperf_running():
m_count += 1
if m_count % 2 == 0:
dest_host = params.get("vm_node")
else:
dest_host = params.get("mig_dest_node")
error_context.context(
"Start migration iterations: %s " % m_count, test.log.info
)
vm.migrate(mig_timeout, mig_protocol, mig_cancel_delay, env=env)
vm.migrate(
mig_timeout,
mig_protocol,
mig_cancel_delay,
dest_host=dest_host,
env=env,
)
finally:
if netperf_server_g:
if netperf_server_g.is_server_running():
Expand Down
8 changes: 8 additions & 0 deletions qemu/tests/migration_with_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,30 @@ def run(test, params, env):
bg = utils_misc.InterruptedThread(
vm.reboot, kwargs={"session": session, "timeout": login_timeout}
)
bg.daemon = True
bg.start()
try:
cnt = 0
while bg.is_alive():
for func in pre_migrate:
func(vm, params, test)
if cnt % 2 == 0:
dest_host = params.get("mig_dest_node")
else:
dest_host = params.get("vm_node")
vm.migrate(
mig_timeout,
mig_protocol,
mig_cancel_delay,
dest_host=dest_host,
env=env,
migration_exec_cmd_src=migration_exec_cmd_src,
migration_exec_cmd_dst=migration_exec_cmd_dst,
)
# run some functions after migrate finish.
for func in post_migrate:
func(vm, params, test)
cnt += 1
except Exception:
# If something bad happened in the main thread, ignore exceptions
# raised in the background thread
Expand Down
6 changes: 5 additions & 1 deletion qemu/tests/migration_with_speed_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ def get_migration_statistic(vm):
time.sleep(2)

clonevm = vm.migrate(
mig_timeout, mig_protocol, not_wait_for_migration=True, env=env
mig_timeout,
mig_protocol,
not_wait_for_migration=True,
dest_host=params.get("mig_dest_node"),
env=env,
)

mig_speed = int(float(utils_misc.normalize_data_size(mig_speed, "M")))
Expand Down