Skip to content

Commit 983f459

Browse files
authored
Merge pull request #6577 from cliping/vm_conf
migration: Add case for changing target VM configurations
2 parents 5e9ec62 + 6a5fed7 commit 983f459

File tree

2 files changed

+188
-0
lines changed

2 files changed

+188
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
- migration.vm_configuration_and_status.change_dst_vm_conf:
2+
type = change_dst_vm_conf
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+
image_convert = 'no'
19+
server_ip = "${migrate_dest_host}"
20+
server_user = "root"
21+
server_pwd = "${migrate_dest_pwd}"
22+
virsh_migrate_dest_state = "running"
23+
virsh_migrate_src_state = "shut off"
24+
status_error = "no"
25+
check_network_accessibility_after_mig = "yes"
26+
migrate_desturi_port = "16509"
27+
migrate_desturi_type = "tcp"
28+
virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system"
29+
start_vm = "no"
30+
variants:
31+
- p2p:
32+
virsh_migrate_options = '--live --p2p --verbose'
33+
- non_p2p:
34+
virsh_migrate_options = '--live --verbose'
35+
variants:
36+
- with_persistent:
37+
persistent_option = "--persistent"
38+
variants:
39+
- with_persistent_xml:
40+
variants persistent_xml_path:
41+
- persistent_xml_exist:
42+
xml_title = "Update xml title to test persistent xml"
43+
- persistent_xml_not_exist:
44+
status_error = "yes"
45+
err_msg = "No such file or directory"
46+
- without_persistent_xml:
47+
- without_persistent:
48+
variants:
49+
- with_xml:
50+
variants xml_path:
51+
- xml_exist:
52+
- xml_not_exist:
53+
status_error = "yes"
54+
err_msg = "No such file or directory"
55+
- without_xml:
56+
variants:
57+
- with_dname:
58+
dname = "change_dst_name"
59+
- without_dname:
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
#
3+
# Copyright Redhat
4+
#
5+
# SPDX-License-Identifier: GPL-2.0
6+
#
7+
# Author: Liping Cheng <[email protected]>
8+
#
9+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
11+
from virttest import virsh
12+
from virttest.utils_test import libvirt
13+
from virttest.libvirt_xml import vm_xml
14+
15+
from provider.migration import base_steps
16+
17+
18+
def run(test, params, env):
19+
"""
20+
To test target vm name, live xml and persistent xml can be changed via virsh
21+
migrate options during migration.
22+
23+
:param test: test object
24+
:param params: Dictionary with the test parameters
25+
:param env: Dictionary with test environment.
26+
"""
27+
def setup_test():
28+
"""
29+
Setup steps
30+
"""
31+
persistent_option = params.get("persistent_option")
32+
dname = params.get("dname")
33+
xml_title = params.get("xml_title")
34+
xml_path = params.get("xml_path")
35+
persistent_xml_path = params.get("persistent_xml_path")
36+
extra = params.get("virsh_migrate_extra")
37+
38+
test.log.info("Setup test.")
39+
migration_obj.setup_connection()
40+
if persistent_option:
41+
extra = "%s %s" % (extra, persistent_option)
42+
if dname:
43+
extra = "%s --dname %s" % (extra, dname)
44+
if xml_path:
45+
if xml_path == "xml_exist":
46+
mig_xml = vm_xml.VMXML.new_from_dumpxml(vm_name, options="--migratable")
47+
graphic_xml = mig_xml.get_devices(device_type="graphics")[0]
48+
mig_xml.del_device(graphic_xml)
49+
graphic_xml["autoport"] = "no"
50+
graphic_xml["port"] = "6666"
51+
mig_xml.add_device(graphic_xml)
52+
mig_xml.sync()
53+
extra = "%s --xml %s" % (extra, mig_xml.xml)
54+
else:
55+
extra = "%s --xml /var/tmp/xml_non_exist_test" % extra
56+
if persistent_xml_path:
57+
if persistent_xml_path == "persistent_xml_exist":
58+
persistent_xml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
59+
persistent_xml.title = xml_title
60+
extra = "%s --persistent-xml %s" % (extra, persistent_xml.xml)
61+
else:
62+
extra = "%s --persistent-xml /var/tmp/persistent_xml_non_exist_test" % extra
63+
params.update({"virsh_migrate_extra": extra})
64+
vm.start()
65+
vm.wait_for_login().close()
66+
67+
def verify_test():
68+
"""
69+
Verify steps
70+
"""
71+
desturi = params.get("virsh_migrate_desturi")
72+
persistent_option = params.get("persistent_option")
73+
dname = params.get("dname")
74+
xml_title = params.get("xml_title")
75+
xml_path = params.get("xml_path")
76+
persistent_xml_path = params.get("persistent_xml_path")
77+
src_vm_state = params.get("virsh_migrate_src_state")
78+
dest_vm_state = params.get("virsh_migrate_dest_state")
79+
status_error = "yes" == params.get("status_error", "no")
80+
81+
test.log.info("Verify test.")
82+
if status_error:
83+
migration_obj.verify_default()
84+
else:
85+
if dname:
86+
migration_obj.migration_test.ping_vm(vm, params, uri=desturi)
87+
if not libvirt.check_vm_state(vm_name, src_vm_state, uri=migration_obj.src_uri, debug=True):
88+
test.fail("When with '--dname', check source vm state failed.")
89+
if not libvirt.check_vm_state(dname, dest_vm_state, uri=desturi, debug=True):
90+
test.fail("When with '--dname', check dest vm state failed.")
91+
else:
92+
migration_obj.verify_default()
93+
vm.name = dname if dname else vm_name
94+
new_xml = virsh.dumpxml(vm.name, debug=True, uri=desturi)
95+
if dname:
96+
if dname not in new_xml.stdout_text.strip():
97+
test.fail(f"Not found {dname} in vm xml.")
98+
99+
if xml_path:
100+
if xml_path == "xml_exist":
101+
libvirt.check_result(new_xml, expected_match="autoport='no'")
102+
else:
103+
libvirt.check_result(new_xml, expected_match="autoport='yes'")
104+
virsh.destroy(vm.name, debug=True, uri=desturi)
105+
if persistent_option:
106+
if not libvirt.check_vm_state(vm.name, "shut off", uri=desturi):
107+
test.fail("When migration with '--persistent', check dest vm state failed.")
108+
if dname:
109+
if dname not in virsh.dom_list("--all", debug=True, uri=desturi).stdout_text:
110+
test.fail(f"When migration with '--persistent --dname', not found {dname} in vm list.")
111+
if persistent_xml_path:
112+
remote_virsh = virsh.Virsh(uri=desturi)
113+
vmxml_inactive = vm_xml.VMXML.new_from_inactive_dumpxml(vm.name, "--security-info", remote_virsh)
114+
if vmxml_inactive.title != xml_title:
115+
test.fail("'--persistent-xml' didn't take effect in live migration.")
116+
else:
117+
if virsh.domain_exists(vm.name, uri=desturi):
118+
test.fail("The domain is found on the target host, but expected not.")
119+
120+
vm_name = params.get("migrate_main_vm")
121+
vm = env.get_vm(vm_name)
122+
migration_obj = base_steps.MigrationBase(test, vm, params)
123+
124+
try:
125+
setup_test()
126+
migration_obj.run_migration()
127+
verify_test()
128+
finally:
129+
migration_obj.cleanup_connection()

0 commit comments

Comments
 (0)