From patchwork Tue Jun 28 09:45:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: qzhou@redhat.com X-Patchwork-Id: 924002 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5S9vBZk023115 for ; Tue, 28 Jun 2011 09:57:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754811Ab1F1JrY (ORCPT ); Tue, 28 Jun 2011 05:47:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59468 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753532Ab1F1JpY (ORCPT ); Tue, 28 Jun 2011 05:45:24 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5S9jNhJ022079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 28 Jun 2011 05:45:23 -0400 Received: from qzhou-TP.nay.redhat.com ([10.66.65.207]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p5S9jLJa003318; Tue, 28 Jun 2011 05:45:22 -0400 From: Qingtang Zhou To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Qingtang Zhou Subject: [PATCH 2/3] KVM-Test: unattended_install.py: Get anaconda log and save it to log file Date: Tue, 28 Jun 2011 17:45:19 +0800 Message-Id: <1309254319-30182-1-git-send-email-qzhou@redhat.com> In-Reply-To: <1309254299-30095-1-git-send-email-qzhou@redhat.com> References: <1309254299-30095-1-git-send-email-qzhou@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 28 Jun 2011 09:57:40 +0000 (UTC) This patch will save guest's anaconda log to 'anaconda.log' in debug directory. Signed-off-by: Qingtang Zhou --- client/tests/kvm/tests/unattended_install.py | 31 ++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/tests/unattended_install.py b/client/tests/kvm/tests/unattended_install.py index 50a8c7a..d631404 100644 --- a/client/tests/kvm/tests/unattended_install.py +++ b/client/tests/kvm/tests/unattended_install.py @@ -494,6 +494,28 @@ class UnattendedInstallConfig(object): raise ValueError("Unexpected installation method %s" % self.medium) +def _get_anaconda_log(vm, log_file): + port = int(vm.params.get("guest_port_unattended_install")) - 1 + port = vm.get_port(port) + + anaconda_logfile = open(log_file, 'w') + + while True: + client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + try: + client.connect((vm.get_address(), port)) + install_log = client.recv(10240) + if install_log != "": + anaconda_logfile.write(install_log) + anaconda_logfile.flush() + client.send("ok %s\n" % str(time.time())) + except (socket.error, virt_vm.VMAddressError): + pass + finally: + client.close() + time.sleep(1) + + anaconda_logfile.close() @error.context_aware def run_unattended_install(test, params, env): @@ -524,6 +546,13 @@ def run_unattended_install(test, params, env): "(%d min)", install_timeout, install_timeout/60) error.context("waiting for installation to finish") + get_anaconda_log = params.get("get_anaconda_log") == "yes" + if get_anaconda_log: + log_file = os.path.join(test.debugdir, "anaconda.log") + bg = virt_utils.Thread(_get_anaconda_log, + kwargs={"vm": vm, "log_file": log_file}) + bg.start() + start_time = time.time() while (time.time() - start_time) < install_timeout: try: @@ -539,6 +568,8 @@ def run_unattended_install(test, params, env): try: client.connect((vm.get_address(), port)) if client.recv(1024) == "done": + if get_anaconda_log: + bg.join() break except (socket.error, virt_vm.VMAddressError): pass