Skip to content

Commit 03f62d2

Browse files
committed
add case for migrating guest while scp files
xxxx-95968 - [virtual network][virtual-nic-device] Migrate guest while scp files xxxx-296253 - [virtual network][virtual-nic-device] migrate guest with iommu_platform=on and different memory size Signed-off-by: nanli <nanli@redhat.com>
1 parent a302a6f commit 03f62d2

File tree

3 files changed

+177
-0
lines changed

3 files changed

+177
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
- virtual_network.qemu_test.migrate_with_file_transfer:
2+
type = migrate_with_file_transfer
3+
create_vm_libvirt = "yes"
4+
kill_vm_libvirt = "yes"
5+
start_vm = "yes"
6+
take_regular_screendumps = no
7+
storage_type = 'nfs'
8+
setup_local_nfs = 'yes'
9+
disk_type = "file"
10+
disk_source_protocol = "netfs"
11+
nfs_mount_dir = "/var/lib/libvirt/migrate"
12+
nfs_mount_options = "soft,timeo=50,retrans=3"
13+
virsh_migrate_dest_state = running
14+
virsh_migrate_options = "--live --p2p --verbose"
15+
virsh_migrate_connect_uri = "qemu:///system"
16+
migration_setup = "yes"
17+
ssh_remote_auth = True
18+
mnt_path_name = ${nfs_mount_dir}
19+
nfs_server_ip = "${migrate_source_host}"
20+
migrate_desturi_port = "22"
21+
migrate_desturi_type = "ssh"
22+
virsh_migrate_desturi = "qemu+ssh://${migrate_dest_host}/system"
23+
login_timeout = "360"
24+
migrate_speed = 15
25+
guest_path = "/tmp/file"
26+
file_size = "500"
27+
transfer_timeout = "240"
28+
migrate_vm_back = "no"
29+
migration_type = "precopy"
30+
virsh_migrate_extra = ""
31+
action_during_mig = [{"func": "utils_test.run_file_transfer", "func_param": {"test": params.get('test'), "params": params.get('params'), "env": params.get('env')}}]
32+
Windows:
33+
guest_path = "C:\\tmpfile"
34+
test_iommu = "yes"
35+
variants:
36+
- default:
37+
# Regular test without IOMMU
38+
test_iommu = "no"
39+
- with_iommu:
40+
x86_64, i386:
41+
only q35
42+
no WinXP WinVista Win7 Win8 Win8.1 Win2003
43+
no Win2008 Win2008..r2 Win2012 Win2012..r2
44+
iface_iommu_driver = {'name':'vhost','iommu': 'on', 'ats': 'on', 'disable-legacy':'on', 'disable-modern':'off'}
45+
HostCpuVendor.intel:
46+
iommu_dict = {'model': 'intel', 'driver': {'intremap': 'on', 'caching_mode': 'on'}}
47+
RHEL.7.9:
48+
# For RHEL 7.9 compatibility - disable device IOTLB
49+
iommu_dict = {'model': 'intel', 'driver': {'intremap': 'on', 'caching_mode': 'on', 'device-iotlb': 'off'}}
50+
Linux:
51+
enable_guest_iommu = "yes"
52+
aarch64:
53+
iommu_dict = {'model': 'smmuv3'}
54+
iface_iommu_driver = {'name':'vhost','iommu': 'on', 'ats': 'on'}
55+
s390x:
56+
iface_iommu_driver = {'name':'vhost','iommu': 'on'}
57+
- with_virtio_iommu:
58+
required_qemu= [7.0.0,)
59+
only Linux
60+
only x86_64, aarch64
61+
x86_64:
62+
only q35
63+
iommu_dict = {'model': 'virtio'}
64+
iface_iommu_driver = {'name':'vhost','iommu': 'on'}
65+
variants:
66+
- default_mem:
67+
- minimum_mem:
68+
x86_64, aarch64, s390, s390x:
69+
mem = 1536
70+
ppc64, ppc64le:
71+
mem = 3072
72+
Windows:
73+
mem = 4096
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
#
3+
# Copyright Redhat
4+
#
5+
# SPDX-License-Identifier: GPL-2.0
6+
#
7+
# Author: Nannan Li <nanli@redhat.com>
8+
#
9+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
11+
from virttest.libvirt_xml.vm_xml import VMXML
12+
from virttest.utils_libvirt import libvirt_virtio
13+
from virttest.utils_libvirt import libvirt_vmxml
14+
15+
from provider.migration import base_steps
16+
from provider.virtual_network import network_base
17+
18+
19+
def run(test, params, env):
20+
"""
21+
Test file transfer during migration
22+
23+
This test supports both regular migration with file transfer and
24+
IOMMU-enabled scenarios for network interface testing.
25+
26+
IOMMU devices are configured using iommu_dict parameter which gets
27+
processed by libvirt_virtio.add_iommu_dev().
28+
29+
:param test: test object
30+
:param params: Dictionary with the test parameters
31+
:param env: Dictionary with test environment.
32+
"""
33+
34+
def setup_test():
35+
"""
36+
Setup IOMMU (Intel IOMMU or virtio-iommu direct plug only)
37+
virt-install not support iommu added, so we add it from xml.
38+
"""
39+
if test_iommu:
40+
libvirt_vmxml.modify_vm_device(vmxml, 'interface', iface_attrs)
41+
libvirt_virtio.add_iommu_dev(vm, iommu_dict)
42+
43+
def run_test():
44+
"""
45+
Test file transfer during migration
46+
"""
47+
if not vm.is_alive:
48+
vm.start()
49+
test.log.info("TEST_STEP 1: Guest xml is: %s\n", VMXML.new_from_dumpxml(vm_name))
50+
51+
test.log.info("TEST_STEP 2: Starting migration with file transfers")
52+
migration_obj.setup_connection()
53+
if not vm.is_alive():
54+
vm.start()
55+
migration_obj.run_migration()
56+
57+
test.log.info("TEST_STEP 3: Testing network connectivity on destination host")
58+
backup_uri = vm.connect_uri
59+
vm.connect_uri = dest_uri
60+
61+
session = vm.wait_for_login(timeout=login_timeout)
62+
ips = {'outside_ip': outside_ip}
63+
network_base.ping_check(params, ips, session)
64+
session.close()
65+
vm.connect_uri = backup_uri
66+
67+
if migrate_vm_back:
68+
test.log.info("TEST_STEP 4: Migrating VM back to source host")
69+
migration_obj.run_migration_back()
70+
71+
def teardown_test():
72+
"""
73+
Cleanup test environment
74+
"""
75+
migration_obj.cleanup_connection()
76+
77+
# Get main parameters
78+
vm_name = params.get("main_vm")
79+
vm = env.get_vm(vm_name)
80+
iommu_dict = eval(params.get('iommu_dict', '{}'))
81+
iface_iommu_driver = eval(params.get('iface_iommu_driver', '{}'))
82+
dest_uri = params.get("virsh_migrate_desturi")
83+
migrate_vm_back = params.get_boolean("migrate_vm_back", True)
84+
login_timeout = params.get_numeric("login_timeout", "240")
85+
outside_ip = params.get("outside_ip", "8.8.8.8")
86+
test_iommu = params.get_boolean("test_iommu")
87+
88+
vmxml = VMXML.new_from_dumpxml(vm_name)
89+
iface_attrs = vmxml.devices.by_device_tag('interface')[0].fetch_attrs()
90+
iface_attrs.setdefault('driver', {})
91+
iface_attrs['driver'] = {
92+
'driver_attr': {**iface_attrs.get('driver', {}).get('driver_attr', {}), **iface_iommu_driver}}
93+
94+
# Add required objects to params for action_during_mig
95+
params.update({"params": params, "test": test, "env": env})
96+
97+
migration_obj = base_steps.MigrationBase(test, vm, params)
98+
99+
try:
100+
setup_test()
101+
run_test()
102+
finally:
103+
teardown_test()

provider/migration/migration_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from virttest import utils_misc # pylint: disable=W0611
1313
from virttest import utils_libvirtd # pylint: disable=W0611
1414
from virttest import utils_conn
15+
from virttest import utils_test # pylint: disable=W0611
1516

1617
from virttest.libvirt_xml import vm_xml
1718
from virttest.migration import MigrationTest

0 commit comments

Comments
 (0)