From 9f986fffe13e29740c5f3370137455ddc2ad1ed9 Mon Sep 17 00:00:00 2001 From: Satheesh Rajendran Date: Thu, 14 Feb 2019 15:30:42 +0530 Subject: [PATCH] Add a param to force use serial session in case of failure Currently, we do have a logic in wait_for_login to return serial session incase of failure if provided by the user through function param, this patch extends that functionality by adding a param which can be use set, so that serial session is returned in case of failure, this will be helpful as we most of the testcases using wait_for_login with default params and we do not need to modify the testcases, this can be useful during certain env issues if we want to force use serial logins for the same test. Signed-off-by: Satheesh Rajendran --- shared/cfg/base.cfg | 4 ++++ virttest/virt_vm.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/shared/cfg/base.cfg b/shared/cfg/base.cfg index 87578f40b5a..223e672cb0a 100644 --- a/shared/cfg/base.cfg +++ b/shared/cfg/base.cfg @@ -120,6 +120,10 @@ q35, arm64-pci, arm64-mmio: # serials = "S1 S2 S3" serials = "serial0" +# Enable this to "yes" if you want to force wait_for_login +# to give serial session incase of failure +force_use_serial_login = "no" + # virtio_serialport and virtio_console ports # virtio_ports = "vs1 vs2 vc1" # Port types diff --git a/virttest/virt_vm.py b/virttest/virt_vm.py index 5f18ed9a856..957ae9e10a4 100644 --- a/virttest/virt_vm.py +++ b/virttest/virt_vm.py @@ -1149,6 +1149,8 @@ def print_guest_network_info(): session.close() error = None + if not serial: + serial = self.params.get("force_use_serial_login", "no") == "yes" logging.debug("Attempting to log into '%s' (timeout %ds)", self.name, timeout) start_time = time.time()