From patchwork Mon Apr 26 10:07:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 95037 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3QA2hMk011008 for ; Mon, 26 Apr 2010 10:02:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753872Ab0DZKCl (ORCPT ); Mon, 26 Apr 2010 06:02:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30257 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753480Ab0DZKCk (ORCPT ); Mon, 26 Apr 2010 06:02:40 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3QA2dET024941 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 26 Apr 2010 06:02:39 -0400 Received: from localhost.localdomain ([10.66.91.25]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o3QA2bYn011014; Mon, 26 Apr 2010 06:02:38 -0400 Subject: [PATCH 1/3] KVM test: Use customized command to get the version of kvm and its To: autotest@test.kernel.org, lmr@redhat.com From: Jason Wang Cc: kvm@vger.kernel.org Date: Mon, 26 Apr 2010 18:07:26 +0800 Message-ID: <20100426100726.26501.73186.stgit@localhost.localdomain> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 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.3 (demeter.kernel.org [140.211.167.41]); Mon, 26 Apr 2010 10:02:45 +0000 (UTC) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 4b9290c..16200ab 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -225,10 +225,10 @@ def preprocess(test, params, env): # Get the KVM kernel module version and write it as a keyval logging.debug("Fetching KVM module version...") if os.path.exists("/dev/kvm"): - try: - kvm_version = open("/sys/module/kvm/version").read().strip() - except: - kvm_version = os.uname()[2] + kvm_ver_cmd = params.get("kvm_ver_cmd", "cat /sys/module/kvm/version") + s, kvm_version = commands.getstatusoutput(kvm_ver_cmd) + if s != 0: + kvm_version = "Unknown" else: kvm_version = "Unknown" logging.debug("KVM module not loaded") @@ -239,11 +239,11 @@ def preprocess(test, params, env): logging.debug("Fetching KVM userspace version...") qemu_path = kvm_utils.get_path(test.bindir, params.get("qemu_binary", "qemu")) - version_line = commands.getoutput("%s -help | head -n 1" % qemu_path) - matches = re.findall("[Vv]ersion .*?,", version_line) - if matches: - kvm_userspace_version = " ".join(matches[0].split()[1:]).strip(",") - else: + def_qemu_ver_cmd = "%s -help | head -n 1 | awk '{ print $5}'" % qemu_path + kvm_userspace_ver_cmd = params.get("kvm_userspace_ver_cmd", + def_qemu_ver_cmd) + s, kvm_userspace_version = commands.getstatusoutput(kvm_userspace_ver_cmd) + if s != 0: kvm_userspace_version = "Unknown" logging.debug("Could not fetch KVM userspace version") logging.debug("KVM userspace version: %s" % kvm_userspace_version)