From: Michael Goldish Subject: [KVM-AUTOTEST PATCH 1/6] KVM test: kvm_subprocess: use read_nonblocking(0) instead of read_nonblocking (0.1) Date: Tue, 29 Sep 2009 22:04:22 +0200 Message-ID: <1254254667-19385-1-git-send-email-mgoldish@redhat.com> Cc: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:13542 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751826AbZI2UIB (ORCPT ); Tue, 29 Sep 2009 16:08:01 -0400 Sender: kvm-owner@vger.kernel.org List-ID: In get_command_status_output() and is_responsive() use read_nonblocking(0) to read the unread output before sending input (e.g. a command). The timeout is currently 0.1 because theoretically it should help if the guest still produces output when the function is called, but in practice there's no guarantee that a value of 0.1 will suffice. Therefore, it is be the user's responsibility to make sure the guest stopped producing output before get_command_status_output() is called. This can be guaranteed (in most cases) by using get_command_status_output() and friends instead of sendline() to send commands (because the former waits for the prompt to return, whereas the latter returns immediately). Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_subprocess.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py index 424c801..730f20e 100755 --- a/client/tests/kvm/kvm_subprocess.py +++ b/client/tests/kvm/kvm_subprocess.py @@ -1028,7 +1028,7 @@ class kvm_shell_session(kvm_expect): """ # Read all output that's waiting to be read, to make sure the output # we read next is in response to the newline sent - self.read_nonblocking(timeout=0.1) + self.read_nonblocking(timeout=0) # Send a newline self.sendline() # Wait up to timeout seconds for some output from the child @@ -1095,7 +1095,7 @@ class kvm_shell_session(kvm_expect): logging.debug("Sending command: %s" % command) # Read everything that's waiting to be read - self.read_nonblocking(0.1) + self.read_nonblocking(timeout=0) # Send the command and get its output self.sendline(command) -- 1.5.4.1