From fe4e1dcb643d8a1a3ed99707c2d2497dd36f4197 Mon Sep 17 00:00:00 2001 From: Satheesh Rajendran Date: Mon, 4 May 2020 16:09:43 +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 used to set, So serial session is returned in case of failure, as 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 214420b734..d92a8513a5 100644 --- a/shared/cfg/base.cfg +++ b/shared/cfg/base.cfg @@ -165,6 +165,10 @@ q35, arm64-pci, arm64-mmio: serials = "serial0" serial_type = "isa-serial" +# Enable this to "yes" if you want to force wait_for_login +# to give serial session incase of failure +force_use_serial_login = "no" + # Emulated machine type, run following command to see supported machine type. # qemu-kvm -M ? # machine_type = pc diff --git a/virttest/virt_vm.py b/virttest/virt_vm.py index 6d570dd4e0..7fb49001c4 100644 --- a/virttest/virt_vm.py +++ b/virttest/virt_vm.py @@ -1187,6 +1187,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()