* [Autotest] [PATCH] KVM test: Memory ballooning test for KVM guest
@ 2010-02-11 16:16 pradeep
0 siblings, 0 replies; 8+ messages in thread
From: pradeep @ 2010-02-11 16:16 UTC (permalink / raw)
To: autotest, kvm, lmr
[-- Attachment #1: Type: text/plain, Size: 257 bytes --]
Hi
This path tests Memory ballooning functionality of a KVM guest.
Create a guest. Boot the guest with "-balloon virtio"
Try to increase/decrease the memory from qemu monitor and verify the
changes.
Please find the attached patch.
Thanks
Pradeep
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 12231 bytes --]
Signed-off-by: Pradeep Kumar Surisetty <psuriset@linux.vnet.ibm.com>
---
diff -uprN a/client/tests/kvm/tests/balloon_check.py b/client/tests/kvm/tests/balloon_check.py
--- a/client/tests/kvm/tests/balloon_check.py 2010-02-11 20:31:49.197953539 +0530
+++ b/client/tests/kvm/tests/balloon_check.py 1970-01-01 05:30:00.000000000 +0530
@@ -1,63 +0,0 @@
-import re, string, logging
-from autotest_lib.client.common_lib import error
-import kvm_test_utils, kvm_utils
-
-def run_balloon_check(test, params, env):
- """
- Check Memory ballooning:
- 1) Boot a guest
- 2) Increase and decrease the memory of guest using balloon command from monitor
- 3) check memory info
-
- @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)
- fail = 0
-
- # Check memory size
- ogging.info("Memory size check")
- expected_mem = int(params.get("mem"))
- actual_mem = vm.get_memory_size()
- if actual_mem != expected_mem:
- logging.error("Memory size mismatch:")
- logging.error(" Assigned to VM: %s" % expected_mem)
- logging.error(" Reported by OS: %s" % actual_mem)
-
- #check info balloon command
- o, str = vm.send_monitor_cmd("info balloon")
- if o != 0:
- logging.error("qemu monitor command failed:")
- s =int(re.findall("\d+",str)[0])
- if s != actual_mem:
- logging.error("qemu monitor command failed: info balloon")
- raise error.TestFail("Memory ballooning failed while decreasing memory")
-
- #Reduce memory to 80% of actual memory
- new_mem = int (0.8 * actual_mem)
- vm.send_monitor_cmd(" balloon %s " % new_mem)
- o, str = vm.send_monitor_cmd("info balloon")
- if o != 0:
- logging.error("qemu monitor command failed:")
- s = int(re.findall("\d+",str)[0])
- if s != new_mem:
- logging.error(" memory ballooning failed ")
- fail = 1
-
- # increase memory to actual size
- vm.send_monitor_cmd(" balloon %s " % new_mem )
- o,str = vm.send_monitor_cmd("info balloon")
- if o != 0:
- logging.error("qemu monitor command failed:")
- s = int(re.findall("\d+",str)[0])
- if s != actual_mem:
- logging.error("Memory ballooning failed while increasing memory")
- fail = 1
-
- #Checking for test result
- if fail != 0:
- raise error.TestFail("Memory ballooning test failed ")
- session.close()
diff -uprN a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
--- a/client/tests/kvm/tests_base.cfg.sample 2010-02-11 21:12:13.792955256 +0530
+++ b/client/tests/kvm/tests_base.cfg.sample 2010-02-11 20:24:06.408947096 +0530
@@ -158,10 +158,6 @@ variants:
drift_threshold = 10
drift_threshold_single = 3
- - balloon_check: install setup unattended_install
- type = balloon_check
- extra_params += "-balloon virtio"
-
- stress_boot: install setup unattended_install
type = stress_boot
max_vms = 5
@@ -320,7 +316,7 @@ variants:
variants:
- 8.32:
- no setup balloon_check
+ no setup
image_name = fc8-32
cdrom = linux/Fedora-8-i386-DVD.iso
md5sum = dd6c79fddfff36d409d02242e7b10189
@@ -331,7 +327,7 @@ variants:
unattended_file = unattended/Fedora-8.ks
- 8.64:
- no setup balloon_check
+ no setup
image_name = fc8-64
cdrom = linux/Fedora-8-x86_64-DVD.iso
md5sum = 2cb231a86709dec413425fd2f8bf5295
@@ -342,7 +338,6 @@ variants:
unattended_file = unattended/Fedora-8.ks
- 9.32:
- no balloon_check
image_name = fc9-32
cdrom = linux/Fedora-9-i386-DVD.iso
md5sum = 72601f685ea8c808c303353d8bf4d307
@@ -353,7 +348,6 @@ variants:
unattended_file = unattended/Fedora-9.ks
- 9.64:
- no balloon_check
image_name = fc9-64
cdrom = linux/Fedora-9-x86_64-DVD.iso
md5sum = 05b2ebeed273ec54d6f9ed3d61ea4c96
@@ -364,7 +358,6 @@ variants:
unattended_file = unattended/Fedora-9.ks
- 10.32:
- no balloon_check
image_name = fc10-32
cdrom = linux/Fedora-10-i386-DVD.iso
md5sum = 27e581edb392728c4a07d00d3fc5ced0
@@ -373,7 +366,6 @@ variants:
unattended_file = unattended/Fedora-10.ks
- 10.64:
- no balloon_check
image_name = fc10-64
cdrom = linux/Fedora-10-x86_64-DVD.iso
sha1sum = f1e5ae7db6a1ba227de7294c4112385922388648
@@ -382,7 +374,6 @@ variants:
unattended_file = unattended/Fedora-10.ks
- 11.32:
- no balloon_check
image_name = fc11-32
cdrom = linux/Fedora-11-i386-DVD.iso
md5sum = e3b1e2d1ba42aa4705fa5f41771b3927
@@ -393,7 +384,6 @@ variants:
unattended_file = unattended/Fedora-11.ks
- 11.64:
- no balloon_check
image_name = fc11-64
cdrom = linux/Fedora-11-x86_64-DVD.iso
md5sum = 9d419844adeb93120215fe7505c9bce8
@@ -418,7 +408,7 @@ variants:
unattended_file = unattended/Fedora-12.ks
- DSL-4.2.5:
- no setup dbench bonnie linux_s3 balloon_check
+ no setup dbench bonnie linux_s3
image_name = dsl-4.2.5
install:
steps = DSL-4.2.5.steps
@@ -427,7 +417,7 @@ variants:
md5sum_1m = 527f2481bd25310f2e3a6e5345ff3d12
- Mandriva-One-2007:
- only install
+ only install
image_name = mandriva-one-2007
steps = Mandriva-One-2007-32.steps
cdrom = linux/mandriva-one-2007-i386.iso
@@ -435,7 +425,7 @@ variants:
md5sum_1m = dc7865a75db665efc86d59bca7c1fe07
- openSUSE-11.0.32:
- no setup dbench bonnie balloon_check
+ no setup dbench bonnie
image_name = openSUSE-11.0-32
install:
steps = openSUSE-11.0-32.steps
@@ -444,7 +434,7 @@ variants:
md5sum_1m = c720b30557af758e69de450409516369
- openSUSE-11.1.32:
- no setup dbench bonnie balloon_check
+ no setup dbench bonnie
image_name = openSUSE-11.1-32
install:
steps = openSUSE-11.1-32-and-64.steps
@@ -453,7 +443,7 @@ variants:
md5sum_1m = b70217417468389083429f81ba7ce2bd
- openSUSE-11.1.64:
- no setup dbench bonnie balloon_check
+ no setup dbench bonnie
image_name = openSUSE-11.1-64
install:
steps = openSUSE-11.1-32-and-64.steps
@@ -506,7 +496,7 @@ variants:
variants:
- 3.9.i386:
- no setup autotest linux_s3 balloon_check
+ no setup autotest linux_s3
image_name = rhel3-32
mem_chk_cmd = dmidecode | awk -F: '/Maximum Capacity/ {print $2}'
cdrom = linux/RHEL-3.9-i386-DVD.iso
@@ -518,7 +508,7 @@ variants:
unattended_file = unattended/RHEL-3-series.ks
- 3.9.x86_64:
- no setup autotest linux_s3 balloon_check
+ no setup autotest linux_s3
image_name = rhel3-64
mem_chk_cmd = dmidecode | awk -F: '/Maximum Capacity/ {print $2}'
cdrom = linux/RHEL-3.9-x86_64-DVD.iso
@@ -530,7 +520,7 @@ variants:
unattended_file = unattended/RHEL-3-series.ks
- 4.7.i386:
- no setup autotest balloon_check
+ no setup autotest
image_name = rhel4-32
cdrom=linux/RHEL-4.7-i386-DVD.iso
md5sum=ee5092653732a88ddbaf8eef2484c500
@@ -541,7 +531,7 @@ variants:
unattended_file = unattended/RHEL-4-series.ks
- 4.7.x86_64:
- no setup autotest balloon_check
+ no setup autotest
image_name = rhel4-64
cdrom=linux/RHEL-4.7-x86_64-DVD.iso
md5sum=ea9dae16dd86f7d94092d0e672333292
@@ -552,7 +542,7 @@ variants:
unattended_file = unattended/RHEL-4-series.ks
- 4.8.i386:
- no setup autotest balloon_check
+ no setup autotest
image_name = rhel4-32
cdrom = linux/RHEL-4.8-i386-DVD.iso
md5sum = b024f0af5079539d3ef51f71fed0b194
@@ -561,7 +551,7 @@ variants:
unattended_file = unattended/RHEL-4-series.ks
- 4.8.x86_64:
- no setup autotest balloon_check
+ no setup autotest
image_name = rhel4-64
cdrom = linux/RHEL-4.8-x86_64-DVD.iso
md5sum = 696bc877b0200cc942626673fcc3fc09
@@ -570,7 +560,7 @@ variants:
unattended_file = unattended/RHEL-4-series.ks
- 5.3.i386:
- no setup balloon_check
+ no setup
image_name = rhel5-32
cdrom=linux/RHEL-5.3-i386-DVD.iso
md5sum=371c62851611fd32ead440df6f24a296
@@ -581,7 +571,7 @@ variants:
unattended_file = unattended/RHEL-5-series.ks
- 5.3.x86_64:
- no setup balloon_check
+ no setup
image_name = rhel5-64
cdrom=linux/RHEL-5.3-x86_64-DVD.iso
md5sum=c5ed6b284410f4d8212cafc78fd7a8c5
@@ -592,7 +582,7 @@ variants:
unattended_file = unattended/RHEL-5-series.ks
- 5.4.i386:
- no setup balloon_check
+ no setup
image_name = rhel5-32
cdrom = linux/RHEL-5.4-i386-DVD.iso
md5sum = 7a12ec6599527e4f3d1790b51eadbfed
@@ -601,7 +591,7 @@ variants:
unattended_file = unattended/RHEL-5-series.ks
- 5.4.x86_64:
- no setup balloon_check
+ no setup
image_name = rhel5-64
cdrom = linux/RHEL-5.4-x86_64-DVD.iso
md5sum = 04fe3c10202402d7b389528d2bad0210
@@ -611,7 +601,7 @@ variants:
# Windows section
- @Windows:
- no autotest linux_s3 vlan_tag balloon_check
+ no autotest linux_s3 vlan_tag
shutdown_command = shutdown /s /t 0
reboot_command = shutdown /r /t 0
status_test_command = echo %errorlevel%
---
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Autotest] [PATCH] KVM test: Memory ballooning test for KVM guest
2010-02-11 18:37 ` Lucas Meneghel Rodrigues
@ 2010-04-09 9:10 ` pradeep
2010-04-09 11:13 ` sudhir kumar
0 siblings, 1 reply; 8+ messages in thread
From: pradeep @ 2010-04-09 9:10 UTC (permalink / raw)
To: Lucas Meneghel Rodrigues, autotest, kvm
[-- Attachment #1: Type: text/plain, Size: 102 bytes --]
Hi Lucas
Thanks for your comments.
Please find the patch, with suggested changes.
Thanks
Pradeep
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2738 bytes --]
Signed-off-by: Pradeep Kumar Surisetty <psuriset@linux.vnet.ibm.com>
---
diff -uprN autotest-old/client/tests/kvm/tests/balloon_check.py autotest/client/tests/kvm/tests/balloon_check.py
--- autotest-old/client/tests/kvm/tests/balloon_check.py 1969-12-31 19:00:00.000000000 -0500
+++ autotest/client/tests/kvm/tests/balloon_check.py 2010-04-09 12:33:34.000000000 -0400
@@ -0,0 +1,47 @@
+import re, string, logging, random, time
+from autotest_lib.client.common_lib import error
+import kvm_test_utils, kvm_utils
+
+def run_balloon_check(test, params, env):
+ """
+ Check Memory ballooning:
+ 1) Boot a guest
+ 2) Increase and decrease the memory of guest using balloon command from monitor
+ 3) check memory info
+
+ @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)
+ fail = 0
+
+ # 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:
+ logging.error("Memory size mismatch:")
+ logging.error("Assigned to VM: %s" % expected_mem)
+ logging.error("Reported by OS: %s" % actual_mem)
+
+ #change memory to random size between 60% to 95% of actual memory
+ percent = random.uniform(0.6, 0.95)
+ new_mem = int(percent*expected_mem)
+ vm.send_monitor_cmd("balloon %s" %new_mem)
+ time.sleep(20)
+ status, output = vm.send_monitor_cmd("info balloon")
+ if status != 0:
+ logging.error("qemu monitor command failed: info balloon")
+
+ balloon_cmd_mem = int(re.findall("\d+",output)[0])
+ if balloon_cmd_mem != new_mem:
+ logging.error("memory ballooning failed while changing memory to %s" %balloon_cmd_mem)
+ fail += 1
+
+ #Checking for test result
+ if fail != 0:
+ raise error.TestFail("Memory ballooning test failed ")
+ session.close()
diff -uprN autotest-old/client/tests/kvm/tests_base.cfg.sample autotest/client/tests/kvm/tests_base.cfg.sample
--- autotest-old/client/tests/kvm/tests_base.cfg.sample 2010-04-09 12:32:50.000000000 -0400
+++ autotest/client/tests/kvm/tests_base.cfg.sample 2010-04-09 12:53:27.000000000 -0400
@@ -185,6 +185,10 @@ variants:
drift_threshold = 10
drift_threshold_single = 3
+ - balloon_check: install setup unattended_install boot
+ type = balloon_check
+ extra_params += " -balloon virtio"
+
- stress_boot: install setup unattended_install
type = stress_boot
max_vms = 5
---
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Autotest] [PATCH] KVM test: Memory ballooning test for KVM guest
2010-04-12 11:03 ` pradeep
@ 2010-04-13 4:24 ` pradeep
2010-04-13 20:53 ` Lucas Meneghel Rodrigues
2010-04-15 0:12 ` Lucas Meneghel Rodrigues
1 sibling, 1 reply; 8+ messages in thread
From: pradeep @ 2010-04-13 4:24 UTC (permalink / raw)
To: Lucas Meneghel Rodrigues; +Cc: autotest, kvm
Lucas
Any comments??
--sp
pradeep wrote:
> sudhir kumar wrote:
>
>
>> On Fri, Apr 9, 2010 at 2:40 PM, pradeep <psuriset@linux.vnet.ibm.com> wrote:
>>
>>
>>> Hi Lucas
>>>
>>> Thanks for your comments.
>>> Please find the patch, with suggested changes.
>>>
>>> Thanks
>>> Pradeep
>>>
>>>
>>>
>>> Signed-off-by: Pradeep Kumar Surisetty <psuriset@linux.vnet.ibm.com>
>>> ---
>>> diff -uprN autotest-old/client/tests/kvm/tests/balloon_check.py
>>> autotest/client/tests/kvm/tests/balloon_check.py
>>> --- autotest-old/client/tests/kvm/tests/balloon_check.py 1969-12-31
>>> 19:00:00.000000000 -0500
>>> +++ autotest/client/tests/kvm/tests/balloon_check.py 2010-04-09
>>> 12:33:34.000000000 -0400
>>> @@ -0,0 +1,47 @@
>>> +import re, string, logging, random, time
>>> +from autotest_lib.client.common_lib import error
>>> +import kvm_test_utils, kvm_utils
>>> +
>>> +def run_balloon_check(test, params, env):
>>> + """
>>> + Check Memory ballooning:
>>> + 1) Boot a guest
>>> + 2) Increase and decrease the memory of guest using balloon command from
>>> monitor
>>>
>>>
>> Better replace this description by "Change the guest memory between X
>> and Y values"
>> Also instead of using 0.6 and 0.95 below, better use two variables and
>> take their value from config file. This will give the user a
>> flexibility to narrow or widen the ballooning range.
>>
>>
> Thanks for your suggestions. I dont think, user should need flexibility
> here.
> If ballooning doest work for one set of value, it will not work for any
> other.
> And here, we are choosing between 60 to 95% of actual values, which is
> reasonable.
>
>
>>
>>
>>> + 3) check memory info
>>> +
>>> + @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)
>>> + fail = 0
>>> +
>>> + # 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:
>>> + logging.error("Memory size mismatch:")
>>> + logging.error("Assigned to VM: %s" % expected_mem)
>>> + logging.error("Reported by OS: %s" % actual_mem)
>>> +
>>> + #change memory to random size between 60% to 95% of actual memory
>>> + percent = random.uniform(0.6, 0.95)
>>> + new_mem = int(percent*expected_mem)
>>> + vm.send_monitor_cmd("balloon %s" %new_mem)
>>>
>>>
>> You may want to check if the command passed/failed. Older versions
>> might not support ballooning.
>>
>>
>
> sure, i will make changes here.
>
>>
>>
>>> + time.sleep(20)
>>>
>>>
>> why 20 second sleep and why the magic number?
>>
>>
> As soon as balloon command is passed, it takes some time for memory
> ballooing.
> If we check "info balloon" as soon as we run ballooning, it will give
> weird values.
> I just choose it as, 20sec and its not huge time from testing perspective.
>
>>
>>
>>> + status, output = vm.send_monitor_cmd("info balloon")
>>>
>>>
>> You might want to put this check before changing the memory.
>>
>>
>>
> sure, will make changes here too.
>
>>> + if status != 0:
>>> + logging.error("qemu monitor command failed: info balloon")
>>> +
>>> + balloon_cmd_mem = int(re.findall("\d+",output)[0])
>>>
>>>
>> A better variable name I can think of is "ballooned_mem"
>>
>>
>
> will change it...
>
>>
>>
>>> + if balloon_cmd_mem != new_mem:
>>> + logging.error("memory ballooning failed while changing memory to
>>> %s" %balloon_cmd_mem)
>>> + fail += 1
>>> +
>>> + #Checking for test result
>>> + if fail != 0:
>>>
>>>
>> In case you are running multiple iterations and the 2nd iteration
>> fails you will always miss this condition.
>>
>>
>
>
>>
>>
>>> + raise error.TestFail("Memory ballooning test failed ")
>>> + session.close()
>>> diff -uprN autotest-old/client/tests/kvm/tests_base.cfg.sample
>>> autotest/client/tests/kvm/tests_base.cfg.sample
>>> --- autotest-old/client/tests/kvm/tests_base.cfg.sample 2010-04-09
>>> 12:32:50.000000000 -0400
>>> +++ autotest/client/tests/kvm/tests_base.cfg.sample 2010-04-09
>>> 12:53:27.000000000 -0400
>>> @@ -185,6 +185,10 @@ variants:
>>> drift_threshold = 10
>>> drift_threshold_single = 3
>>>
>>> + - balloon_check: install setup unattended_install boot
>>> + type = balloon_check
>>> + extra_params += " -balloon virtio"
>>> +
>>> - stress_boot: install setup unattended_install
>>> type = stress_boot
>>> max_vms = 5
>>> ---
>>>
>>>
>> Rest all looks good!!!!
>>
>>
>>> _______________________________________________
>>> Autotest mailing list
>>> Autotest@test.kernel.org
>>> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>>>
>>>
>>>
>>>
>>
>>
>>
>
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Autotest] [PATCH] KVM test: Memory ballooning test for KVM guest
2010-04-13 4:24 ` [Autotest] " pradeep
@ 2010-04-13 20:53 ` Lucas Meneghel Rodrigues
0 siblings, 0 replies; 8+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-04-13 20:53 UTC (permalink / raw)
To: pradeep; +Cc: autotest, kvm
On Tue, Apr 13, 2010 at 1:24 AM, pradeep <psuriset@linux.vnet.ibm.com> wrote:
>
> Lucas
>
> Any comments??
No pradeep, Sudhir's comments are very reasonable, please implement
the changes he suggested and re-send the patch, I am going to do some
testing on it on my local systems and then commit it upstream when
done with testing.
>
> --sp
>
> pradeep wrote:
>
>> sudhir kumar wrote:
>>
>>
>>> On Fri, Apr 9, 2010 at 2:40 PM, pradeep <psuriset@linux.vnet.ibm.com> wrote:
>>>
>>>
>>>> Hi Lucas
>>>>
>>>> Thanks for your comments.
>>>> Please find the patch, with suggested changes.
>>>>
>>>> Thanks
>>>> Pradeep
>>>>
>>>>
>>>>
>>>> Signed-off-by: Pradeep Kumar Surisetty <psuriset@linux.vnet.ibm.com>
>>>> ---
>>>> diff -uprN autotest-old/client/tests/kvm/tests/balloon_check.py
>>>> autotest/client/tests/kvm/tests/balloon_check.py
>>>> --- autotest-old/client/tests/kvm/tests/balloon_check.py 1969-12-31
>>>> 19:00:00.000000000 -0500
>>>> +++ autotest/client/tests/kvm/tests/balloon_check.py 2010-04-09
>>>> 12:33:34.000000000 -0400
>>>> @@ -0,0 +1,47 @@
>>>> +import re, string, logging, random, time
>>>> +from autotest_lib.client.common_lib import error
>>>> +import kvm_test_utils, kvm_utils
>>>> +
>>>> +def run_balloon_check(test, params, env):
>>>> + """
>>>> + Check Memory ballooning:
>>>> + 1) Boot a guest
>>>> + 2) Increase and decrease the memory of guest using balloon command from
>>>> monitor
>>>>
>>>>
>>> Better replace this description by "Change the guest memory between X
>>> and Y values"
>>> Also instead of using 0.6 and 0.95 below, better use two variables and
>>> take their value from config file. This will give the user a
>>> flexibility to narrow or widen the ballooning range.
>>>
>>>
>> Thanks for your suggestions. I dont think, user should need flexibility
>> here.
>> If ballooning doest work for one set of value, it will not work for any
>> other.
>> And here, we are choosing between 60 to 95% of actual values, which is
>> reasonable.
>>
>>
>>>
>>>
>>>> + 3) check memory info
>>>> +
>>>> + @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)
>>>> + fail = 0
>>>> +
>>>> + # 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:
>>>> + logging.error("Memory size mismatch:")
>>>> + logging.error("Assigned to VM: %s" % expected_mem)
>>>> + logging.error("Reported by OS: %s" % actual_mem)
>>>> +
>>>> + #change memory to random size between 60% to 95% of actual memory
>>>> + percent = random.uniform(0.6, 0.95)
>>>> + new_mem = int(percent*expected_mem)
>>>> + vm.send_monitor_cmd("balloon %s" %new_mem)
>>>>
>>>>
>>> You may want to check if the command passed/failed. Older versions
>>> might not support ballooning.
>>>
>>>
>>
>> sure, i will make changes here.
>>
>>>
>>>
>>>> + time.sleep(20)
>>>>
>>>>
>>> why 20 second sleep and why the magic number?
>>>
>>>
>> As soon as balloon command is passed, it takes some time for memory
>> ballooing.
>> If we check "info balloon" as soon as we run ballooning, it will give
>> weird values.
>> I just choose it as, 20sec and its not huge time from testing perspective.
>>
>>>
>>>
>>>> + status, output = vm.send_monitor_cmd("info balloon")
>>>>
>>>>
>>> You might want to put this check before changing the memory.
>>>
>>>
>>>
>> sure, will make changes here too.
>>
>>>> + if status != 0:
>>>> + logging.error("qemu monitor command failed: info balloon")
>>>> +
>>>> + balloon_cmd_mem = int(re.findall("\d+",output)[0])
>>>>
>>>>
>>> A better variable name I can think of is "ballooned_mem"
>>>
>>>
>>
>> will change it...
>>
>>>
>>>
>>>> + if balloon_cmd_mem != new_mem:
>>>> + logging.error("memory ballooning failed while changing memory to
>>>> %s" %balloon_cmd_mem)
>>>> + fail += 1
>>>> +
>>>> + #Checking for test result
>>>> + if fail != 0:
>>>>
>>>>
>>> In case you are running multiple iterations and the 2nd iteration
>>> fails you will always miss this condition.
>>>
>>>
>>
>>
>>>
>>>
>>>> + raise error.TestFail("Memory ballooning test failed ")
>>>> + session.close()
>>>> diff -uprN autotest-old/client/tests/kvm/tests_base.cfg.sample
>>>> autotest/client/tests/kvm/tests_base.cfg.sample
>>>> --- autotest-old/client/tests/kvm/tests_base.cfg.sample 2010-04-09
>>>> 12:32:50.000000000 -0400
>>>> +++ autotest/client/tests/kvm/tests_base.cfg.sample 2010-04-09
>>>> 12:53:27.000000000 -0400
>>>> @@ -185,6 +185,10 @@ variants:
>>>> drift_threshold = 10
>>>> drift_threshold_single = 3
>>>>
>>>> + - balloon_check: install setup unattended_install boot
>>>> + type = balloon_check
>>>> + extra_params += " -balloon virtio"
>>>> +
>>>> - stress_boot: install setup unattended_install
>>>> type = stress_boot
>>>> max_vms = 5
>>>> ---
>>>>
>>>>
>>> Rest all looks good!!!!
>>>
>>>
>>>> _______________________________________________
>>>> Autotest mailing list
>>>> Autotest@test.kernel.org
>>>> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>> _______________________________________________
>> Autotest mailing list
>> Autotest@test.kernel.org
>> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>>
>
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>
--
Lucas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Autotest] [PATCH] KVM test: Memory ballooning test for KVM guest
2010-04-12 11:03 ` pradeep
2010-04-13 4:24 ` [Autotest] " pradeep
@ 2010-04-15 0:12 ` Lucas Meneghel Rodrigues
2010-04-15 15:10 ` pradeep
1 sibling, 1 reply; 8+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-04-15 0:12 UTC (permalink / raw)
To: pradeep; +Cc: sudhir kumar, autotest, kvm
On Mon, Apr 12, 2010 at 8:03 AM, pradeep <psuriset@linux.vnet.ibm.com> wrote:
> sudhir kumar wrote:
>
>> On Fri, Apr 9, 2010 at 2:40 PM, pradeep <psuriset@linux.vnet.ibm.com> wrote:
>>
>>> Hi Lucas
>>>
>>> Thanks for your comments.
>>> Please find the patch, with suggested changes.
>>>
>>> Thanks
>>> Pradeep
>>>
>>>
>>>
>>> Signed-off-by: Pradeep Kumar Surisetty <psuriset@linux.vnet.ibm.com>
>>> ---
>>> diff -uprN autotest-old/client/tests/kvm/tests/balloon_check.py
>>> autotest/client/tests/kvm/tests/balloon_check.py
>>> --- autotest-old/client/tests/kvm/tests/balloon_check.py 1969-12-31
>>> 19:00:00.000000000 -0500
>>> +++ autotest/client/tests/kvm/tests/balloon_check.py 2010-04-09
>>> 12:33:34.000000000 -0400
>>> @@ -0,0 +1,47 @@
>>> +import re, string, logging, random, time
>>> +from autotest_lib.client.common_lib import error
>>> +import kvm_test_utils, kvm_utils
>>> +
>>> +def run_balloon_check(test, params, env):
>>> + """
>>> + Check Memory ballooning:
>>> + 1) Boot a guest
>>> + 2) Increase and decrease the memory of guest using balloon command from
>>> monitor
>>>
>> Better replace this description by "Change the guest memory between X
>> and Y values"
>> Also instead of using 0.6 and 0.95 below, better use two variables and
>> take their value from config file. This will give the user a
>> flexibility to narrow or widen the ballooning range.
>>
> Thanks for your suggestions. I dont think, user should need flexibility
> here.
> If ballooning doest work for one set of value, it will not work for any
> other.
> And here, we are choosing between 60 to 95% of actual values, which is
> reasonable.
Sorry for not having commented on this before. Yes, a reasonable,
hardcoded range is completely OK to me. Did you tested and verified
that this range is safe for guest testing? I mean, a memory set too
low might trigger OOM killer on VMs, so I was wondering if 60% isn't
too low...
--
Lucas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Autotest] [PATCH] KVM test: Memory ballooning test for KVM guest
2010-04-15 0:12 ` Lucas Meneghel Rodrigues
@ 2010-04-15 15:10 ` pradeep
2010-04-15 20:19 ` Lucas Meneghel Rodrigues
0 siblings, 1 reply; 8+ messages in thread
From: pradeep @ 2010-04-15 15:10 UTC (permalink / raw)
To: Lucas Meneghel Rodrigues; +Cc: autotest, kvm
[-- Attachment #1: Type: text/plain, Size: 101 bytes --]
Hi Lucas
Please ignore my earlier patch
Find the correct patch with the suggested changes.
--SP
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2804 bytes --]
diff -purN autotest/client/tests/kvm/tests/balloon_check.py autotest-new/client/tests/kvm/tests/balloon_check.py
--- autotest/client/tests/kvm/tests/balloon_check.py 1969-12-31 19:00:00.000000000 -0500
+++ autotest-new/client/tests/kvm/tests/balloon_check.py 2010-04-15 18:50:09.000000000 -0400
@@ -0,0 +1,51 @@
+import re, string, logging, random, time
+from autotest_lib.client.common_lib import error
+import kvm_test_utils, kvm_utils
+
+def run_balloon_check(test, params, env):
+ """
+ Check Memory ballooning:
+ 1) Boot a guest
+ 2) Change the memory between 60% to 95% of memory of guest using ballooning
+ 3) check memory info
+
+ @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)
+ fail = 0
+
+ # 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:
+ logging.error("Memory size mismatch:")
+ logging.error(" Assigned to VM: %s" % expected_mem)
+ logging.error(" Reported by OS: %s" % actual_mem)
+
+
+ #Check if info balloon works or not.
+ status, output = vm.send_monitor_cmd("info balloon")
+ if status != 0:
+ logging.error("qemu monitor command failed: info balloon")
+ fail += 1
+
+ #Reduce memory to random size between 60% to 95% of actual memory
+ percent = random.uniform(0.6, 0.95)
+ new_mem = int(percent*actual_mem)
+ vm.send_monitor_cmd("balloon %s" % new_mem)
+ time.sleep(20)
+ status, output = vm.send_monitor_cmd("info balloon")
+ ballooned_mem = int(re.findall("\d+",output)[0])
+ if ballooned_mem != new_mem:
+ logging.error("memory ballooning failed while changing memory from %s to %s" %actual_mem %new_mem)
+ fail += 1
+
+ #Checking for test result
+ if fail != 0:
+ raise error.TestFail("Memory ballooning test failed ")
+ session.close()
diff -purN autotest/client/tests/kvm/tests_base.cfg.sample autotest-new/client/tests/kvm/tests_base.cfg.sample
--- autotest/client/tests/kvm/tests_base.cfg.sample 2010-04-15 09:14:10.000000000 -0400
+++ autotest-new/client/tests/kvm/tests_base.cfg.sample 2010-04-15 18:50:35.000000000 -0400
@@ -171,6 +171,10 @@ variants:
drift_threshold = 10
drift_threshold_single = 3
+ - balloon_check: install setup unattended_install
+ type = balloon_check
+ extra_params += "-balloon virtio"
+
- stress_boot: install setup unattended_install
type = stress_boot
max_vms = 5
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Autotest] [PATCH] KVM test: Memory ballooning test for KVM guest
2010-04-15 15:10 ` pradeep
@ 2010-04-15 20:19 ` Lucas Meneghel Rodrigues
2010-04-16 5:01 ` pradeep
0 siblings, 1 reply; 8+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-04-15 20:19 UTC (permalink / raw)
To: pradeep; +Cc: autotest, kvm
On Thu, 2010-04-15 at 20:40 +0530, pradeep wrote:
> Hi Lucas
>
> Please ignore my earlier patch
> Find the correct patch with the suggested changes.
Hi Pradeep, I was reading the test once again while trying it myself,
some other ideas came to me. I spent some time hacking the test and sent
an updated patch with changes. Please let me know what you think, if you
are OK with them I'll commit it.
>
> --SP
>
>
> plain text document attachment (patch)
> diff -purN autotest/client/tests/kvm/tests/balloon_check.py autotest-new/client/tests/kvm/tests/balloon_check.py
> --- autotest/client/tests/kvm/tests/balloon_check.py 1969-12-31 19:00:00.000000000 -0500
> +++ autotest-new/client/tests/kvm/tests/balloon_check.py 2010-04-15 18:50:09.000000000 -0400
> @@ -0,0 +1,51 @@
> +import re, string, logging, random, time
> +from autotest_lib.client.common_lib import error
> +import kvm_test_utils, kvm_utils
> +
> +def run_balloon_check(test, params, env):
> + """
> + Check Memory ballooning:
> + 1) Boot a guest
> + 2) Change the memory between 60% to 95% of memory of guest using ballooning
> + 3) check memory info
> +
> + @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)
> + fail = 0
> +
> + # 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:
> + logging.error("Memory size mismatch:")
> + logging.error(" Assigned to VM: %s" % expected_mem)
> + logging.error(" Reported by OS: %s" % actual_mem)
> +
> +
> + #Check if info balloon works or not.
> + status, output = vm.send_monitor_cmd("info balloon")
> + if status != 0:
> + logging.error("qemu monitor command failed: info balloon")
> + fail += 1
> +
> + #Reduce memory to random size between 60% to 95% of actual memory
> + percent = random.uniform(0.6, 0.95)
> + new_mem = int(percent*actual_mem)
> + vm.send_monitor_cmd("balloon %s" % new_mem)
> + time.sleep(20)
> + status, output = vm.send_monitor_cmd("info balloon")
> + ballooned_mem = int(re.findall("\d+",output)[0])
> + if ballooned_mem != new_mem:
> + logging.error("memory ballooning failed while changing memory from %s to %s" %actual_mem %new_mem)
> + fail += 1
> +
> + #Checking for test result
> + if fail != 0:
> + raise error.TestFail("Memory ballooning test failed ")
> + session.close()
> diff -purN autotest/client/tests/kvm/tests_base.cfg.sample autotest-new/client/tests/kvm/tests_base.cfg.sample
> --- autotest/client/tests/kvm/tests_base.cfg.sample 2010-04-15 09:14:10.000000000 -0400
> +++ autotest-new/client/tests/kvm/tests_base.cfg.sample 2010-04-15 18:50:35.000000000 -0400
> @@ -171,6 +171,10 @@ variants:
> drift_threshold = 10
> drift_threshold_single = 3
>
> + - balloon_check: install setup unattended_install
> + type = balloon_check
> + extra_params += "-balloon virtio"
> +
> - stress_boot: install setup unattended_install
> type = stress_boot
> max_vms = 5
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Autotest] [PATCH] KVM test: Memory ballooning test for KVM guest
2010-04-15 20:19 ` Lucas Meneghel Rodrigues
@ 2010-04-16 5:01 ` pradeep
0 siblings, 0 replies; 8+ messages in thread
From: pradeep @ 2010-04-16 5:01 UTC (permalink / raw)
To: Lucas Meneghel Rodrigues; +Cc: autotest, kvm
Lucas Meneghel Rodrigues wrote:
>
>
> Hi Pradeep, I was reading the test once again while trying it myself,
> some other ideas came to me. I spent some time hacking the test and sent
> an updated patch with changes. Please let me know what you think, if you
> are OK with them I'll commit it.
>
>
Hi Lucas
Patch looks fine to me. Thanks for your code changes.
--SP
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-04-16 5:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-11 16:16 [Autotest] [PATCH] KVM test: Memory ballooning test for KVM guest pradeep
-- strict thread matches above, loose matches on Subject: below --
2010-02-11 17:29 pradeep
2010-02-11 18:37 ` Lucas Meneghel Rodrigues
2010-04-09 9:10 ` [Autotest] " pradeep
2010-04-09 11:13 ` sudhir kumar
2010-04-12 11:03 ` pradeep
2010-04-13 4:24 ` [Autotest] " pradeep
2010-04-13 20:53 ` Lucas Meneghel Rodrigues
2010-04-15 0:12 ` Lucas Meneghel Rodrigues
2010-04-15 15:10 ` pradeep
2010-04-15 20:19 ` Lucas Meneghel Rodrigues
2010-04-16 5:01 ` pradeep
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox