diff --git a/libvirt/tests/cfg/serial/serial_functional.cfg b/libvirt/tests/cfg/serial/serial_functional.cfg index 678bc94ffb..49b04637c6 100644 --- a/libvirt/tests/cfg/serial/serial_functional.cfg +++ b/libvirt/tests/cfg/serial/serial_functional.cfg @@ -70,6 +70,11 @@ serial_dev_type = pty console_target_type = virtio second_serial_console = yes + - connect_to_console_no_serial_device: + serial_dev_type = pty + error_msg = "cannot find character device" + connect_to_console_without_serial_device = "yes" + func_supported_since_libvirt_ver = (10, 3, 0) - type_tls_server: serial_dev_type = tls serial_sources = mode:bind,host:${local_ip_address},service:5556,tls:yes diff --git a/libvirt/tests/src/serial/serial_functional.py b/libvirt/tests/src/serial/serial_functional.py index d143a64d9b..f83c8ceae9 100644 --- a/libvirt/tests/src/serial/serial_functional.py +++ b/libvirt/tests/src/serial/serial_functional.py @@ -23,6 +23,7 @@ from virttest import libvirt_version from avocado.utils import astring +from avocado.utils import process # Using as lower capital is not the best way to do, but this is just a @@ -746,6 +747,7 @@ def get_console_type(): target_model = params.get('target_model', '') console_target_port = params.get('console_target_port', '0') second_serial_console = params.get('second_serial_console', 'no') == 'yes' + connect_to_console_without_serial_device = params.get('connect_to_console_without_serial_device', 'no') == 'yes' custom_pki_path = params.get('custom_pki_path', '/etc/pki/libvirt-chardev') auto_recover = params.get('auto_recover', 'no') client_pwd = params.get('client_pwd', None) @@ -821,6 +823,12 @@ def get_console_type(): if console_type == 'server': console = prepare_serial_console() + if connect_to_console_without_serial_device: + libvirt_version.is_libvirt_feature_supported(params) + for device_type in remove_devices: + vm_xml.remove_all_device_by_type(device_type) + vm_xml.sync() + res = virsh.start(vm_name) libvirt.check_result(res, expected_fails, []) if res.exit_status: @@ -835,8 +843,19 @@ def get_console_type(): console_type != 'server'): check_serial_console(console, username, password) + if connect_to_console_without_serial_device: + time.sleep(20) + # use raw virsh console command since we need to output message from virsh console VM + result = process.run("virsh console %s" % vm_name, shell=True, verbose=True, ignore_status=True).stderr_text + error_msg = params.get("error_msg") + if error_msg not in result: + test.fail(f"Fail to get expected error message:{error_msg} from console") + vm.destroy() finally: + # Recover VM. + if vm.is_alive(): + vm.destroy(gracefully=False) cleanup(objs_list) vm_xml_backup.sync()