Skip to content

Commit 8722813

Browse files
committed
migration: Add case testing the abort operation
Abort migration job before qemu layer migration starts, then migrate vm again. VIRT-298398 - [VM migration][precopy] abort migration job before qemu layer migration starts Signed-off-by: lcheng <[email protected]>
1 parent 043000c commit 8722813

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
- migration.async_job.abort_before_qemu_layer_mig_start:
2+
type = abort_before_qemu_layer_mig_start
3+
migration_setup = 'yes'
4+
storage_type = 'nfs'
5+
setup_local_nfs = 'yes'
6+
disk_type = "file"
7+
disk_source_protocol = "netfs"
8+
mnt_path_name = ${nfs_mount_dir}
9+
# Console output can only be monitored via virsh console output
10+
only_pty = True
11+
take_regular_screendumps = no
12+
# Extra options to pass after <domain> <desturi>
13+
virsh_migrate_extra = ''
14+
# SSH connection time out
15+
ssh_timeout = 60
16+
# Local URI
17+
virsh_migrate_connect_uri = 'qemu:///system'
18+
virsh_migrate_dest_state = "running"
19+
virsh_migrate_src_state = "shut off"
20+
image_convert = 'no'
21+
server_ip = "${migrate_dest_host}"
22+
server_user = "root"
23+
server_pwd = "${migrate_dest_pwd}"
24+
status_error = "yes"
25+
check_network_accessibility_after_mig = "yes"
26+
migrate_speed = "15"
27+
err_msg = "error: operation aborted: migration out: canceled by client"
28+
migrate_again_status_error = "no"
29+
start_vm = "yes"
30+
variants:
31+
- p2p:
32+
virsh_migrate_options = '--live --p2p --verbose'
33+
variants:
34+
- with_precopy:
35+
variants:
36+
- tcp:
37+
migrate_desturi_port = "16509"
38+
migrate_desturi_type = "tcp"
39+
virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system"
40+
- unix:
41+
transport_type = "unix_proxy"
42+
service_to_check = " "
43+
migrateuri_socket_path = "/var/lib/libvirt/qemu/migrateuri-socket"
44+
desturi_socket_path = "/tmp/desturi-socket"
45+
migrate_desturi_type = "unix_proxy"
46+
virsh_migrate_desturi = "qemu+unix:///system?socket=${desturi_socket_path}"
47+
migrateuri_port = "33334"
48+
port_to_check = "${migrateuri_port}"
49+
virsh_migrate_migrateuri = "unix://${migrateuri_socket_path}"
50+
virsh_migrate_extra = "--migrateuri ${virsh_migrate_migrateuri}"
51+
variants abort_mig:
52+
- domjobabort:
53+
- ctrl_c:
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
#
3+
# Copyright Redhat
4+
#
5+
# SPDX-License-Identifier: GPL-2.0
6+
#
7+
# Author: Liping Cheng <[email protected]>
8+
#
9+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
11+
import queue
12+
import signal
13+
import threading
14+
import time
15+
16+
from avocado.utils import process
17+
18+
from virttest import remote
19+
from virttest import utils_misc
20+
from virttest import virsh
21+
from virttest.utils_test import libvirt
22+
23+
from provider.migration import base_steps
24+
25+
msg_queue = queue.Queue()
26+
27+
28+
def run_migration(vm_name, dest_uri, option, extra):
29+
"""
30+
Run migration
31+
32+
:param vm_name: VM name
33+
:param dest_uri: virsh uri
34+
:param option: virsh migrate option parameters
35+
:param extra: virsh migrate extra paramsters
36+
"""
37+
ret = virsh.migrate(vm_name, dest_uri, option, extra, debug=True)
38+
msg_queue.put(ret)
39+
40+
41+
def run(test, params, env):
42+
"""
43+
Abort migration job before qemu layer migration starts, then migrate vm
44+
again.
45+
46+
"""
47+
def setup_test():
48+
"""
49+
Setup steps
50+
51+
"""
52+
test.log.info("Setup steps.")
53+
migration_obj.setup_connection()
54+
remote.run_remote_cmd("pkill -19 virtqemud", params)
55+
56+
def run_test():
57+
"""
58+
Run test
59+
60+
"""
61+
dest_uri = params.get("virsh_migrate_desturi")
62+
option = params.get("virsh_migrate_options", "--live --verbose")
63+
extra = params.get("virsh_migrate_extra")
64+
err_msg = params.get("err_msg")
65+
abort_mig = params.get("abort_mig")
66+
67+
mig_t = threading.Thread(target=run_migration, args=(vm_name, dest_uri, option, extra))
68+
mig_t.start()
69+
time.sleep(3)
70+
71+
if abort_mig == "domjobabort":
72+
virsh.domjobabort(vm_name, debug=True)
73+
elif abort_mig == "ctrl_c":
74+
ret = process.run("pgrep -f 'virsh migrate'", shell=True, verbose=True).stdout_text.strip()
75+
utils_misc.safe_kill(ret, signal.SIGINT)
76+
time.sleep(60)
77+
else:
78+
test.error(f"Unsupported abort operation: {abort_mig}")
79+
80+
remote.run_remote_cmd("pkill -18 virtqemud", params)
81+
mig_t.join()
82+
83+
output = msg_queue.get()
84+
libvirt.check_result(output, err_msg)
85+
86+
vm_name = params.get("migrate_main_vm")
87+
88+
vm = env.get_vm(vm_name)
89+
migration_obj = base_steps.MigrationBase(test, vm, params)
90+
91+
try:
92+
setup_test()
93+
run_test()
94+
migration_obj.run_migration_again()
95+
migration_obj.verify_default()
96+
finally:
97+
migration_obj.cleanup_connection()

0 commit comments

Comments
 (0)