From: Yolkfull Chow <yzhou@redhat.com>
To: Yaniv Kaul <ykaul@redhat.com>
Cc: sudhir kumar <smalikphy@gmail.com>,
kvm-devel <kvm@vger.kernel.org>,
Autotest mailing list <autotest@test.kernel.org>,
Lucas Meneghel Rodrigues <mrodrigu@redhat.com>,
Michael Goldish <mgoldish@redhat.com>
Subject: Re: [PATCH 1/2] Adds a test to verify resources inside a VM
Date: Fri, 4 Dec 2009 17:20:21 +0800 [thread overview]
Message-ID: <20091204092020.GB1816@aFu.nay.redhat.com> (raw)
In-Reply-To: <4B123937.4090500@redhat.com>
On Sun, Nov 29, 2009 at 11:04:55AM +0200, Yaniv Kaul wrote:
> On 11/29/2009 9:20 AM, Yolkfull Chow wrote:
> >On Wed, Nov 25, 2009 at 11:35:02AM +0530, sudhir kumar wrote:
> >>This patch adds a test for verifying whether the number of cpus and amount
> >>of memory as seen inside a guest is same as allocated to it on the qemu
> >>command line.
> >Hello Sudhir,
> >
> >Please see embedded comments as below:
> >
> >>Signed-off-by: Sudhir Kumar<skumar@linux.vnet.ibm.com>
> >>
> >>Index: kvm/tests/verify_resources.py
> >>===================================================================
> >>--- /dev/null
> >>+++ kvm/tests/verify_resources.py
> >>@@ -0,0 +1,74 @@
> >>+import logging, time
> >>+from autotest_lib.client.common_lib import error
> >>+import kvm_subprocess, kvm_test_utils, kvm_utils
> >>+
> >>+"""
> >>+Test to verify if the guest has the equal amount of resources
> >>+as allocated through the qemu command line
> >>+
> >>+@Copyright: 2009 IBM Corporation
> >>+@author: Sudhir Kumar<skumar@linux.vnet.ibm.com>
> >>+
> >>+"""
> >>+
> >>+def run_verify_resources(test, params, env):
> >>+ """
> >>+ KVM test for verifying VM resources(#vcpu, memory):
> >>+ 1) Get resources from the VM parameters
> >>+ 2) Log into the guest
> >>+ 3) Get actual resources, compare and report the pass/failure
> >>+
> >>+ @param test: kvm test object
> >>+ @param params: Dictionary with the test parameters
> >>+ @param env: Dictionary with test environment.
> >>+ """
> >>+ vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
> >>+
> >>+ # Get info about vcpu and memory from dictionary
> >>+ exp_vcpus = int(params.get("smp"))
> >>+ exp_mem_mb = long(params.get("mem"))
> >>+ real_vcpus = 0
> >>+ real_mem_kb = 0
> >>+ real_mem_mb = 0
> >>+ # Some memory is used by bios and all, so lower the expected
> >>value say by 5%
> >>+ exp_mem_mb = long(exp_mem_mb * 0.95)
> >>+ logging.info("The guest should have vcpus: %s" % exp_vcpus)
> >>+ logging.info("The guest should have min mem: %s MB" % exp_mem_mb)
> >>+
> >>+ session = kvm_test_utils.wait_for_login(vm)
> >>+
> >>+ # Get info about vcpu and memory from within guest
> >>+ if params.get("guest_os_type") == "Linux":
> >>+ output = session.get_command_output("cat /proc/cpuinfo|grep processor")
> >We'd better here not hard code the command that getting CPU count. As KVM supports not
> >only Linux& Windows, but also others say Unix/BSD.
> >A recommended method could be define it in config file for different platforms:
> >
> >- @Linux:
> > verify_resources:
> > count_cpu_cmd = grep processor /proc/cpuinfo
> >
> >- @Windows:
> > verify_resources:
> > count_cpu_cmd = systeminfo (here I would not suggest we use 'systeminfo'
> > for catching M$ guest's memory size)
> >
> >>+ for line in output.split('\n'):
> >>+ if 'processor' in line:
> >>+ real_vcpus = real_vcpus + 1
>
> If you want just to count the number of processors, count using:
> "/bin/grep -c processor /proc/cpuinfo"
> However, I feel there's more data we could get from the output -
> such as the topology (sockets/cores/threads) and cpuid level and
> flags which we should look at .
Hi Yaniv,
Thanks very much for comments. Yes, cpuid level and flags are important.
And test of cpu_flags verification has been finished long long ago in our
internal tree. We will add cpuid in later improvement.
Thanks again for pointing this out and also sorry for late reply. :)
>
> >>+
> >>+ output = session.get_command_output("cat /proc/meminfo")
>
> /bin/grep MemTotal /proc/meminfo
> Y.
>
> >For catching memory size of Linux guests, I prefer command 'dmidecode' which can
> >catch memory size exactly in MB.
> >
> >>+ for line in output.split('\n'):
> >>+ if 'MemTotal' in line:
> >>+ real_mem_kb = long(line.split()[1])
> >>+ real_mem_mb = real_mem_kb / 1024
> >>+
> >>+ elif params.get("guest_os_type") == "Windows":
> >>+ # Windows takes long time to display output for systeminfo
> >>+ output = session.get_command_output("systeminfo", timeout =
> >>150, internal_timeout = 50)
> >>+ for line in output.split('\n'):
> >>+ if 'Processor' in line:
> >>+ real_vcpus = int(line.split()[1])
> >>+
> >>+ for line in output.split('\n'):
> >>+ if 'Total Physical Memory' in line:
> >>+ real_mem_mb = long("".join("%s" % k for k in
> >>line.split()[3].split(',')))
> >So many slice and split operations can easy results in problems.
> >To catch memory of Windows guests, I recommend we use 'wmic memphysical' which
> >can dump memory size in KB exactly.
> >
> >
> >Meanwhile, we also need to verify guest's NICs' count and their(its) model,
> >hard disk(s)'s count& model etc. Therefore I think we need a case to verify
> >them together.
> >
> >I had wrote such test couples of days before. I also ran it several times.
> >Please comment on it when I post it here later. Thanks,
> >
> >>+
> >>+ else:
> >>+ raise error.TestFail("Till date this test is supported only
> >>for Linux and Windows")
> >>+
> >>+ logging.info("The guest has cpus: %s" % real_vcpus)
> >>+ logging.info("The guest has mem: %s MB" % real_mem_mb)
> >>+ if exp_vcpus != real_vcpus or real_mem_mb< exp_mem_mb:
> >>+ raise error.TestFail("Actual resources(cpu ='%s' memory ='%s' MB) "
> >>+ "differ from Allocated resources(cpu = '%s' memory ='%s' MB"
> >>+ % (real_vcpus, real_mem_mb, exp_vcpus, exp_mem_mb))
> >>+
> >>+ session.close()
> >>
> >>
> >>
> >>
> >>Sending the patch as an attachment too. Please review and provide your comments.
> >>--
> >>Sudhir Kumar
> >>This patch adds a test for verifying whether the number of cpus and amount
> >>of memory as seen inside a guest is same as allocated to it on the qemu
> >>command line.
> >>
> >>Signed-off-by: Sudhir Kumar<skumar@linux.vnet.ibm.com>
> >>
> >>Index: kvm/tests/verify_resources.py
> >>===================================================================
> >>--- /dev/null
> >>+++ kvm/tests/verify_resources.py
> >>@@ -0,0 +1,74 @@
> >>+import logging, time
> >>+from autotest_lib.client.common_lib import error
> >>+import kvm_subprocess, kvm_test_utils, kvm_utils
> >>+
> >>+"""
> >>+Test to verify if the guest has the equal amount of resources
> >>+as allocated through the qemu command line
> >>+
> >>+@Copyright: 2009 IBM Corporation
> >>+@author: Sudhir Kumar<skumar@linux.vnet.ibm.com>
> >>+
> >>+"""
> >>+
> >>+def run_verify_resources(test, params, env):
> >>+ """
> >>+ KVM test for verifying VM resources(#vcpu, memory):
> >>+ 1) Get resources from the VM parameters
> >>+ 2) Log into the guest
> >>+ 3) Get actual resources, compare and report the pass/failure
> >>+
> >>+ @param test: kvm test object
> >>+ @param params: Dictionary with the test parameters
> >>+ @param env: Dictionary with test environment.
> >>+ """
> >>+ vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
> >>+
> >>+ # Get info about vcpu and memory from dictionary
> >>+ exp_vcpus = int(params.get("smp"))
> >>+ exp_mem_mb = long(params.get("mem"))
> >>+ real_vcpus = 0
> >>+ real_mem_kb = 0
> >>+ real_mem_mb = 0
> >>+ # Some memory is used by bios and all, so lower the expected value say by 5%
> >>+ exp_mem_mb = long(exp_mem_mb * 0.95)
> >>+ logging.info("The guest should have vcpus: %s" % exp_vcpus)
> >>+ logging.info("The guest should have min mem: %s MB" % exp_mem_mb)
> >>+
> >>+ session = kvm_test_utils.wait_for_login(vm)
> >>+
> >>+ # Get info about vcpu and memory from within guest
> >>+ if params.get("guest_os_type") == "Linux":
> >>+ output = session.get_command_output("cat /proc/cpuinfo|grep processor")
> >>+ for line in output.split('\n'):
> >>+ if 'processor' in line:
> >>+ real_vcpus = real_vcpus + 1
> >>+
> >>+ output = session.get_command_output("cat /proc/meminfo")
> >>+ for line in output.split('\n'):
> >>+ if 'MemTotal' in line:
> >>+ real_mem_kb = long(line.split()[1])
> >>+ real_mem_mb = real_mem_kb / 1024
> >>+
> >>+ elif params.get("guest_os_type") == "Windows":
> >>+ # Windows takes long time to display output for systeminfo
> >>+ output = session.get_command_output("systeminfo", timeout = 150, internal_timeout = 50)
> >>+ for line in output.split('\n'):
> >>+ if 'Processor' in line:
> >>+ real_vcpus = int(line.split()[1])
> >>+
> >>+ for line in output.split('\n'):
> >>+ if 'Total Physical Memory' in line:
> >>+ real_mem_mb = long("".join("%s" % k for k in line.split()[3].split(',')))
> >>+
> >>+ else:
> >>+ raise error.TestFail("Till date this test is supported only for Linux and Windows")
> >>+
> >>+ logging.info("The guest has cpus: %s" % real_vcpus)
> >>+ logging.info("The guest has mem: %s MB" % real_mem_mb)
> >>+ if exp_vcpus != real_vcpus or real_mem_mb< exp_mem_mb:
> >>+ raise error.TestFail("Actual resources(cpu ='%s' memory ='%s' MB) "
> >>+ "differ from Allocated resources(cpu = '%s' memory ='%s' MB"
> >>+ % (real_vcpus, real_mem_mb, exp_vcpus, exp_mem_mb))
> >>+
> >>+ session.close()
> >--
> >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 http://vger.kernel.org/majordomo-info.html
>
> --
> 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 http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2009-12-04 9:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-25 6:05 [PATCH 1/2] Adds a test to verify resources inside a VM sudhir kumar
2009-11-27 7:44 ` sudhir kumar
2009-11-27 12:08 ` [Autotest] " Lucas Meneghel Rodrigues
2009-11-29 7:20 ` Yolkfull Chow
2009-11-29 8:52 ` sudhir kumar
2009-11-29 10:40 ` Yolkfull Chow
2009-12-01 13:56 ` [Autotest] " Lucas Meneghel Rodrigues
2009-12-02 2:21 ` Yolkfull Chow
2009-12-02 3:29 ` sudhir kumar
2009-12-02 3:40 ` Lucas Meneghel Rodrigues
2009-12-02 17:09 ` sudhir kumar
2009-11-29 9:04 ` Yaniv Kaul
2009-12-04 9:20 ` Yolkfull Chow [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091204092020.GB1816@aFu.nay.redhat.com \
--to=yzhou@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=mgoldish@redhat.com \
--cc=mrodrigu@redhat.com \
--cc=smalikphy@gmail.com \
--cc=ykaul@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox