[PATCH 0 of 3] Add CPU scheduling test.

This test corresponds to the recent CPU scheduling enhancement.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1212719877 25200 # Node ID 59fce67164a22315bb712f692dfd93314c4f30e0 # Parent 727d97c09d77d73f3542ba49a9dd19ba119a67eb Remove bootloader from vsms.py in the Xen case. This looks like an old bug that was masked by some tests that are XFAILing. Since the cimtest guest uses a ramdisk, we should not set a bootloader for paravirtualized guests. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 727d97c09d77 -r 59fce67164a2 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Tue Jun 10 18:26:20 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Thu Jun 05 19:37:57 2008 -0700 @@ -105,8 +105,6 @@ elif type == 'LXC': self.InitPath = const.LXC_init_path else: - self.Bootloader = live.bootloader(Globals.CIM_IP, 0) - self.BootloaderArgs = '' self.Kernel = const.Xen_kernel_path self.Ramdisk = const.Xen_init_path

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1214156795 25200 # Node ID 6cb3a4b4b0b21497dbfc812c49e555699d580d21 # Parent 59fce67164a22315bb712f692dfd93314c4f30e0 [TEST] Add generic poll function to poll for guest state. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 59fce67164a2 -r 6cb3a4b4b0b2 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Thu Jun 05 19:37:57 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Sun Jun 22 10:46:35 2008 -0700 @@ -23,6 +23,7 @@ import os import pywbem import random +from time import sleep from distutils.file_util import move_file from XenKvmLib.test_xml import * from XenKvmLib.test_doms import * @@ -135,6 +136,33 @@ return 1 return 0 + +def poll_for_state_change(server, virt, dom, exp_state): + timeout = 30 + cs = computersystem.get_cs_class(virt) + + try: + for i in range(1, (timeout + 1)): + sleep(1) + dom_cs = cs(server, name=dom) + if dom_cs is None: + logger.error("CS instance not returned for %s." % dom) + return FAIL + + if dom_cs.EnabledState == exp_state: + break + + except Exception, detail: + logger.error("Exception: %s" % detail) + return FAIL + + if dom_cs.EnabledState != exp_state: + logger.error("EnabledState is %i instead of %i." % (dom_cs.EnabledState, + exp_state)) + logger.error("Try to increase the timeout and run the test again") + return FAIL + + return PASS def get_host_info(server, virt="Xen"): status = PASS

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1214156795 25200 # Node ID 6cb3a4b4b0b21497dbfc812c49e555699d580d21 # Parent 59fce67164a22315bb712f692dfd93314c4f30e0 [TEST] Add generic poll function to poll for guest state.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 59fce67164a2 -r 6cb3a4b4b0b2 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Thu Jun 05 19:37:57 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Sun Jun 22 10:46:35 2008 -0700 @@ -23,6 +23,7 @@ import os import pywbem import random +from time import sleep from distutils.file_util import move_file from XenKvmLib.test_xml import * from XenKvmLib.test_doms import * @@ -135,6 +136,33 @@ return 1
return 0 + +def poll_for_state_change(server, virt, dom, exp_state): + timeout = 30
It will be good if we pass timeout value as well.
+ cs = computersystem.get_cs_class(virt) + + try: + for i in range(1, (timeout + 1)): + sleep(1) + dom_cs = cs(server, name=dom) + if dom_cs is None:
We can make this better by checking dom_cs.Name, thoughts ? otherwise +1 for me.
+ logger.error("CS instance not returned for %s." % dom) + return FAIL + + if dom_cs.EnabledState == exp_state: + break + + except Exception, detail: + logger.error("Exception: %s" % detail) + return FAIL + + if dom_cs.EnabledState != exp_state: + logger.error("EnabledState is %i instead of %i." % (dom_cs.EnabledState, + exp_state)) + logger.error("Try to increase the timeout and run the test again") + return FAIL + + return PASS
def get_host_info(server, virt="Xen"): status = PASS
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

return 1
return 0 + +def poll_for_state_change(server, virt, dom, exp_state): + timeout = 30
It will be good if we pass timeout value as well.
+ cs = computersystem.get_cs_class(virt) + + try: + for i in range(1, (timeout + 1)): + sleep(1) + dom_cs = cs(server, name=dom) + if dom_cs is None:
We can make this better by checking dom_cs.Name, thoughts ? otherwise +1 for me.
That's a really good point. It's possible to get back the wrong CS instance. Good catch =) I'll add both of these changes and resend. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1213896959 25200 # Node ID 5c90c9a2fd567d7cf592932db189afbc8a4756f8 # Parent 6cb3a4b4b0b21497dbfc812c49e555699d580d21 [TEST] Define and create guest with CPU scheduling values set. Verify these values after the guest starts. KVM doesn't support CPU scheduling. For KVM guests, this test just verfies that the guest can be created and defined when CPU scheduling values are defined in the ProcRASD that's passed in to the DefineSystem() call. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 6cb3a4b4b0b2 -r 5c90c9a2fd56 suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py Thu Jun 19 10:35:59 2008 -0700 @@ -0,0 +1,137 @@ +#!/usr/bin/python +# +# Copyright 2008 IBM Corp. +# +# Authors: +# Kaitlin Rupert <karupert@us.ibm.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import sys +import pywbem +from XenKvmLib.common_util import call_request_state_change, \ + poll_for_state_change +from XenKvmLib import vsms +from VirtLib import utils +from CimTest.Globals import logger +from CimTest.Globals import do_main +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.test_doms import destroy_and_undefine_domain + +sup_types = ['Xen', 'XenFV', 'KVM'] +default_dom = 'rstest_domain' + +nvcpu = 2 +weight = 124 +limit = 256 + +REQUESTED_STATE = 2 +TIME = "00000000000000.000000:000" + +def setup_rasd_mof(ip, vtype): + vssd, rasd = vsms.default_vssd_rasd_str(default_dom, virt=vtype) + + class_pasd = vsms.get_pasd_class(vtype) + proc_inst = class_pasd(nvcpu, default_dom, weight, limit) + proc_mof = proc_inst.mof() + + for i in range(len(rasd)): + if "ProcResourceAllocationSettingData" in rasd[i]: + rasd[i] = proc_mof + return PASS, vssd, rasd + + return FAIL, vssd, rasd + +def check_sched_info(str, exp_val, server, virt): + if str == "limit": + virsh_val = "cap" + else: + virsh_val = str + + cmd = "virsh -c %s schedinfo %s | awk '/%s/ { print \$3 }'" % \ + (utils.virt2uri(virt), default_dom, virsh_val) + ret, out = utils.run_remote(server, cmd) + if not out.isdigit(): + return FAIL + + try: + val = int(out) + except ValueError: + val = -1 + + if val != exp_val: + logger.error("%s is %i, expected %i" % (str, val, exp_val)) + return FAIL + + return PASS + +def check_proc_pinning(server, virt): + attr_list = { "weight" : weight, + "limit" : limit + } + + for k, v in attr_list.iteritems(): + status = check_sched_info(k, v, server, virt) + if status != PASS: + return FAIL + + return PASS + +@do_main(sup_types) +def main(): + options = main.options + + status, vssd, rasd = setup_rasd_mof(options.ip, options.virt) + if status != PASS: + return status + + try: + service = vsms.get_vsms_class(options.virt)(options.ip) + + service.DefineSystem(SystemSettings=vssd, + ResourceSettings=rasd, + ReferenceConfiguration=' ') + + rc = call_request_state_change(default_dom, options.ip, + REQUESTED_STATE, TIME, options.virt) + if rc != 0: + raise Exception("Unable to start %s using RequestedStateChange()" % + default_dom) + + status = poll_for_state_change(options.ip, options.virt, default_dom, + REQUESTED_STATE) + if status != PASS: + raise Exception("%s didn't change state as expected" % default_dom) + + if options.virt == "Xen" or options.virt == "XenFV": + status = check_proc_pinning(options.ip, options.virt) + if status != PASS: + raise Exception("%s CPU scheduling not set properly" % + default_dom) + + status = PASS + + except Exception, details: + logger.error(details) + status = FAIL + + destroy_and_undefine_domain(default_dom, options.ip, options.virt) + + return status + +if __name__ == "__main__": + sys.exit(main()) + diff -r 6cb3a4b4b0b2 -r 5c90c9a2fd56 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Sun Jun 22 10:46:35 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Thu Jun 19 10:35:59 2008 -0700 @@ -174,7 +174,7 @@ pass class CIM_ProcResourceAllocationSettingData(CIMClassMOF): - def __init__(self, vcpu, name): + def __init__(self, vcpu, name, weight=None, limit=None): self.ResourceType = RASD_TYPE_PROC if vcpu != None: @@ -182,6 +182,12 @@ if name != None: self.InstanceID = '%s/proc' % name + + if weight != None: + self.Weight = weight + + if limit != None: + self.Limit = limit class Xen_ProcResourceAllocationSettingData(CIM_ProcResourceAllocationSettingData): pass

KR> +def check_proc_pinning(server, virt): KR> + attr_list = { "weight" : weight, KR> + "limit" : limit KR> + } KR> + KR> + for k, v in attr_list.iteritems(): KR> + status = check_sched_info(k, v, server, virt) KR> + if status != PASS: KR> + return FAIL KR> + KR> + return PASS This method could probably use a better name, since we're not doing any pinning. Otherwise it looks good to me. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> +def check_proc_pinning(server, virt): KR> + attr_list = { "weight" : weight, KR> + "limit" : limit KR> + } KR> + KR> + for k, v in attr_list.iteritems(): KR> + status = check_sched_info(k, v, server, virt) KR> + if status != PASS: KR> + return FAIL KR> + KR> + return PASS
This method could probably use a better name, since we're not doing
Yes, for some reason - I want to say pinning when I mean scheduling. And sorry for the slow reply - I didn't see this message until just now. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Dan Smith
-
Deepti B Kalakeri
-
Kaitlin Rupert