[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 08 of 10] libxl: Implement libxl_sched_credit_param_[gs]et



Implement functions to set credit scheduler global parameters.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>

diff -r 127b33c09db2 -r d70161aab13e tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Tue Feb 21 12:14:32 2012 +0000
+++ b/tools/libxl/libxl.c       Tue Feb 21 12:17:12 2012 +0000
@@ -3032,6 +3032,65 @@ int libxl_sched_credit_domain_set(libxl_
     return 0;
 }
 
+int libxl_sched_credit_param_get(libxl_ctx *ctx, uint32_t poolid, 
libxl_sched_credit_param *scinfo)
+{
+    struct xen_sysctl_credit_schedule sparam;
+    int rc;
+
+    rc = xc_sched_credit_param_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_param_set(libxl_ctx *ctx, uint32_t poolid, 
libxl_sched_credit_param *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_param_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 127b33c09db2 -r d70161aab13e tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Tue Feb 21 12:14:32 2012 +0000
+++ b/tools/libxl/libxl.h       Tue Feb 21 12:17:12 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_param_get(libxl_ctx *ctx, uint32_t poolid,
+                                  libxl_sched_credit_param *scinfo);
+int libxl_sched_credit_param_set(libxl_ctx *ctx, uint32_t poolid,
+                                  libxl_sched_credit_param *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 127b33c09db2 -r d70161aab13e tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl       Tue Feb 21 12:14:32 2012 +0000
+++ b/tools/libxl/libxl_types.idl       Tue Feb 21 12:17:12 2012 +0000
@@ -395,6 +395,11 @@ libxl_sched_credit_domain = Struct("sche
     ("cap", integer),
     ], dispose_fn=None)
 
+libxl_sched_credit_param = Struct("sched_credit_param", [
+    ("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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.