* [PATCH 1/2] Adds a test to verify resources inside a VM
@ 2009-11-25 6:05 sudhir kumar
2009-11-27 7:44 ` sudhir kumar
2009-11-29 7:20 ` Yolkfull Chow
0 siblings, 2 replies; 13+ messages in thread
From: sudhir kumar @ 2009-11-25 6:05 UTC (permalink / raw)
To: kvm-devel
Cc: Autotest mailing list, Lucas Meneghel Rodrigues, Michael Goldish,
smalikphy
[-- Attachment #1: Type: text/plain, Size: 3423 bytes --]
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()
Sending the patch as an attachment too. Please review and provide your comments.
--
Sudhir Kumar
[-- Attachment #2: add_vcpu_verify_test.patch --]
[-- Type: text/x-patch, Size: 3322 bytes --]
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()
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] Adds a test to verify resources inside a VM
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
1 sibling, 1 reply; 13+ messages in thread
From: sudhir kumar @ 2009-11-27 7:44 UTC (permalink / raw)
To: kvm-devel
Cc: Autotest mailing list, Lucas Meneghel Rodrigues, Michael Goldish,
smalikphy
Folks,
Any comments on the patch below ?
On Wed, Nov 25, 2009 at 11:35 AM, sudhir kumar <smalikphy@gmail.com> 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.
>
> 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()
>
>
>
>
> Sending the patch as an attachment too. Please review and provide your comments.
> --
> Sudhir Kumar
>
--
Sudhir Kumar
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Autotest] [PATCH 1/2] Adds a test to verify resources inside a VM
2009-11-27 7:44 ` sudhir kumar
@ 2009-11-27 12:08 ` Lucas Meneghel Rodrigues
0 siblings, 0 replies; 13+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-11-27 12:08 UTC (permalink / raw)
To: sudhir kumar; +Cc: kvm-devel, Autotest mailing list, Lucas Meneghel Rodrigues
On Fri, 2009-11-27 at 13:14 +0530, sudhir kumar wrote:
> Folks,
> Any comments on the patch below ?
I'll get to it today and comment on it, Sudhir, thanks!
> On Wed, Nov 25, 2009 at 11:35 AM, sudhir kumar <smalikphy@gmail.com> 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.
> >
> > 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()
> >
> >
> >
> >
> > Sending the patch as an attachment too. Please review and provide your comments.
> > --
> > Sudhir Kumar
> >
>
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] Adds a test to verify resources inside a VM
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-29 7:20 ` Yolkfull Chow
2009-11-29 8:52 ` sudhir kumar
2009-11-29 9:04 ` Yaniv Kaul
1 sibling, 2 replies; 13+ messages in thread
From: Yolkfull Chow @ 2009-11-29 7:20 UTC (permalink / raw)
To: sudhir kumar
Cc: kvm-devel, Autotest mailing list, Lucas Meneghel Rodrigues,
Michael Goldish
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
> +
> + output = session.get_command_output("cat /proc/meminfo")
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()
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] Adds a test to verify resources inside a VM
2009-11-29 7:20 ` Yolkfull Chow
@ 2009-11-29 8:52 ` sudhir kumar
2009-11-29 10:40 ` Yolkfull Chow
2009-11-29 9:04 ` Yaniv Kaul
1 sibling, 1 reply; 13+ messages in thread
From: sudhir kumar @ 2009-11-29 8:52 UTC (permalink / raw)
To: Yolkfull Chow
Cc: kvm-devel, Autotest mailing list, Lucas Meneghel Rodrigues,
Michael Goldish
On Sun, Nov 29, 2009 at 12:50 PM, Yolkfull Chow <yzhou@redhat.com> 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:
I agree. The only concern that made me doing it inside test is the
increasing size and complexity of the config file. I am fine with
passing the command from the config file but still the code paths have
to be different for each type of OS ie windows linux etc.
>
> - @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
>> +
>> + output = session.get_command_output("cat /proc/meminfo")
>
> For catching memory size of Linux guests, I prefer command 'dmidecode' which can
> catch memory size exactly in MB.
I think we can use both here. To my knowledge dmidecode will test the
BIOS code of kvm and hence we can include both the methods?
>
>> + 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.
Is the command available for all windows OSes? If yes we can
definitely use the command.
>
>
> 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.
Yeah, I just gave a first try for such a test. We need to test all the
emulated hardware.
>
> 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,
Sure. Please post them. I am happy to see them getting merged.
Thanks a lot for your comments!!
Sudhir
>
>> +
>> + 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()
>
>
--
Sudhir Kumar
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] Adds a test to verify resources inside a VM
2009-11-29 7:20 ` Yolkfull Chow
2009-11-29 8:52 ` sudhir kumar
@ 2009-11-29 9:04 ` Yaniv Kaul
2009-12-04 9:20 ` Yolkfull Chow
1 sibling, 1 reply; 13+ messages in thread
From: Yaniv Kaul @ 2009-11-29 9:04 UTC (permalink / raw)
To: Yolkfull Chow
Cc: sudhir kumar, kvm-devel, Autotest mailing list,
Lucas Meneghel Rodrigues, Michael Goldish
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 .
>> +
>> + 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
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] Adds a test to verify resources inside a VM
2009-11-29 8:52 ` sudhir kumar
@ 2009-11-29 10:40 ` Yolkfull Chow
2009-12-01 13:56 ` [Autotest] " Lucas Meneghel Rodrigues
0 siblings, 1 reply; 13+ messages in thread
From: Yolkfull Chow @ 2009-11-29 10:40 UTC (permalink / raw)
To: sudhir kumar
Cc: kvm-devel, Autotest mailing list, Lucas Meneghel Rodrigues,
Michael Goldish
On Sun, Nov 29, 2009 at 02:22:40PM +0530, sudhir kumar wrote:
> On Sun, Nov 29, 2009 at 12:50 PM, Yolkfull Chow <yzhou@redhat.com> 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:
> I agree. The only concern that made me doing it inside test is the
> increasing size and complexity of the config file. I am fine with
> passing the command from the config file but still the code paths have
> to be different for each type of OS ie windows linux etc.
>
> >
> > - @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
> >> +
> >> + output = session.get_command_output("cat /proc/meminfo")
> >
> > For catching memory size of Linux guests, I prefer command 'dmidecode' which can
> > catch memory size exactly in MB.
> I think we can use both here. To my knowledge dmidecode will test the
> BIOS code of kvm and hence we can include both the methods?
> >
> >> + 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.
> Is the command available for all windows OSes? If yes we can
> definitely use the command.
Yes it's available for all Windows OSes although with some limitations that it can
only be executed within TELNET session or Windows command prompt. But it's fixed now.:)
Cheers,
> >
> >
> > 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.
> Yeah, I just gave a first try for such a test. We need to test all the
> emulated hardware.
> >
> > 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,
> Sure. Please post them. I am happy to see them getting merged.
>
> Thanks a lot for your comments!!
> Sudhir
>
> >
> >> +
> >> + 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()
> >
> >
>
>
>
> --
> Sudhir Kumar
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Autotest] [PATCH 1/2] Adds a test to verify resources inside a VM
2009-11-29 10:40 ` Yolkfull Chow
@ 2009-12-01 13:56 ` Lucas Meneghel Rodrigues
2009-12-02 2:21 ` Yolkfull Chow
0 siblings, 1 reply; 13+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-12-01 13:56 UTC (permalink / raw)
To: Yolkfull Chow
Cc: sudhir kumar, Autotest mailing list, Lucas Meneghel Rodrigues,
kvm-devel
Hi Sudhir and Yolkfull:
Thanks for your work on this test! Since Yolkfull's test matches
Sudhir's test functionality and extends it, I will go with it. Some
points:
* A failure on checking a given resource shouldn't prevent us from
testing other resources. Hence, instead of TestFail() exceptions,
let's replace it by an increase on a failure counter defined in the
beginning of the test.
* In order to make it more clear what the test does, let's change the
name to check_physical_resources
* At least for the user messages, it's preferrable to use "Assigned
to VM" and "Reported by OS" instead of "expected" and "actual".
I have implemented the suggestions and tested it, works quite well. A
patch was sent to the mailing list a couple of minutes ago, please let
me know what you guys think.
Cheers,
On Sun, Nov 29, 2009 at 8:40 AM, Yolkfull Chow <yzhou@redhat.com> wrote:
> On Sun, Nov 29, 2009 at 02:22:40PM +0530, sudhir kumar wrote:
>> On Sun, Nov 29, 2009 at 12:50 PM, Yolkfull Chow <yzhou@redhat.com> 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:
>> I agree. The only concern that made me doing it inside test is the
>> increasing size and complexity of the config file. I am fine with
>> passing the command from the config file but still the code paths have
>> to be different for each type of OS ie windows linux etc.
>>
>> >
>> > - @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
>> >> +
>> >> + output = session.get_command_output("cat /proc/meminfo")
>> >
>> > For catching memory size of Linux guests, I prefer command 'dmidecode' which can
>> > catch memory size exactly in MB.
>> I think we can use both here. To my knowledge dmidecode will test the
>> BIOS code of kvm and hence we can include both the methods?
>> >
>> >> + 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.
>> Is the command available for all windows OSes? If yes we can
>> definitely use the command.
>
> Yes it's available for all Windows OSes although with some limitations that it can
> only be executed within TELNET session or Windows command prompt. But it's fixed now.:)
>
> Cheers,
>
>> >
>> >
>> > 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.
>> Yeah, I just gave a first try for such a test. We need to test all the
>> emulated hardware.
>> >
>> > 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,
>> Sure. Please post them. I am happy to see them getting merged.
>>
>> Thanks a lot for your comments!!
>> Sudhir
>>
>> >
>> >> +
>> >> + 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()
>> >
>> >
>>
>>
>>
>> --
>> Sudhir Kumar
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>
--
Lucas
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Autotest] [PATCH 1/2] Adds a test to verify resources inside a VM
2009-12-01 13:56 ` [Autotest] " Lucas Meneghel Rodrigues
@ 2009-12-02 2:21 ` Yolkfull Chow
2009-12-02 3:29 ` sudhir kumar
0 siblings, 1 reply; 13+ messages in thread
From: Yolkfull Chow @ 2009-12-02 2:21 UTC (permalink / raw)
To: Lucas Meneghel Rodrigues
Cc: sudhir kumar, Autotest mailing list, Lucas Meneghel Rodrigues,
kvm-devel
On Tue, Dec 01, 2009 at 11:56:43AM -0200, Lucas Meneghel Rodrigues wrote:
> Hi Sudhir and Yolkfull:
>
> Thanks for your work on this test! Since Yolkfull's test matches
> Sudhir's test functionality and extends it, I will go with it. Some
> points:
>
> * A failure on checking a given resource shouldn't prevent us from
> testing other resources. Hence, instead of TestFail() exceptions,
> let's replace it by an increase on a failure counter defined in the
> beginning of the test.
> * In order to make it more clear what the test does, let's change the
> name to check_physical_resources
> * At least for the user messages, it's preferrable to use "Assigned
> to VM" and "Reported by OS" instead of "expected" and "actual".
>
> I have implemented the suggestions and tested it, works quite well. A
> patch was sent to the mailing list a couple of minutes ago, please let
> me know what you guys think.
Looks good for me. Thanks Lucas for improving this test.
Sudhir, what do you think about this? :)
Cheers,
Yolkfull
>
> Cheers,
>
> On Sun, Nov 29, 2009 at 8:40 AM, Yolkfull Chow <yzhou@redhat.com> wrote:
> > On Sun, Nov 29, 2009 at 02:22:40PM +0530, sudhir kumar wrote:
> >> On Sun, Nov 29, 2009 at 12:50 PM, Yolkfull Chow <yzhou@redhat.com> 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:
> >> I agree. The only concern that made me doing it inside test is the
> >> increasing size and complexity of the config file. I am fine with
> >> passing the command from the config file but still the code paths have
> >> to be different for each type of OS ie windows linux etc.
> >>
> >> >
> >> > - @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
> >> >> +
> >> >> + output = session.get_command_output("cat /proc/meminfo")
> >> >
> >> > For catching memory size of Linux guests, I prefer command 'dmidecode' which can
> >> > catch memory size exactly in MB.
> >> I think we can use both here. To my knowledge dmidecode will test the
> >> BIOS code of kvm and hence we can include both the methods?
> >> >
> >> >> + 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.
> >> Is the command available for all windows OSes? If yes we can
> >> definitely use the command.
> >
> > Yes it's available for all Windows OSes although with some limitations that it can
> > only be executed within TELNET session or Windows command prompt. But it's fixed now.:)
> >
> > Cheers,
> >
> >> >
> >> >
> >> > 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.
> >> Yeah, I just gave a first try for such a test. We need to test all the
> >> emulated hardware.
> >> >
> >> > 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,
> >> Sure. Please post them. I am happy to see them getting merged.
> >>
> >> Thanks a lot for your comments!!
> >> Sudhir
> >>
> >> >
> >> >> +
> >> >> + 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()
> >> >
> >> >
> >>
> >>
> >>
> >> --
> >> Sudhir Kumar
> > _______________________________________________
> > Autotest mailing list
> > Autotest@test.kernel.org
> > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
> >
>
>
>
> --
> Lucas
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Autotest] [PATCH 1/2] Adds a test to verify resources inside a VM
2009-12-02 2:21 ` Yolkfull Chow
@ 2009-12-02 3:29 ` sudhir kumar
2009-12-02 3:40 ` Lucas Meneghel Rodrigues
0 siblings, 1 reply; 13+ messages in thread
From: sudhir kumar @ 2009-12-02 3:29 UTC (permalink / raw)
To: Yolkfull Chow
Cc: Lucas Meneghel Rodrigues, Autotest mailing list,
Lucas Meneghel Rodrigues, kvm-devel
On Wed, Dec 2, 2009 at 7:51 AM, Yolkfull Chow <yzhou@redhat.com> wrote:
> On Tue, Dec 01, 2009 at 11:56:43AM -0200, Lucas Meneghel Rodrigues wrote:
>> Hi Sudhir and Yolkfull:
>>
>> Thanks for your work on this test! Since Yolkfull's test matches
>> Sudhir's test functionality and extends it, I will go with it. Some
>> points:
>>
>> * A failure on checking a given resource shouldn't prevent us from
>> testing other resources. Hence, instead of TestFail() exceptions,
>> let's replace it by an increase on a failure counter defined in the
>> beginning of the test.
>> * In order to make it more clear what the test does, let's change the
>> name to check_physical_resources
>> * At least for the user messages, it's preferrable to use "Assigned
>> to VM" and "Reported by OS" instead of "expected" and "actual".
>>
>> I have implemented the suggestions and tested it, works quite well. A
>> patch was sent to the mailing list a couple of minutes ago, please let
>> me know what you guys think.
>
> Looks good for me. Thanks Lucas for improving this test.
>
> Sudhir, what do you think about this? :)
Needs couple of hours before I go through the patch. I will post my
comments by today. Also would like to give a quick run for windows
guests which are more prone to break :) Thanks Lucas for the effort.
>
> Cheers,
> Yolkfull
>
>>
>> Cheers,
>>
>> On Sun, Nov 29, 2009 at 8:40 AM, Yolkfull Chow <yzhou@redhat.com> wrote:
>> > On Sun, Nov 29, 2009 at 02:22:40PM +0530, sudhir kumar wrote:
>> >> On Sun, Nov 29, 2009 at 12:50 PM, Yolkfull Chow <yzhou@redhat.com> 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:
>> >> I agree. The only concern that made me doing it inside test is the
>> >> increasing size and complexity of the config file. I am fine with
>> >> passing the command from the config file but still the code paths have
>> >> to be different for each type of OS ie windows linux etc.
>> >>
>> >> >
>> >> > - @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
>> >> >> +
>> >> >> + output = session.get_command_output("cat /proc/meminfo")
>> >> >
>> >> > For catching memory size of Linux guests, I prefer command 'dmidecode' which can
>> >> > catch memory size exactly in MB.
>> >> I think we can use both here. To my knowledge dmidecode will test the
>> >> BIOS code of kvm and hence we can include both the methods?
>> >> >
>> >> >> + 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.
>> >> Is the command available for all windows OSes? If yes we can
>> >> definitely use the command.
>> >
>> > Yes it's available for all Windows OSes although with some limitations that it can
>> > only be executed within TELNET session or Windows command prompt. But it's fixed now.:)
>> >
>> > Cheers,
>> >
>> >> >
>> >> >
>> >> > 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.
>> >> Yeah, I just gave a first try for such a test. We need to test all the
>> >> emulated hardware.
>> >> >
>> >> > 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,
>> >> Sure. Please post them. I am happy to see them getting merged.
>> >>
>> >> Thanks a lot for your comments!!
>> >> Sudhir
>> >>
>> >> >
>> >> >> +
>> >> >> + 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()
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Sudhir Kumar
>> > _______________________________________________
>> > Autotest mailing list
>> > Autotest@test.kernel.org
>> > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>> >
>>
>>
>>
>> --
>> Lucas
>
--
Sudhir Kumar
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Autotest] [PATCH 1/2] Adds a test to verify resources inside a VM
2009-12-02 3:29 ` sudhir kumar
@ 2009-12-02 3:40 ` Lucas Meneghel Rodrigues
2009-12-02 17:09 ` sudhir kumar
0 siblings, 1 reply; 13+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-12-02 3:40 UTC (permalink / raw)
To: sudhir kumar
Cc: Yolkfull Chow, Autotest mailing list, Lucas Meneghel Rodrigues,
kvm-devel
On Wed, 2009-12-02 at 08:59 +0530, sudhir kumar wrote:
> On Wed, Dec 2, 2009 at 7:51 AM, Yolkfull Chow <yzhou@redhat.com> wrote:
> >
> > Looks good for me. Thanks Lucas for improving this test.
> >
> > Sudhir, what do you think about this? :)
> Needs couple of hours before I go through the patch. I will post my
> comments by today. Also would like to give a quick run for windows
> guests which are more prone to break :) Thanks Lucas for the effort.
Thanks guys,
I've found some bugs on the version I sent to the mailing list, the bugs
were fixed and now the test looks like this - please review this
version!
import re, string, logging
from autotest_lib.client.common_lib import error
import kvm_test_utils, kvm_utils
def run_physical_resources_check(test, params, env):
"""
Check physical resources assigned to KVM virtual machines:
1) Log into the guest
2) Verify whether cpu counts ,memory size, nics' model,
count and drives' format & count, drive_serial, UUID
reported by the guest OS matches what has been assigned
to the VM (qemu command line)
3) Verify all MAC addresses for guest NICs
@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"))
session = kvm_test_utils.wait_for_login(vm)
logging.info("Starting physical resources check test")
logging.info("Values assigned to VM are the values we expect "
"to see reported by the Operating System")
# Define a failure counter, as we want to check all physical
# resources to know which checks passed and which ones failed
n_fail = 0
# Check cpu count
logging.info("CPU count check")
expected_cpu_nr = int(params.get("smp"))
actual_cpu_nr = vm.get_cpu_count()
if expected_cpu_nr != actual_cpu_nr:
n_fail += 1
logging.error("CPU count mismatch:")
logging.error(" Assigned to VM: %s" % expected_cpu_nr)
logging.error(" Reported by OS: %s" % actual_cpu_nr)
# Check memory size
logging.info("Memory size check")
expected_mem = int(params.get("mem"))
actual_mem = vm.get_memory_size()
if actual_mem != expected_mem:
n_fail += 1
logging.error("Memory size mismatch:")
logging.error(" Assigned to VM: %s" % expected_mem)
logging.error(" Reported by OS: %s" % actual_mem)
# Define a function for checking number of hard drivers & NICs
def check_num(devices, cmd, check_str):
f_fail = 0
expected_num = kvm_utils.get_sub_dict_names(params, devices).__len__()
s, o = vm.send_monitor_cmd(cmd)
if s != 0:
f_fail += 1
logging.error("qemu monitor command failed: %s" % cmd)
actual_num = string.count(o, check_str)
if expected_num != actual_num:
f_fail += 1
logging.error("%s number mismatch:")
logging.error(" Assigned to VM: %d" % expected_num)
logging.error(" Reported by OS: %d" % actual_num)
return expected_num, f_fail
logging.info("Hard drive count check")
drives_num, f_fail = check_num("images", "info block", "type=hd")
n_fail += f_fail
logging.info("NIC count check")
nics_num, f_fail = check_num("nics", "info network", "model=")
n_fail += f_fail
# Define a function for checking hard drives & NICs' model
def chk_fmt_model(device, fmt_model, cmd, str):
f_fail = 0
devices = kvm_utils.get_sub_dict_names(params, device)
for chk_device in devices:
expected = kvm_utils.get_sub_dict(params, chk_device).get(fmt_model)
if not expected:
expected = "rtl8139"
s, o = vm.send_monitor_cmd(cmd)
if s != 0:
f_fail += 1
logging.error("qemu monitor command failed: %s" % cmd)
device_found = re.findall(str, o)
logging.debug("Found devices: %s" % device_found)
found = False
for fm in device_found:
if expected in fm:
found = True
if not found:
f_fail += 1
logging.error("%s model mismatch:")
logging.error(" Assigned to VM: %s" % expected)
logging.error(" Reported by OS: %s" % device_found)
return f_fail
logging.info("NICs model check")
f_fail = chk_fmt_model("nics", "nic_model", "info network", "model=(.*),")
n_fail += f_fail
logging.info("Drive format check")
f_fail = chk_fmt_model("images", "drive_format", "info block",
"(.*)\: type=hd")
n_fail += f_fail
logging.info("Network card MAC check")
s, o = vm.send_monitor_cmd("info network")
if s != 0:
n_fail += 1
logging.error("qemu monitor command failed: info network")
found_mac_addresses = re.findall("macaddr=(.*)", o)
logging.debug("Found MAC adresses: %s" % found_mac_addresses)
for nic_name in kvm_utils.get_sub_dict_names(params, "nics"):
nic_params = kvm_utils.get_sub_dict(params, nic_name)
mac, ip = kvm_utils.get_mac_ip_pair_from_dict(nic_params)
if not string.lower(mac) in found_mac_addresses:
n_fail += 1
logging.error("MAC address mismatch:")
logging.error(" Assigned to VM (not found): %s" % mac)
# Define a function to verify UUID & Serial number
def verify_device(expect, name, verify_cmd):
f_fail = 0
if verify_cmd:
actual = session.get_command_output(verify_cmd)
if not string.upper(expect) in actual:
f_fail += 1
logging.error("%s mismatch:")
logging.error(" Assigned to VM: %s" % string.upper(expect))
logging.error(" Reported by OS: %s" % actual)
return f_fail
logging.info("UUID check")
if vm.get_uuid():
f_fail = verify_device(vm.get_uuid(), "UUID",
params.get("catch_uuid_cmd"))
n_fail += f_fail
logging.info("Hard Disk serial number check")
catch_serial_cmd = params.get("catch_serial_cmd")
f_fail = verify_device(params.get("drive_serial"), "Serial",
catch_serial_cmd)
n_fail += f_fail
if n_fail != 0:
raise error.TestFail("Physical resources check test reported %s "
"failures. Please verify the test logs." % n_fail)
session.close()
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Autotest] [PATCH 1/2] Adds a test to verify resources inside a VM
2009-12-02 3:40 ` Lucas Meneghel Rodrigues
@ 2009-12-02 17:09 ` sudhir kumar
0 siblings, 0 replies; 13+ messages in thread
From: sudhir kumar @ 2009-12-02 17:09 UTC (permalink / raw)
To: Lucas Meneghel Rodrigues
Cc: Yolkfull Chow, Autotest mailing list, Lucas Meneghel Rodrigues,
kvm-devel
On Wed, Dec 2, 2009 at 9:10 AM, Lucas Meneghel Rodrigues <lmr@redhat.com> wrote:
> On Wed, 2009-12-02 at 08:59 +0530, sudhir kumar wrote:
>> On Wed, Dec 2, 2009 at 7:51 AM, Yolkfull Chow <yzhou@redhat.com> wrote:
>> >
>> > Looks good for me. Thanks Lucas for improving this test.
>> >
>> > Sudhir, what do you think about this? :)
>> Needs couple of hours before I go through the patch. I will post my
>> comments by today. Also would like to give a quick run for windows
>> guests which are more prone to break :) Thanks Lucas for the effort.
>
> Thanks guys,
>
> I've found some bugs on the version I sent to the mailing list, the bugs
> were fixed and now the test looks like this - please review this
> version!
>
> import re, string, logging
> from autotest_lib.client.common_lib import error
> import kvm_test_utils, kvm_utils
>
>
> def run_physical_resources_check(test, params, env):
> """
> Check physical resources assigned to KVM virtual machines:
> 1) Log into the guest
> 2) Verify whether cpu counts ,memory size, nics' model,
> count and drives' format & count, drive_serial, UUID
> reported by the guest OS matches what has been assigned
> to the VM (qemu command line)
> 3) Verify all MAC addresses for guest NICs
>
> @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"))
> session = kvm_test_utils.wait_for_login(vm)
>
> logging.info("Starting physical resources check test")
> logging.info("Values assigned to VM are the values we expect "
> "to see reported by the Operating System")
> # Define a failure counter, as we want to check all physical
> # resources to know which checks passed and which ones failed
> n_fail = 0
>
> # Check cpu count
> logging.info("CPU count check")
> expected_cpu_nr = int(params.get("smp"))
> actual_cpu_nr = vm.get_cpu_count()
> if expected_cpu_nr != actual_cpu_nr:
> n_fail += 1
> logging.error("CPU count mismatch:")
> logging.error(" Assigned to VM: %s" % expected_cpu_nr)
> logging.error(" Reported by OS: %s" % actual_cpu_nr)
>
> # Check memory size
> logging.info("Memory size check")
> expected_mem = int(params.get("mem"))
> actual_mem = vm.get_memory_size()
> if actual_mem != expected_mem:
> n_fail += 1
> logging.error("Memory size mismatch:")
> logging.error(" Assigned to VM: %s" % expected_mem)
> logging.error(" Reported by OS: %s" % actual_mem)
>
> # Define a function for checking number of hard drivers & NICs
> def check_num(devices, cmd, check_str):
> f_fail = 0
> expected_num = kvm_utils.get_sub_dict_names(params, devices).__len__()
> s, o = vm.send_monitor_cmd(cmd)
> if s != 0:
> f_fail += 1
> logging.error("qemu monitor command failed: %s" % cmd)
>
> actual_num = string.count(o, check_str)
> if expected_num != actual_num:
> f_fail += 1
> logging.error("%s number mismatch:")
> logging.error(" Assigned to VM: %d" % expected_num)
> logging.error(" Reported by OS: %d" % actual_num)
> return expected_num, f_fail
>
> logging.info("Hard drive count check")
> drives_num, f_fail = check_num("images", "info block", "type=hd")
> n_fail += f_fail
>
> logging.info("NIC count check")
> nics_num, f_fail = check_num("nics", "info network", "model=")
> n_fail += f_fail
>
> # Define a function for checking hard drives & NICs' model
> def chk_fmt_model(device, fmt_model, cmd, str):
> f_fail = 0
> devices = kvm_utils.get_sub_dict_names(params, device)
> for chk_device in devices:
> expected = kvm_utils.get_sub_dict(params, chk_device).get(fmt_model)
> if not expected:
> expected = "rtl8139"
chk_fmt_model is a generic function. why are we initializing this
variable, expected to rtl8139 ?
> s, o = vm.send_monitor_cmd(cmd)
> if s != 0:
> f_fail += 1
> logging.error("qemu monitor command failed: %s" % cmd)
>
> device_found = re.findall(str, o)
> logging.debug("Found devices: %s" % device_found)
> found = False
> for fm in device_found:
> if expected in fm:
> found = True
>
> if not found:
> f_fail += 1
> logging.error("%s model mismatch:")
> logging.error(" Assigned to VM: %s" % expected)
> logging.error(" Reported by OS: %s" % device_found)
> return f_fail
>
> logging.info("NICs model check")
> f_fail = chk_fmt_model("nics", "nic_model", "info network", "model=(.*),")
> n_fail += f_fail
>
> logging.info("Drive format check")
> f_fail = chk_fmt_model("images", "drive_format", "info block",
> "(.*)\: type=hd")
> n_fail += f_fail
>
> logging.info("Network card MAC check")
> s, o = vm.send_monitor_cmd("info network")
> if s != 0:
> n_fail += 1
> logging.error("qemu monitor command failed: info network")
> found_mac_addresses = re.findall("macaddr=(.*)", o)
> logging.debug("Found MAC adresses: %s" % found_mac_addresses)
>
> for nic_name in kvm_utils.get_sub_dict_names(params, "nics"):
> nic_params = kvm_utils.get_sub_dict(params, nic_name)
> mac, ip = kvm_utils.get_mac_ip_pair_from_dict(nic_params)
> if not string.lower(mac) in found_mac_addresses:
> n_fail += 1
> logging.error("MAC address mismatch:")
> logging.error(" Assigned to VM (not found): %s" % mac)
>
> # Define a function to verify UUID & Serial number
> def verify_device(expect, name, verify_cmd):
> f_fail = 0
> if verify_cmd:
> actual = session.get_command_output(verify_cmd)
> if not string.upper(expect) in actual:
> f_fail += 1
> logging.error("%s mismatch:")
> logging.error(" Assigned to VM: %s" % string.upper(expect))
> logging.error(" Reported by OS: %s" % actual)
> return f_fail
>
> logging.info("UUID check")
> if vm.get_uuid():
> f_fail = verify_device(vm.get_uuid(), "UUID",
> params.get("catch_uuid_cmd"))
> n_fail += f_fail
>
> logging.info("Hard Disk serial number check")
> catch_serial_cmd = params.get("catch_serial_cmd")
> f_fail = verify_device(params.get("drive_serial"), "Serial",
> catch_serial_cmd)
> n_fail += f_fail
>
> if n_fail != 0:
> raise error.TestFail("Physical resources check test reported %s "
> "failures. Please verify the test logs." % n_fail)
>
> session.close()
A generic question: In the patch we are verifying some of the
resources(image, nic) through qemu monitor. Is it sufficient instead
of testing them inside OS(as we do for cpu and memory)? However a
particular device may not have been configured inside guest OS but
still it will be visible to the guest OS.
>
>
>
--
Sudhir Kumar
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] Adds a test to verify resources inside a VM
2009-11-29 9:04 ` Yaniv Kaul
@ 2009-12-04 9:20 ` Yolkfull Chow
0 siblings, 0 replies; 13+ messages in thread
From: Yolkfull Chow @ 2009-12-04 9:20 UTC (permalink / raw)
To: Yaniv Kaul
Cc: sudhir kumar, kvm-devel, Autotest mailing list,
Lucas Meneghel Rodrigues, Michael Goldish
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
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2009-12-04 9:20 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox