Skip to content

Commit

Permalink
migration: add case about migrate vm which have vmx-* cpu features
Browse files Browse the repository at this point in the history
XXX-303279 - [VM migration] migrate vm which have vmx-* cpu features

Signed-off-by: lcheng <lcheng@redhat.com>
  • Loading branch information
cliping committed Jan 17, 2025
1 parent 5930c34 commit 5951bf9
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- migration.migration_misc.migration_with_vmx_cpu_features:
type = migration_with_vmx_cpu_features
migration_setup = 'yes'
storage_type = 'nfs'
setup_local_nfs = 'yes'
disk_type = "file"
disk_source_protocol = "netfs"
mnt_path_name = ${nfs_mount_dir}
# Console output can only be monitored via virsh console output
only_pty = True
take_regular_screendumps = no
# Extra options to pass after <domain> <desturi>
virsh_migrate_extra = ''
# SSH connection time out
ssh_timeout = 60
# Local URI
virsh_migrate_connect_uri = 'qemu:///system'
image_convert = 'no'
server_ip = "${migrate_dest_host}"
server_user = "root"
server_pwd = "${migrate_dest_pwd}"
status_error = "no"
migrate_desturi_port = "16509"
migrate_desturi_type = "tcp"
virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system"
start_vm = "no"
variants:
- p2p:
virsh_migrate_options = '--live --p2p --verbose'
- non_p2p:
virsh_migrate_options = '--live --verbose'
variants migration_option:
- with_xml:
- without_xml:
variants cpu_mode:
- host_model:
numa_cell = "'numa_cell': [{'cpus': '0-1', 'memory': '2097152', 'unit': 'KiB'}]"
vm_attrs = {'cpu': {'mode': 'host-model', 'check': 'partial', ${numa_cell}}}
- custom:
cpu_mode = "custom"
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import os

from avocado.utils import process

from virttest import data_dir
from virttest import virsh
from virttest.libvirt_xml import vm_xml

from provider.migration import base_steps


def run(test, params, env):
"""
Verify that migration can succeed when host and guest have vmx-* cpu
features.
:param test: test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def setup_test():
"""
Setup steps
"""
cpu_mode = params.get("cpu_mode")
migration_option = params.get("migration_option")

test.log.info("Setup steps.")
migration_obj.setup_connection()
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)
if cpu_mode == "host_model":
vm_attrs = eval(params.get('vm_attrs', '{}'))
vmxml.setup_attrs(**vm_attrs)
vmxml.sync()
else:
base_steps.sync_cpu_for_mig(params)

if not vm.is_alive():
vm.start()
vm.wait_for_login().close()

if migration_option == "with_xml":
xmlfile = os.path.join(data_dir.get_tmp_dir(), '%s.xml' % vm_name)
virsh.dumpxml(vm_name, extra="--migratable", to_file=xmlfile, ignore_status=False)
params.update({"virsh_migrate_extra": f"--xml {xmlfile}"})

vm_name = params.get("migrate_main_vm")

vm = env.get_vm(vm_name)
migration_obj = base_steps.MigrationBase(test, vm, params)

cmd = "virsh domcapabilities |grep vmx- |wc -l"
ret = process.run(cmd, shell=True).stdout_text.strip()
if int(ret) == 0:
test.cancel("Please use the host with vmx-* cpu features to test.")
try:
setup_test()
migration_obj.run_migration()
migration_obj.verify_default()
finally:
migration_obj.cleanup_connection()
1 change: 1 addition & 0 deletions spell.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,7 @@ vms
VMs
vmtype
vmware
vmx
vmxml
vnc
vncdisplay
Expand Down

0 comments on commit 5951bf9

Please sign in to comment.