From b11efc1df1da332a8cf33f461dc538da3483bd17 Mon Sep 17 00:00:00 2001 From: Xiaodai Wang Date: Fri, 10 Nov 2023 15:09:43 +0800 Subject: [PATCH] v2v: add cpu topology case for -i vmx scenario Signed-off-by: Xiaodai Wang --- v2v/tests/cfg/convert_from_file.cfg | 8 +++++++- v2v/tests/src/convert_from_file.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/v2v/tests/cfg/convert_from_file.cfg b/v2v/tests/cfg/convert_from_file.cfg index 65f13e695f..22a8b1570b 100644 --- a/v2v/tests/cfg/convert_from_file.cfg +++ b/v2v/tests/cfg/convert_from_file.cfg @@ -261,7 +261,13 @@ enable_legacy_policy = yes only esx_67 main_vm = 'VM_NAME_RHEL6_V2V_EXAMPLE' - + - cpu_topology: + only esx_67 + vmx_nfs_src = NFS_ESX67_VMX_V2V_EXAMPLE + main_vm = 'VM_NAME_CPU_TOPOLOGY_V2V_EXAMPLE' + v2v_debug = force_on + checkpoint = 'cpu_topology' + msg_content_yes = '' variants: - negative_test: status_error = 'yes' diff --git a/v2v/tests/src/convert_from_file.py b/v2v/tests/src/convert_from_file.py index c39d4c1676..26d10cde2d 100644 --- a/v2v/tests/src/convert_from_file.py +++ b/v2v/tests/src/convert_from_file.py @@ -1,3 +1,4 @@ +import glob import os import pwd import logging @@ -233,6 +234,22 @@ def vm_check(): 'skip_virsh_pre_conn': skip_virsh_pre_conn}) if checkpoint == 'regular_user_sudo': v2v_params.update({'pub_key': pub_key}) + if checkpoint == 'cpu_topology': + mount_point = utils_v2v.v2v_mount(vmx_nfs_src, 'v2v_tmp_mp') + vmxfile = glob.glob(os.path.join(mount_point, vm_name, '*.vmx'))[0] + with open(vmxfile) as fd: + buf = fd.read() + res = re.search('numvcpus = "(\d+)"', buf) + if not res: + test.error('Not found numvcpus in vmx file') + numvcpus = int(res.group(1)) + res = re.search('cpuid.coresPerSocket = "(\d+)"', buf) + if not res: + test.error('Not found cpuid.coresPerSocket in vmx file') + corespersocket = int(res.group(1)) + params['msg_content_yes'] += '' + str(numvcpus//corespersocket) + '%' + params['msg_content_yes'] += '' + str(corespersocket) + '%' + params['msg_content_yes'] += '' + '1' # copy ova from nfs storage before v2v conversion if input_mode == 'ova': src_dir = params.get('ova_dir')