From mboxrd@z Thu Jan 1 00:00:00 1970 From: Amos Kong Subject: Re: [PATCH] KVM test: Add a subtest cpuflags Date: Fri, 29 Jul 2011 13:27:05 +0800 Message-ID: References: <1267687233-26740-1-git-send-email-sshang@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: sshang , lmr@redhat.com, autotest@test.kernel.org, kvm@vger.kernel.org Return-path: In-Reply-To: <1267687233-26740-1-git-send-email-sshang@redhat.com> 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 On Thu, Mar 4, 2010 at 3:20 PM, sshang wrote: > =A0This test mainly tests whether all guest cpu flags are supported by ho= st machine. > > Signed-off-by: sshang Hi Lucas, It seems that this patch[1] was lost by us. Have confirmed with shuang, this subtest needs to be refactored. So let's wait the new version! [1] https://patchwork.kernel.org/patch/83543/ > --- > =A0client/tests/kvm/tests/cpuflags.py =A0 =A0 | =A0 80 ++++++++++++++++++= ++++++++++++++ > =A0client/tests/kvm/tests_base.cfg.sample | =A0 =A09 +++- > =A02 files changed, 88 insertions(+), 1 deletions(-) > =A0create mode 100644 client/tests/kvm/tests/cpuflags.py > > diff --git a/client/tests/kvm/tests/cpuflags.py b/client/tests/kvm/tests/= cpuflags.py > new file mode 100644 > index 0000000..5f51d65 > --- /dev/null > +++ b/client/tests/kvm/tests/cpuflags.py > @@ -0,0 +1,80 @@ > +import logging,os,commands > +from autotest_lib.client.common_lib import error > +import kvm_test_utils > + > +def run_cpuflags(test,params,env): > + =A0 =A0""" > + =A0 =A0Check guest cpu extension flags supported by host > + =A0 =A01) Log into =A0guest > + =A0 =A02) Get guest cpu information and host cpu information > + =A0 =A03) Compare with each other make sure host cpu extension flags > + =A0 =A0 =A0 bits contain guest > + > + =A0 =A0@param test: kvm test object > + =A0 =A0@param params: Dictionary with the test parameters > + =A0 =A0@param env: Dictionary with test environment. > + =A0 =A0""" > + =A0 =A0vm =3D kvm_test_utils.get_living_vm(env, params.get("main_vm")) > + =A0 =A0session =3D kvm_test_utils.wait_for_login(vm, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0timeout=3Dint(params.get("login_time= out", 360))) > + > + =A0 =A0get_cpuflags_cmd =3D params.get("getcpuflags") > + =A0 =A0s, o =3D session.get_command_status_output(get_cpuflags_cmd) > + =A0 =A0if s !=3D 0: > + =A0 =A0 =A0 =A0raise error.TestFail, "Could not read guest cpu flags" > + =A0 =A0guest_cpuflags_list =3D o.splitlines()[0].split(':')[1].split() > + =A0 =A0host_cpuflags_list =3D commands.getoutput(get_cpuflags_cmd).\ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 splitlines()[0].split('= :')[1].split() > + > + =A0 =A0logging.debug("Host flags %s" % host_cpuflags_list) > + =A0 =A0logging.debug("Guest flags %s" % guest_cpuflags_list) > + > + =A0 =A0# There are some special flags, for example 'hypervisor', 'sep', > + =A0 =A0# present in guests but not in the hosts, exclude these flags fr= om > + =A0 =A0# comparison. > + =A0 =A0ban_flags_list =3D params.get("ban_flags").split() > + > + =A0 =A0guest_cpuflags_set =3D set(guest_cpuflags_list) > + =A0 =A0host_cpuflags_set =3D set(host_cpuflags_list) > + > + =A0 =A0# If the excluded flags provided by the config file that exist i= n the > + =A0 =A0# host, remove them from the ban_flags_list, because we require = kvm > + =A0 =A0# virtualize/simulate the host. > + =A0 =A0if params.get("strict_check") =3D=3D "yes": > + =A0 =A0 =A0 =A0for flag in ban_flags_list: > + =A0 =A0 =A0 =A0 =A0 =A0if flag in host_cpuflags_list: > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ban_flags_list.remove(flag) > + > + =A0 =A0# exclude the banned flags from guest flags set. > + =A0 =A0for flag in ban_flags_list: > + =A0 =A0 =A0 =A0if flag in guest_cpuflags_set: > + =A0 =A0 =A0 =A0 =A0 =A0guest_cpuflags_set.remove(flag) > + > + =A0 =A0if guest_cpuflags_set.issubset(host_cpuflags_set): > + =A0 =A0 =A0 =A0logging.info("Guest cpu flags all supported by host") > + =A0 =A0else: > + =A0 =A0 =A0 =A0invalidflags_set =3D guest_cpuflags_set - host_cpuflags_= set > + =A0 =A0 =A0 =A0host_cpuflags_str =3D str(host_cpuflags_set)[4:-1] > + =A0 =A0 =A0 =A0invalidflags_str =3D '' > + =A0 =A0 =A0 =A0for i in invalidflags_set: > + =A0 =A0 =A0 =A0 =A0 =A0if host_cpuflags_str.find(i.strip()) =3D=3D -1: > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0invalidflags_str =3D invalidflags_str + = i + ',' > + > + =A0 =A0 =A0 =A0if invalidflags_str.strip() !=3D '': > + =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("Unsupported cpu flags by h= ost: %s" % \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0invalidflags_str[0:-1]) > + > + =A0 =A0# check the extra cpuflags in guest. > + =A0 =A0extra_flags_set =3D set(params.get("extra_flags").split()) > + =A0 =A0if extra_flags_set.issubset(guest_cpuflags_set): > + =A0 =A0 =A0 =A0logging.info("All extra flags are found in guest.") > + =A0 =A0else: > + =A0 =A0 =A0 =A0invalidflags_set =3D extra_flags_set - guest_cpuflags_set > + =A0 =A0 =A0 =A0invalidflags_str =3D '' > + =A0 =A0 =A0 =A0for i in invalidflags_set: > + =A0 =A0 =A0 =A0 =A0 =A0invalidflags_str =3D invalidflags_str + i + ',' > + =A0 =A0 =A0 =A0raise error.TestFail("Unsupported extra flags by guest: = %s" % \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0invalidflags_str[0:-1]) > + > + =A0 =A0session.close() > + > diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/te= sts_base.cfg.sample > index 040d0c3..f7dcbb6 100644 > --- a/client/tests/kvm/tests_base.cfg.sample > +++ b/client/tests/kvm/tests_base.cfg.sample > @@ -300,6 +300,13 @@ variants: > =A0 =A0 =A0 =A0 shutdown_method =3D shell > =A0 =A0 =A0 =A0 kill_vm =3D yes > =A0 =A0 =A0 =A0 kill_vm_gracefully =3D no > + > + =A0 =A0- cpuflags: > + =A0 =A0 =A0 =A0type =3D cpuflags > + =A0 =A0 =A0 =A0getcpuflags =3D grep 'flags' /proc/cpuinfo > + =A0 =A0 =A0 =A0ban_flags =3D "up sep hypervisor sep_good" > + =A0 =A0 =A0 =A0extra_flags =3D "" > + =A0 =A0 =A0 =A0strict_check =3D yes > =A0 =A0 # Do not define test variants below shutdown > > > @@ -1001,7 +1008,7 @@ variants: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 md5sum =3D 9fae22f2666369968a76ef59e9a81c= ed > > > -linux_s3: > +linux_s3|cpuflags: > =A0 =A0 only Linux > > > -- > 1.5.5.6 > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at =A0http://vger.kernel.org/majordomo-info.html >