diff -Naurp xen-3.0.0/tools/python/xen/lowlevel/xc/xc.c xen-3.0.0-sched-param/tools/python/xen/lowlevel/xc/xc.c --- xen-3.0.0/tools/python/xen/lowlevel/xc/xc.c 2005-12-05 04:06:31.000000000 +0530 +++ xen-3.0.0-sched-param/tools/python/xen/lowlevel/xc/xc.c 2006-03-08 10:18:20.000000000 +0530 @@ -622,7 +622,69 @@ static PyObject *pyxc_physinfo(XcObject "cpu_khz", info.cpu_khz, "hw_caps", cpu_cap); } +/*Code for getting Scheduler ID */ +static PyObject *pyxc_sched_id(XcObject *self) +{ + int sched_id; + + if ( xc_sched_id(self->xc_handle, &sched_id) !=0 ) + return PyErr_SetFromErrno(xc_error); + + return Py_BuildValue("i", sched_id); +} +/*Code for getting Scheduler params */ +static PyObject *pyxc_sched_param(XcObject *self, PyObject *args) +{ + int sched_id; + uint32_t dom; + /*BVT Scheduler Parameters*/ + uint32_t mcuadv; + int warpback; + int32_t warpvalue; + long long warpl; + long long warpu; + /*SEDF Scheduler Parameters*/ + uint64_t period, slice, latency; + uint16_t weight, extratime; + if (!PyArg_ParseTuple(args, "l", &dom)) + return NULL; + + if (xc_sched_id(self->xc_handle,(int *) &sched_id) !=0) + return PyErr_SetFromErrno(xc_error); + + if (sched_id == 0) { + /*Scheduler is bvt; get the Domain parameters*/ + if (xc_bvtsched_domain_get(self->xc_handle, dom, &mcuadv, &warpback, + &warpvalue, &warpl, &warpu) != 0) + + return PyErr_SetFromErrno(xc_error); + + return Py_BuildValue("lliiLL", + dom, + mcuadv, + warpback, + warpvalue, + warpl, + warpu); + } + else if (sched_id == 4) { + /*Scheduler is sedf; get the Domain parameters*/ + if (xc_sedf_domain_get(self->xc_handle, dom, &period, + &slice,&latency,&extratime,&weight)) + return PyErr_SetFromErrno(xc_error); + + return Py_BuildValue("lLLLhh", + dom, + slice, + period, + latency, + extratime, + weight); + } + else + return Py_BuildValue("si","Unknown Scheduler Parameters for ",sched_id); +} static PyObject *pyxc_xeninfo(XcObject *self) { xen_extraversion_t xen_extra; @@ -1037,6 +1099,21 @@ static PyMethodDef pyxc_methods[] = { "Returns [dict]: information about the hardware" " [None]: on failure.\n" }, + { "sched_id", + (PyCFunction)pyxc_sched_id, + METH_NOARGS, "\n" + "Get information about the Scheduler being used\n" + "Returns [int] Scheduler ID 0-bvt,4-sedf" + " [none] on failure.\n" }, + + { "sched_param", + (PyCFunction)pyxc_sched_param, + METH_VARARGS, "\n" + "Get scheduling parameters for the scheduler being used\n" + "dom [int] Identifier of a domain" + "Returns [dict]: Scheduler parameters" + " [None]: on failure.\n" }, + { "xeninfo", (PyCFunction)pyxc_xeninfo, METH_NOARGS, "\n" diff -Naurp xen-3.0.0/tools/python/xen/xend/XendClient.py xen-3.0.0-sched-param/tools/python/xen/xend/XendClient.py --- xen-3.0.0/tools/python/xen/xend/XendClient.py 2005-12-05 04:06:31.000000000 +0530 +++ xen-3.0.0-sched-param/tools/python/xen/xend/XendClient.py 2006-03-09 12:58:36.000000000 +0530 @@ -291,6 +291,31 @@ class Xend: 'extratime' : extratime, 'weight' : weight }) + ##Scheduler information interface + def xend_sched_id(self): + import xen.lowlevel.xc + xc = xen.lowlevel.xc.xc() + sched_id = xc.sched_id() + return sched_id + + def xend_sched_param(self, id): + + sched_param = {} + import xen.lowlevel.xc + xc = xen.lowlevel.xc.xc() + if id != -1: + sched_param[0] = xc.sched_param(id) + else: + domid = 0 + icnt = 0 + domlist = xc.domain_getinfo() + for d in domlist: + domid = d['dom'] + sched_param[icnt] = xc.sched_param(domid) + icnt += 1 + + return sched_param + def xend_domain_maxmem_set(self, id, memory): return self.xendPost(self.domainurl(id), { 'op' : 'maxmem_set', diff -Naurp xen-3.0.0/tools/python/xen/xm/main.py xen-3.0.0-sched-param/tools/python/xen/xm/main.py --- xen-3.0.0/tools/python/xen/xm/main.py 2005-12-05 04:06:31.000000000 +0530 +++ xen-3.0.0-sched-param/tools/python/xen/xm/main.py 2006-03-09 13:37:53.000000000 +0530 @@ -84,6 +84,8 @@ sched_bvt_help = """sched-bvt Set the BVT scheduler context switch allowance""" sched_sedf_help = "sched-sedf Set simple EDF parameters" +sched_info_help = "sched-info Print the Scheduler Used" +sched_param_help = "sched-param Print Parameters associated with scheduler" block_attach_help = """block-attach [BackDomId] Create a new virtual block device""" block_detach_help = """block-detach Destroy a domain's virtual block device, @@ -156,7 +158,9 @@ scheduler_commands = [ "sched-bvt", "sched-bvt-ctxallow", "sched-sedf", - ] + "sched-info", + "sched-param", + ] device_commands = [ "block-attach", @@ -385,7 +389,7 @@ def xm_brief_list(doms): for dom in doms: d = parse_doms_info(dom) if (d['ssidref'] != 0): - d['ssidstr'] = (" s:%04x/p:%04x" % + d['ssidstr'] = (" s:%04x/p:%04x" % ((d['ssidref'] >> 16) & 0xffff, d['ssidref'] & 0xffff)) else: @@ -621,6 +625,70 @@ def xm_sched_sedf(args): from xen.xend.XendClient import server server.xend_domain_cpu_sedf_set(dom, *v) +##Retrieve scheduler Information from xendclient interface +def xm_sched_info(args): + from xen.xend.XendClient import server + schedinf = server.xend_sched_id() + if schedinf == 0: + print "Domain Scheduler : bvt" + elif schedinf == 4: + print "Domain Scheduler : sedf" + else: + print "Domain Scheduler : unknown" + +def xm_sched_param(args): + + argpassed = 0 + domid = -1 + if len(args) > 1: + ## Superflous arguments + print "Usage: xm sched-param [Domain id]" + else: + if len(args) == 1: + ## The domain id is specified; use this domain id to get the + ## cpu scheduler parameters for this domain + try: + dom = int(args[0]) + argpassed = 1 + except (TypeError, ValueError), argerr: + err(argerr) + sys.exit(1) + ## No argument specified; list cpu parmeters for all domain + else: + pass + + from xen.xend.XendClient import server + if argpassed == 1: + info = server.xend_domain(dom) + domid = int(sxp.child_value(info, 'domid', '-1')) + + schedinf = server.xend_sched_id() + schedparam = server.xend_sched_param(domid) + + icnt = 0 + if schedinf == 0: + print "Scheduler : bvt" + print "---------------" + print 'Domain MCuAdv WarpBack WarpValue WarpL WarpU' + + while icnt < len(schedparam): + pars = schedparam[icnt] + print '%2d %8d %8d %16d %16d %16d' % (pars[0], pars[1], pars[2], pars[3], pars[4], pars[5]) + icnt += 1 + + elif schedinf == 4: + print "Scheduler : sedf" + print "----------------" + print 'Domain Slice Period Latency ExtraTime Weight' + + while icnt < len(schedparam): + pars = schedparam[icnt] + print '%2d %12d %16d %8d %8d %8d' % (pars[0], pars[1], pars[2], pars[3], pars[4], pars[5]) + icnt += 1 + else: + print "Scheduler : unknown" + sys.exit(1) + def xm_info(args): from xen.xend.XendClient import server info = server.xend_node() @@ -811,7 +879,9 @@ commands = { # scheduler "sched-bvt": xm_sched_bvt, "sched-bvt-ctxallow": xm_sched_bvt_ctxallow, - "sched-sedf": xm_sched_sedf, + "sched-sedf": xm_sched_sedf, + "sched-info": xm_sched_info, + "sched-param": xm_sched_param, # block "block-attach": xm_block_attach, "block-detach": xm_block_detach,