Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions libvirt/tests/src/bios/boot_order_ovmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ def check_boot(vm, test, params):
time.sleep(3)
if not status_error:
try:
vm.cleanup_serial_console()
vm.create_serial_console()
vm.wait_for_serial_login()
vm.wait_for_serial_login(recreate_serial_console=True)
except Exception as error:
test.fail(f"Test fail: {error}")
else:
test.log.debug("Succeed to boot %s", vm.name)
else:
try:
vm.cleanup_serial_console()
vm.create_serial_console()
vm.wait_for_serial_login()
vm.wait_for_serial_login(recreate_serial_console=True)
except LoginTimeoutError as expected_e:
test.log.debug(f"Got expected error message: {expected_e}")
except Exception as e:
Expand Down
8 changes: 2 additions & 6 deletions libvirt/tests/src/bios/boot_order_seabios.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,14 @@ def run(test, params, env):
internal_timeout=0.5)
else:
time.sleep(3)
vm.cleanup_serial_console()
vm.create_serial_console()
vm.wait_for_serial_login(timeout=15)
vm.wait_for_serial_login(timeout=15, recreate_serial_console=True)
except Exception as e:
test.fail(f"Test fail: {str(e)}")
else:
test.log.debug("Succeed to boot %s", vm_name)
else:
try:
vm.cleanup_serial_console()
vm.create_serial_console()
vm.wait_for_serial_login(timeout=15)
vm.wait_for_serial_login(timeout=15, recreate_serial_console=True)
except LoginTimeoutError as expected_e:
test.log.debug("Got expected error message: %s", str(expected_e))
except Exception as exc:
Expand Down
6 changes: 1 addition & 5 deletions libvirt/tests/src/migration/migrate_mem.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,7 @@ def verify_test_back_mem_nvdimm(vm, params, test):
:param test: test object
"""
vm.connect_uri = params.get("virsh_migrate_connect_uri")
if vm.serial_console is not None:
test.log.debug("clean up old serial console")
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=240)
vm_session = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)
cmd = 'mount -o dax /dev/pmem0 /mnt'
vm_session.cmd(cmd)
expected_content = params.get('test_file_content') + '.back'
Expand Down
15 changes: 3 additions & 12 deletions libvirt/tests/src/migration/migrate_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,7 @@ def create_fake_tap(remote_session):
vm_xml.VMXML.new_from_dumpxml(vm_name))

# Check local guest network connection before migration
if vm.serial_console is not None:
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=240)
vm_session = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)
if not utils_package.package_install('dhcp-client', session=vm_session):
test.error("Failed to install dhcp-client on guest.")
utils_net.restart_guest_network(vm_session)
Expand All @@ -343,10 +340,7 @@ def create_fake_tap(remote_session):
# Check network accessibility after migration
if int(mig_result.exit_status) == 0:
vm.connect_uri = dest_uri
if vm.serial_console is not None:
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session_after_mig = vm.wait_for_serial_login(timeout=240)
vm_session_after_mig = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)
vm_session_after_mig.cmd(restart_dhclient)
check_vm_network_accessed(ping_dest, session=vm_session_after_mig)

Expand Down Expand Up @@ -393,10 +387,7 @@ def create_fake_tap(remote_session):
logging.debug("VM is migrated back.")

vm.connect_uri = bk_uri
if vm.serial_console is not None:
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session_after_mig_bak = vm.wait_for_serial_login(timeout=240)
vm_session_after_mig_bak = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)
vm_session_after_mig_bak.cmd(restart_dhclient)
check_vm_network_accessed(ping_dest, vm_session_after_mig_bak)
finally:
Expand Down
4 changes: 1 addition & 3 deletions libvirt/tests/src/migration/migrate_with_panic_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ def verify_test():
migration_obj.verify_default()

backup_uri, vm.connect_uri = vm.connect_uri, dest_uri
vm.cleanup_serial_console()
vm.create_serial_console()
remote_vm_session = vm.wait_for_serial_login(timeout=360)
remote_vm_session = vm.wait_for_serial_login(timeout=360, recreate_serial_console=True)
try:
remote_vm_session.cmd("systemctl stop kdump", ignore_all_errors=True)
remote_vm_session.cmd("echo 1 > /proc/sys/kernel/sysrq")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ def verify_test():
expect_str = params.get("expect_str")

backup_uri, vm.connect_uri = vm.connect_uri, desturi
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=120)
vm_session = vm.wait_for_serial_login(timeout=120, recreate_serial_console=True)
output = vm_session.cmd_output("df -h")
vm_session.close()
test.log.debug("output: %s", output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ def verify_test():
mnt_path_name = params.get("mnt_path_name")

backup_uri, vm.connect_uri = vm.connect_uri, desturi
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=120)
vm_session = vm.wait_for_serial_login(timeout=120, recreate_serial_console=True)
output = vm_session.cmd_output("df -h")
test.log.debug("output: %s", output)
if not re.search(expect_str, output):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ def check_vtpm_func(params, vm, test, on_remote=False):
src_uri = params.get("virsh_migrate_connect_uri")
test.log.debug("Check vtpm func: (on_remote: %s).", on_remote)
if on_remote:
if vm.serial_console is not None:
vm.cleanup_serial_console()
vm.connect_uri = dest_uri
if vm.serial_console is None:
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=240)
vm_session = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)
if not utils_package.package_install("tpm2-tools", vm_session):
test.error("Failed to install tpm2-tools in vm")
cmd_result = vm_session.cmd_status(tpm_cmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ def check_vtpm_func(params, vm, test, remote=False):
src_uri = params.get("virsh_migrate_connect_uri")
test.log.debug("Check vtpm func: %s (remote).", remote)
if remote:
if vm.serial_console is not None:
vm.cleanup_serial_console()
vm.connect_uri = dest_uri
if vm.serial_console is None:
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=240)
vm_session = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)
if not utils_package.package_install("tpm2-tools", vm_session):
test.error("Failed to install tpm2-tools in vm")
cmd_result = vm_session.cmd_status(tpm_cmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ def check_vtpm_func(params, vm, test, remote=False):
src_uri = params.get("virsh_migrate_connect_uri")
test.log.debug("Check vtpm func: %s (remote).", remote)
if remote:
if vm.serial_console is not None:
vm.cleanup_serial_console()
vm.connect_uri = dest_uri
if vm.serial_console is None:
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=240)
vm_session = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)
if not utils_package.package_install("tpm2-tools", vm_session):
test.error("Failed to install tpm2-tools in vm")
cmd_result = vm_session.cmd_status(tpm_cmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def verify_test():

test.log.info("Verify steps.")
backup_uri, vm.connect_uri = vm.connect_uri, dest_uri
vm.cleanup_serial_console()
vm.create_serial_console()
remote_vm_session = vm.wait_for_serial_login(timeout=360)
remote_vm_session = vm.wait_for_serial_login(timeout=360, recreate_serial_console=True)
remote_vm_dmesg = remote_vm_session.cmd_output("dmesg")
if "I/O error" in remote_vm_dmesg:
test.fail(f"Found I/O error in guest dmesg: {remote_vm_dmesg}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ def check_disk(params, vm):
disk_target1 = params.get("disk_target1")
disk_target2 = params.get("disk_target2")

vm.cleanup_serial_console()
backup_uri, vm.connect_uri = vm.connect_uri, dest_uri
vm.create_serial_console()
remote_vm_session = vm.wait_for_serial_login(timeout=120)
remote_vm_session = vm.wait_for_serial_login(timeout=120, recreate_serial_console=True)
utils_disk.linux_disk_check(remote_vm_session, disk_target1)
utils_disk.linux_disk_check(remote_vm_session, disk_target2)

Expand Down
4 changes: 1 addition & 3 deletions libvirt/tests/src/nwfilter/nwfilter_binding_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ def attach_new_device():
utlv.check_result(ret, expected_match=[r"vnet\d+\s+clean-traffic"])
utlv.check_result(ret, expected_match=[r"vnet\d+\s+allow-dhcp-server"])
# detach a interface, before detach, make sure guest boot up
vm.cleanup_serial_console()
vm.create_serial_console()
vm.wait_for_serial_login().close
vm.wait_for_serial_login(recreate_serial_console=True).close()
option = "--type network" + " --mac " + new_iface_1.mac_address
ret = virsh.detach_interface(vm_name, option, debug=True)
time.sleep(time_wait)
Expand Down
4 changes: 1 addition & 3 deletions libvirt/tests/src/snapshot/revert_disk_external_snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def revert_snap_and_check_files(params, vm, test, snap_name, expected_files):

virsh.snapshot_revert(vm.name, snap_name, options=options, **virsh_dargs)

vm.cleanup_serial_console()
vm.create_serial_console()
session = vm.wait_for_serial_login()
session = vm.wait_for_serial_login(recreate_serial_console=True)
for file in expected_files:
output = session.cmd('ls %s' % file)
if file not in output:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def check_file_exist(test, vm, params, revert_snap):

if not vm.is_alive():
virsh.start(vm_name)
vm.cleanup_serial_console()
vm.create_serial_console()
session = vm.wait_for_serial_login()
session = vm.wait_for_serial_login(recreate_serial_console=True)

if revert_snap == "1":
file_list = eval(params.get("file_list"))[0:1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def run_test():

test.log.info("TEST_STEP2: Start the VM")
vm.start()
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=240)
vm_session = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)

test.log.info("TEST_STEP3: Check interface quantity and network"
"accessibility.")
Expand Down
12 changes: 3 additions & 9 deletions libvirt/tests/src/sriov/failover/sriov_failover_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def run_test():

test.log.info("TEST_STEP2: Start the VM")
vm.start()
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=240)
vm_session = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)

test.log.info("TEST_STEP3: Check network accessibility")
check_points.check_vm_network_accessed(vm_session,
Expand Down Expand Up @@ -67,9 +65,7 @@ def run_test():
virsh.restore(save_file, debug=True, ignore_status=False)
if not libvirt.check_vm_state(vm_name, "running"):
test.fail("The guest should be running after executing 'virsh restore'.")
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login()
vm_session = vm.wait_for_serial_login(recreate_serial_console=True)

test.log.info("TEST_STEP7: Check network accessibility")
check_points.check_vm_network_accessed(vm_session,
Expand All @@ -80,9 +76,7 @@ def run_test():
test.log.info("TEST_STEP8: Managedsave the VM.")
virsh.managedsave(vm_name, debug=True, ignore_status=False, timeout=10)
vm.start()
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login()
vm_session = vm.wait_for_serial_login(recreate_serial_console=True)

test.log.info("TEST_STEP9: Check network accessibility")
check_points.check_vm_network_accessed(vm_session,
Expand Down
4 changes: 1 addition & 3 deletions libvirt/tests/src/sriov/failover/sriov_failover_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ def verify_network():
"""
Verify network function
"""
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=240)
vm_session = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)
check_points.check_vm_iface_num(vm_session, expr_iface_no,
timeout=40, first=15)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ def parse_iface_dict(pf_pci):
test.log.debug("Verify: Check VF driver successfully after detaching hostdev interface/device - PASS")
virsh.reboot(vm.name, ignore_status=False, debug=True)
test.log.debug("Verify: VM reboot is successful after detaching hostdev interface/device - PASS")
vm.cleanup_serial_console()
vm.create_serial_console()
vm.wait_for_serial_login().close()
vm.wait_for_serial_login(recreate_serial_console=True).close()
finally:
orig_vm_xml.sync()
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ def run_test():
if start_vm:
if not vm.is_alive():
vm.start()
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=240)
vm_session = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)

libvirt_vfio.check_vfio_pci(sriov_test_obj.vf_pci, True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def run_test():
if start_vm:
if not vm.is_alive():
vm.start()
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=240)
vm_session = vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)

mac_addr = utils_net.generate_mac_address_simple()
alias_name = 'ua-' + str(uuid.uuid4())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def get_vm_session(vm):
:return: The session of VM
"""
vm.start()
vm.cleanup_serial_console()
vm.create_serial_console()
return vm.wait_for_serial_login(timeout=240)
return vm.wait_for_serial_login(timeout=240, recreate_serial_console=True)

def run_test():
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ def detach_dev(device_type, dev_iommu_info, vm_session):
test.log.info("TEST_STEP: Start the VM.")
if not vm.is_alive():
vm.start()
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
timeout=int(params.get('login_timeout')),
recreate_serial_console=True)
pre_devices = viommu_base.get_devices_pci(vm_session, test_devices)
if disk_dict:
test.log.info("TEST_STEP: Attach a disk device to VM.")
Expand Down
5 changes: 2 additions & 3 deletions libvirt/tests/src/sriov/vIOMMU/intel_iommu_aw_bits.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ def run(test, params, env):
if err_msg:
libvirt.check_result(result, err_msg)
return
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
timeout=int(params.get('login_timeout')),
recreate_serial_console=True)
test.log.debug(vm_xml.VMXML.new_from_dumpxml(vm.name))

test.log.info("TEST_STEP: Check dmesg message.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def run(test, params, env):
test.log.debug("The current guest xml ls: %s",
virsh.dumpxml(vm_name).stdout_text)
test.log.info("TEST STEP3: Check the message for iommu group and DMA.")
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(timeout=1000)
vm_session = vm.wait_for_serial_login(timeout=1000, recreate_serial_console=True)
dma_status, dma_o = vm_session.cmd_status_output("dmesg | grep -i 'Not attempting DMA translation'")
iommu_status, iommu_o = vm_session.cmd_status_output("dmesg | grep -i 'Adding to iommu group'")
if dma_translation == "on" and (not dma_status or iommu_status):
Expand Down
5 changes: 2 additions & 3 deletions libvirt/tests/src/sriov/vIOMMU/iommu_device_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ def run(test, params, env):
test_obj.setup_iommu_test(iommu_dict=iommu_dict, cleanup_ifaces=cleanup_ifaces)
test_obj.prepare_controller()
vm.start()
vm.cleanup_serial_console()
vm.create_serial_console()
vm_session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
timeout=int(params.get('login_timeout')),
recreate_serial_console=True)
pre_devices = viommu_base.get_devices_pci(vm_session, test_devices)
vm.destroy()

Expand Down
4 changes: 1 addition & 3 deletions libvirt/tests/src/sriov/vIOMMU/viommu_unload_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ def all_threads_alive(threads):
time.sleep(5)

test.log.info("TEST_STEP: Unload and load the driver.")
vm.cleanup_serial_console()
vm.create_serial_console()
vm_serial = vm.wait_for_serial_login(timeout=120)
vm_serial = vm.wait_for_serial_login(timeout=120, recreate_serial_console=True)
while not all_threads_done(threads):
vm_serial.cmd("modprobe -r %s" % nic_driver, timeout=120)
time.sleep(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def run(test, params, env):
dev_names = sriov_vfio.attach_dev(vm, params)
if not vm.is_alive():
vm.start()
vm.cleanup_serial_console()
vm.create_serial_console()
vm.wait_for_serial_login().close()
vm.wait_for_serial_login(recreate_serial_console=True).close()
time.sleep(30)

test.log.debug(f'VMXML of {vm_name}:\n{virsh.dumpxml(vm_name).stdout_text}')
Expand Down
Loading