Skip to content

Commit 6cade94

Browse files
committed
Auto five v2v cases
1. Check qemu-ga for rhel8 guest with usr partition 2. Convert sles15 guest with encrypted btrfs fs 3. Check output for virt-v2v-in-place 4. Convert win11 guest with vtpm and bitlocker 5. Check disks in specific path for kubevirt output Signed-off-by: Ming Xie <[email protected]>
1 parent 4f934ff commit 6cade94

File tree

5 files changed

+80
-58
lines changed

5 files changed

+80
-58
lines changed

provider/v2v_vmcheck_helper.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,6 @@ def check_kubevirt_output(params):
11121112

11131113
os_directory = params.get('os_directory')
11141114
disk_count = int(params.get('vm_disk_count', 0))
1115-
vm_name = params.get('v2v_cmd_op_on')
11161115

11171116
result = True
11181117

@@ -1121,11 +1120,7 @@ def check_kubevirt_output(params):
11211120
fd.seek(0)
11221121
data = load(fd, Loader=Loader)
11231122

1124-
if vm_name != data['metadata']['name']:
1125-
LOG.debug('expect vm name: %s' % vm_name)
1126-
result = False
1127-
1128-
if disk_count != len(data['spec']['domain']['devices']['disks']):
1123+
if disk_count != len(data['spec']['template']['spec']['domain']['devices']['disks']):
11291124
LOG.debug('expect disk count: %s' % disk_count)
11301125
result = False
11311126

v2v/tests/cfg/function_test_esx.cfg

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
variants:
3939
- kubevirt:
4040
only dest_kubevirt
41-
only multiple_disks
4241
- json:
4342
only dest_json
4443
only uefi.win2019,device_map,without_ip_option,env_leak,block_dev
@@ -453,7 +452,9 @@
453452
esx_https_proxy = HTTPS_PROXY_V2V_EXAMPLE
454453
- usr_partition:
455454
only esx_70
455+
version_required = "[virt-v2v-2.8.1-8,)"
456456
main_vm = VM_NAME_USR_PARTITION_V2V_EXAMPLE
457+
checkpoint = "ogac"
457458
- dir_permission:
458459
only esx_70
459460
main_vm = VM_NAME_ESX70_RHEL9_V2V_EXAMPLE
@@ -535,23 +536,13 @@
535536
checkpoint = "exist_uuid"
536537
v2v_opts = ""
537538
msg_content = "Disk with the UUID .*? already exists"
538-
- no-copy:
539-
only esx_70
540-
only rhev.rhv_upload
541-
# Means version >= libguestfs-1.40.2-15
542-
version_required = "[libguestfs-1.40.2-15,)"
543-
main_vm = VM_NAME_RHEL7_V2V_EXAMPLE
544-
has_rhv_disk_uuid = 'yes'
545-
v2v_opts = "--no-copy"
546-
skip_vm_check = yes
547-
skip_reason = '--no-copy is specified, no images will be copied'
548-
variants:
549-
- normal:
550-
- without_rhv-disk-uuid:
551-
# Means version >= virt-v2v-1.45.3-1
552-
version_required = "[virt-v2v-1.45.3-1,)"
553-
checkpoint = "no_uuid"
554-
# ovirt-guest-agent-common
539+
- define_disk_path:
540+
only esx_80
541+
only dest_kubevirt
542+
version_required = "[virt-v2v-2.8.1-2,)"
543+
main_vm = VM_NAME_WIN2019_ONLINE_DISKS_V2V_EXAMPLE
544+
checkpoint = define_disk_path
545+
vm_disk_count = 4
555546
- OGAC:
556547
checkpoint = "ogac"
557548
variants:
@@ -769,13 +760,21 @@
769760
luks_keys = LUKS_UUID_KEYS
770761
v2v_opts += "--key all:clevis"
771762
- win_bitlocker:
772-
only esx_70
773-
version_required = "[virt-v2v-1.42.0-15,)"
774-
checkpoint = 'luks_dev_keys'
775-
main_vm = VM_NAME_WIN_BITLOCKER_V2V_EXAMPLE
776-
luks_keys = LUKS_WIN_BIT_LOCKER_DEV_KEYS
777763
skip_vm_check = yes
778764
skip_reason = 'luks encryped, cannot boots up without password'
765+
variants:
766+
- without_tpm:
767+
only esx_70
768+
version_required = "[virt-v2v-1.42.0-15,)"
769+
checkpoint = 'luks_dev_keys'
770+
main_vm = VM_NAME_WIN_BITLOCKER_V2V_EXAMPLE
771+
luks_keys = LUKS_WIN_BIT_LOCKER_DEV_KEYS
772+
- with_tpm:
773+
only esx_80
774+
checkpoint = 'luks_dev_keys'
775+
main_vm = VM_NAME_WIN11_WITH_TPM_BITLOCKER_V2V_EXAMPLE
776+
luks_keys = VM_WIN11_WITH_TPM_BITLOCKER_KEYS
777+
779778
- cve_2022_2211:
780779
only esx_70
781780
only dest_local
@@ -966,19 +965,28 @@
966965
skip_reason = 'bug RHEL-97179 is not fixed'
967966
boottype = 3
968967
- encrypted:
969-
main_vm = VM_NAME_SLES_BTRFS_ENCRYPTED_SLES12SP5_V2V_EXAMPLE
970-
skip_vm_check = yes
971-
skip_reason = 'bug RHEL-93583 is not fixed and cannot boot into OS without password automatically'
972-
checkpoint = 'luks_dev_keys'
973-
luks_keys = LUKS_ALL_KEYS
968+
variants:
969+
- sles12sp5:
970+
main_vm = VM_NAME_SLES_BTRFS_ENCRYPTED_SLES12SP5_V2V_EXAMPLE
971+
skip_vm_check = yes
972+
skip_reason = 'bug RHEL-93583 is not fixed and cannot boot into OS without password automatically'
973+
checkpoint = 'luks_dev_keys'
974+
luks_keys = LUKS_ALL_KEYS
975+
- sles15sp6:
976+
main_vm = VM_NAME_SLES_BTRFS_ENCRYPTED_SLES15SP6_V2V_EXAMPLE
977+
boottype = 3
978+
checkpoint = 'luks_dev_keys'
979+
luks_keys = LUKS_ALL_KEYS
980+
skip_vm_check = yes
981+
skip_reason = 'luks encryped, cannot boots up without password'
982+
version_required = "[libguestfs-1.56.1-3,)"
974983
- print_blkhash:
975-
only esx_70
976-
only libvirt
977-
v2v_debug = force_on
978-
version_required = "[virt-v2v-2.7.1-12,)"
979-
checkpoint = "print_blkhash"
980-
msg_content_yes = "nbdcopy.*--blkhash"
981-
984+
only esx_70
985+
only libvirt
986+
v2v_debug = force_on
987+
version_required = "[virt-v2v-2.7.1-12,)"
988+
checkpoint = "print_blkhash"
989+
msg_content_yes = "nbdcopy.*--blkhash"
982990
variants:
983991
- positive_test:
984992
status_error = 'no'

v2v/tests/cfg/v2v_options.cfg

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,13 @@
353353
only output_mode.none
354354
input_disk_image = '/DISK_IMAGE_PATH_V2V_EXAMPLE/IMAGE_WITH_MEM_ALLOC_V2V_EXAMPLE'
355355
v2v_options = '-i disk ${input_disk_image} -o null'
356+
- in_place:
357+
only input_mode.none
358+
only output_mode.none
359+
checkpoint = 'in_place'
360+
disk_path = DEFAULT_TEST_IMAGE
361+
msg_content = 'virt-v2v-in-place: warning: virt-v2v-in-place is NOT SUPPORTED for command'
362+
expect_msg = yes
356363
- negative_test:
357364
status_error = "yes"
358365
variants:
@@ -408,13 +415,6 @@
408415
- 2_mac:
409416
v2v_options = '-i libvirt --mac 00:50:56:ac:6a:23:bridge:test --mac 00:50:56:ac:6a:23:bridge:ovirtmgmt'
410417
msg_content = 'duplicate --mac parameter'
411-
- in_place:
412-
only input_mode.libvirt.xen
413-
only output_mode.libvirt
414-
checkpoint = 'in_place'
415-
v2v_options = '--in-place'
416-
msg_content = 'virt-v2v: error: --in-place cannot be used in RHEL'
417-
expect_msg = yes
418418
- xen_no_output_format:
419419
only input_mode.libvirt.xen
420420
only output_mode.libvirt

v2v/tests/src/function_test_esx.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,11 @@ def vm_check(status_error):
580580
test.fail('check json output failed')
581581
if output_mode == 'kubevirt' and not check_kubevirt_output(params):
582582
test.fail('check kubevirt output failed')
583+
if 'define_disk_path' in checkpoint:
584+
from glob import glob
585+
disk_num = len(glob(os.path.join(os_directory, 'disk*.img')))
586+
if disk_num != vm_disk_count:
587+
test.fail('disk num is incorrect')
583588
if output_mode == 'local' and not check_local_output(params):
584589
test.fail('check local output failed')
585590
if output_mode == 'qemu' and not check_qemu_output(params):
@@ -739,15 +744,16 @@ def vm_check(status_error):
739744

740745
utils_v2v.set_libguestfs_backend(params)
741746
v2v_uri = utils_v2v.Uri('esx')
747+
if src_uri_type == 'esx':
748+
vpx_dc = None
742749
remote_uri = v2v_uri.get_uri(remote_host, vpx_dc, esx_ip)
750+
LOG.debug("Remote host uri for converting: %s", remote_uri)
743751

744752
# Create password file for access to ESX hypervisor
745753
vpx_passwd_file = params.get("vpx_passwd_file")
746-
with open(vpx_passwd_file, 'w') as pwd_f:
747-
if src_uri_type == 'esx':
748-
pwd_f.write(esxi_password)
749-
else:
750-
pwd_f.write(vpx_passwd)
754+
source_pwd = vpx_passwd if src_uri_type != 'esx' else esxi_password
755+
with open(vpx_passwd_file, 'w') as f:
756+
f.write(source_pwd)
751757
v2v_params['v2v_opts'] += " -ip %s" % vpx_passwd_file
752758

753759
if params.get('output_format'):
@@ -922,8 +928,15 @@ def vm_check(status_error):
922928
luks_keys = params_get(params, 'luks_keys', '').split(':')[-1]
923929
v2v_params['v2v_opts'] += ' ' + "$(seq -f '--key /dev/sda%%g:key:%s' 200)" % luks_keys
924930

931+
if 'define_disk_path' in checkpoint:
932+
os_directory = data_dir.get_tmp_dir()
933+
vm_disk_count = int(params_get(params, 'vm_disk_count'))
934+
v2v_params['v2v_opts'] += ' -oo create=true'
935+
for i in range(1, vm_disk_count + 1):
936+
v2v_params['v2v_opts'] += ' -oo disk=%s/disk%s.img' % (os_directory, i)
937+
925938
virsh_dargs = {'uri': remote_uri, 'remote_ip': remote_host,
926-
'remote_user': 'root', 'remote_pwd': vpx_passwd,
939+
'remote_user': 'root', 'remote_pwd': source_pwd,
927940
'auto_close': True,
928941
'debug': True}
929942
remote_virsh = virsh.VirshPersistent(**virsh_dargs)

v2v/tests/src/v2v_options.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,9 @@ def check_alloc():
593593
virt_v2v_version = get_virt_v2v_version.group(1) + '-' + get_virt_v2v_version.group(2)
594594
if (rpm_version != virt_v2v_version):
595595
test.fail('v2v version is incorrect in v2v version option')
596-
596+
if checkpoint == 'in_place':
597+
if not os.path.exists(xml_path):
598+
test.fail('Not found guest xml file')
597599
log_check = utils_v2v.check_log(params, output)
598600
if log_check:
599601
test.fail(log_check)
@@ -726,7 +728,7 @@ def check_alloc():
726728
# Output more messages except quiet mode
727729
if checkpoint == 'quiet':
728730
v2v_options += ' -q'
729-
elif checkpoint not in ['length_of_error', 'empty_nic_source_network', 'line_no_wrap', 'empty_nic_source_bridge', 'machine_readable']:
731+
elif checkpoint not in ['length_of_error', 'empty_nic_source_network', 'line_no_wrap', 'empty_nic_source_bridge', 'machine_readable', 'in_place']:
730732
v2v_options += " -v -x"
731733

732734
# Prepare for libvirt unprivileged user session connection
@@ -846,7 +848,10 @@ def check_alloc():
846848

847849
if checkpoint == 'length_of_error' and utils_v2v.v2v_supported_option('--wrap'):
848850
v2v_options += ' --wrap'
849-
851+
if checkpoint == 'in_place':
852+
disk_path = params.get('disk_path')
853+
xml_path = os.path.join(data_dir.get_tmp_dir(), 'output.xml')
854+
v2v_options += '-i disk %s -O %s' % (disk_path, xml_path)
850855
# Running virt-v2v command
851856
cmd = "%s %s %s %s" % (utils_v2v.V2V_EXEC, input_option,
852857
output_option, v2v_options)
@@ -875,7 +880,8 @@ def check_alloc():
875880
output_func=utils_misc.log_line,
876881
output_params=(params['tail_log'],)
877882
)
878-
883+
if checkpoint == 'in_place':
884+
cmd = re.sub(r".*/bin/virt-v2v", '/usr/libexec/virt-v2v-in-place', cmd)
879885
cmd_result = process.run(cmd, timeout=v2v_timeout, verbose=True,
880886
ignore_status=True)
881887
if new_vm_name:

0 commit comments

Comments
 (0)