-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automate case: Connect to the guest console without serial device #5865
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd better to use virsh.command() but not process for virsh commands if there is no virsh.console related functions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it need second terminal to launch virsh console command, virsh.command will block execution |
||
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we add the
libvirt_version.is_libvirt_feature_supported
in global but not only in if condition. So we can reuse it if we add new test scenarios later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this dependence version is specific to this case only, so keep it in specific case looks more sensible