From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lucas Meneghel Rodrigues Subject: Re: [Autotest] [PATCH 1/3] KVM test: Use customized command to get the version of kvm and its Date: Thu, 6 May 2010 14:16:45 -0300 Message-ID: References: <20100426100726.26501.73186.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: autotest@test.kernel.org, kvm@vger.kernel.org To: Jason Wang Return-path: Received: from mail-ww0-f46.google.com ([74.125.82.46]:41600 "EHLO mail-ww0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751274Ab0EFRQt convert rfc822-to-8bit (ORCPT ); Thu, 6 May 2010 13:16:49 -0400 Received: by wwb39 with SMTP id 39so161020wwb.19 for ; Thu, 06 May 2010 10:16:47 -0700 (PDT) In-Reply-To: <20100426100726.26501.73186.stgit@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Apr 26, 2010 at 7:07 AM, Jason Wang wrote= : > userspace > > Current method may or may not work for various kinds of > distribution. So this patch enable the ability to use customized > commands to get the version of kvm and its userspace. "kvm_ver_cmd" i= s > used for kvm verison and "kvm_userspace_ver_cmd" is for its userspace= =2E The method we are currently using is pretty satisfactory - if we fail in getting /sys/module/kvm/version we use the kernel version as a fallback, which is good for the kernel module. For qemu, we make a regular expression searching for numbers following the string version, so I don't see a reason on why we should make it configurable. Care to provide an example of a situation where the current method fails? > Signed-off-by: Jason Wang > --- > =A0client/tests/kvm/kvm_preprocessing.py | =A0 18 +++++++++--------- > =A01 files changed, 9 insertions(+), 9 deletions(-) > > 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): > =A0 =A0 # Get the KVM kernel module version and write it as a keyval > =A0 =A0 logging.debug("Fetching KVM module version...") > =A0 =A0 if os.path.exists("/dev/kvm"): > - =A0 =A0 =A0 =A0try: > - =A0 =A0 =A0 =A0 =A0 =A0kvm_version =3D open("/sys/module/kvm/versio= n").read().strip() > - =A0 =A0 =A0 =A0except: > - =A0 =A0 =A0 =A0 =A0 =A0kvm_version =3D os.uname()[2] > + =A0 =A0 =A0 =A0kvm_ver_cmd =3D params.get("kvm_ver_cmd", "cat /sys/= module/kvm/version") > + =A0 =A0 =A0 =A0s, kvm_version =3D commands.getstatusoutput(kvm_ver_= cmd) > + =A0 =A0 =A0 =A0if s !=3D 0: > + =A0 =A0 =A0 =A0 =A0 =A0kvm_version =3D "Unknown" > =A0 =A0 else: > =A0 =A0 =A0 =A0 kvm_version =3D "Unknown" > =A0 =A0 =A0 =A0 logging.debug("KVM module not loaded") > @@ -239,11 +239,11 @@ def preprocess(test, params, env): > =A0 =A0 logging.debug("Fetching KVM userspace version...") > =A0 =A0 qemu_path =3D kvm_utils.get_path(test.bindir, params.get("qem= u_binary", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"qemu")) > - =A0 =A0version_line =3D commands.getoutput("%s -help | head -n 1" %= qemu_path) > - =A0 =A0matches =3D re.findall("[Vv]ersion .*?,", version_line) > - =A0 =A0if matches: > - =A0 =A0 =A0 =A0kvm_userspace_version =3D " ".join(matches[0].split(= )[1:]).strip(",") > - =A0 =A0else: > + =A0 =A0def_qemu_ver_cmd =3D "%s -help | head -n 1 | awk '{ print $5= }'" % qemu_path > + =A0 =A0kvm_userspace_ver_cmd =3D params.get("kvm_userspace_ver_cmd"= , > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 def_qemu_ver_cmd) > + =A0 =A0s, kvm_userspace_version =3D commands.getstatusoutput(kvm_us= erspace_ver_cmd) > + =A0 =A0if s !=3D 0: > =A0 =A0 =A0 =A0 kvm_userspace_version =3D "Unknown" > =A0 =A0 =A0 =A0 logging.debug("Could not fetch KVM userspace version"= ) > =A0 =A0 logging.debug("KVM userspace version: %s" % kvm_userspace_ver= sion) > > _______________________________________________ > Autotest mailing list > Autotest@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest > --=20 Lucas