From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Wang Subject: [PATCH v2 07/10] KVM test: Introduce local_login() Date: Tue, 11 May 2010 17:04:07 +0800 Message-ID: <20100511090407.19914.58580.stgit@localhost.localdomain> References: <20100511083338.19914.7719.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: lmr@redhat.com, autotest@test.kernel.org Return-path: In-Reply-To: <20100511083338.19914.7719.stgit@localhost.localdomain> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org This patch introduces a new method which is used to log into the guest through the guest serial console. The serial_mode must be set to "session" in order to make use of this patch. Serial does not support cocurrent sessions, so it doest not aim at replacing the regular remote shell servers. But it would be useful for the network related test which may cause the network unresponsive such as driver load/unload or some kinds of network stress testing. Signed-off-by: Jason Wang --- client/tests/kvm/kvm_vm.py | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index cfebfc1..b7151c5 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -815,7 +815,32 @@ class VM: "command", "")) return session + def local_login(self, timeout=240): + """ + Log into the guest via serial console + If timeout expires while waiting for output from the guest (e.g. a + password prompt or a shell prompt) -- fail. + """ + + serial_mode = self.params.get("serial_mode") + username = self.params.get("username", "") + password = self.params.get("password", "") + prompt = self.params.get("shell_prompt", "[\#\$]") + linesep = eval("'%s'" % self.params.get("shell_linesep", r"\n")) + if serial_mode != "session": + logging.debug("serial_mode is not session") + return None + else: + command = "nc -U %s" % self.serial_file_name + assist = self.params.get("prompt_assist", "") + session = kvm_utils.remote_login(command, username, password, prompt, + linesep, timeout, assist) + if session: + session.set_status_test_command(self.params.get("status_test_" + "command", "")) + return session + def copy_files_to(self, local_path, remote_path, nic_index=0, timeout=300): """ Transfer files to the guest.