[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 7 of 9] libxl: Implement libxl_sched_credit_param_[gs]et
Implement functions to set credit scheduler global parameters. v2: - Use "params" rather than "param" - Fix long lines Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx> diff -r af02b1ea16da -r acbe35e4fb4a tools/libxl/libxl.c --- a/tools/libxl/libxl.c Wed Feb 22 16:08:28 2012 +0000 +++ b/tools/libxl/libxl.c Wed Feb 22 16:08:28 2012 +0000 @@ -3034,6 +3034,67 @@ int libxl_sched_credit_domain_set(libxl_ return 0; } +int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t poolid, + libxl_sched_credit_params *scinfo) +{ + struct xen_sysctl_credit_schedule sparam; + int rc; + + rc = xc_sched_credit_params_get(ctx->xch, poolid, &sparam); + if (rc != 0) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting sched credit param"); + return ERROR_FAIL; + } + + scinfo->tslice_ms = sparam.tslice_ms; + scinfo->ratelimit_us = sparam.ratelimit_us; + + return 0; +} + +int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid, + libxl_sched_credit_params *scinfo) +{ + struct xen_sysctl_credit_schedule sparam; + int rc=0; + + if (scinfo->tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN + || scinfo->tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "Time slice out of range, valid range is from %d to %d", + XEN_SYSCTL_CSCHED_TSLICE_MIN, + XEN_SYSCTL_CSCHED_TSLICE_MAX); + return ERROR_INVAL; + } + if (scinfo->ratelimit_us < XEN_SYSCTL_SCHED_RATELIMIT_MIN + || scinfo->ratelimit_us > XEN_SYSCTL_SCHED_RATELIMIT_MAX) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "Ratelimit out of range, valid range is from %d to %d", + XEN_SYSCTL_SCHED_RATELIMIT_MIN, + XEN_SYSCTL_SCHED_RATELIMIT_MAX); + return ERROR_INVAL; + } + if (scinfo->ratelimit_us > scinfo->tslice_ms*1000) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "Ratelimit cannot be greater than timeslice\n"); + return ERROR_INVAL; + } + + sparam.tslice_ms = scinfo->tslice_ms; + sparam.ratelimit_us = scinfo->ratelimit_us; + + rc = xc_sched_credit_params_set(ctx->xch, poolid, &sparam); + if ( rc < 0 ) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting sched credit param"); + return ERROR_FAIL; + } + + scinfo->tslice_ms = sparam.tslice_ms; + scinfo->ratelimit_us = sparam.ratelimit_us; + + return 0; +} + int libxl_sched_credit2_domain_get(libxl_ctx *ctx, uint32_t domid, libxl_sched_credit2_domain *scinfo) { diff -r af02b1ea16da -r acbe35e4fb4a tools/libxl/libxl.h --- a/tools/libxl/libxl.h Wed Feb 22 16:08:28 2012 +0000 +++ b/tools/libxl/libxl.h Wed Feb 22 16:08:28 2012 +0000 @@ -591,6 +591,10 @@ int libxl_sched_credit_domain_get(libxl_ libxl_sched_credit_domain *scinfo); int libxl_sched_credit_domain_set(libxl_ctx *ctx, uint32_t domid, libxl_sched_credit_domain *scinfo); +int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t poolid, + libxl_sched_credit_params *scinfo); +int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid, + libxl_sched_credit_params *scinfo); int libxl_sched_credit2_domain_get(libxl_ctx *ctx, uint32_t domid, libxl_sched_credit2_domain *scinfo); int libxl_sched_credit2_domain_set(libxl_ctx *ctx, uint32_t domid, diff -r af02b1ea16da -r acbe35e4fb4a tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Wed Feb 22 16:08:28 2012 +0000 +++ b/tools/libxl/libxl_types.idl Wed Feb 22 16:08:28 2012 +0000 @@ -395,6 +395,11 @@ libxl_sched_credit_domain = Struct("sche ("cap", integer), ], dispose_fn=None) +libxl_sched_credit_params = Struct("sched_credit_params", [ + ("tslice_ms", integer), + ("ratelimit_us", integer), + ], dispose_fn=None) + libxl_sched_credit2_domain = Struct("sched_credit2_domain", [ ("weight", integer), ], dispose_fn=None) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |