KVM test: Memory ballooning test for KVM guest
PATCH 1/1 KVM test: Memory ballooning test for KVM guest
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
Signed-off-by Pradeep Kumar Surisetty <[email protected]>
---
client/tests/kvm/tests/balloon_check.py +0 -63
@@ -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()
client/tests/kvm/tests_base.cfg.sample +18 -28
196 lines not on this page · raw message
---