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

Re: [Xen-devel] [PATCH 1 of 3] Support of getting scheduler defaults



On Tue, 2012-05-22 at 14:40 +0100, Ian Campbell wrote:
> On Tue, 2012-05-22 at 14:05 +0100, George Dunlap wrote:
> > 
> > I think Ian has convinced me that just using -1 for default values
> > would be the best option: 
> 
> Perhaps I should code up what I'm talking about for comparison. 

Like the below. Lightly tested with the credit scheduler.

I think CAP is the only one for which 0 is a real valid value, but I'm
not sure (especially with the SEDF ones which didn't have existing
limits checks in the set function I could crib from...).

I'm pretty sure that libxl__sched_set_params needs to get the correct
scheduler for the particular domain, but I've no idea how to get that...

8<---------------------------

# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1337698727 -3600
# Node ID 355030f95eb313605a0e43aa7328e731b28a28b3
# Parent  426bbf58cea4559464b6e5d3ff0f65324a5f5926
libxl: make it possible to explicitly specify default sched params

To do so we define a descriminating value which is never a valid real value for
each parameter.

While there:

 - remove tslice_ms and ratelimit_us from libxl_sched_params and from the xl
   domain config parser. These are global scheduler properties, not per-domain
   ones (and were never read in any case).
 - removed libxl_sched_*_domain in favour of libxl_sched_params.
 - rename libxl_sched_params to libxl_sched_domain_params for clarity.
 - use this new functionality for the various xl commands which set sched
   parameters, which saves an explicit read-modify-write in xl.
 - removed call of xc_domain_getinfolist from a few functions which weren't
   actually using the result (looks like a cut and paste error)
 - fix xl which was setting period for a variety of different config keys.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 426bbf58cea4 -r 355030f95eb3 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Tue May 22 14:19:07 2012 +0100
+++ b/tools/libxl/libxl.c       Tue May 22 15:58:47 2012 +0100
@@ -3168,19 +3168,19 @@ libxl_scheduler libxl_get_scheduler(libx
 }
 
 int libxl_sched_credit_domain_get(libxl_ctx *ctx, uint32_t domid,
-                                  libxl_sched_credit_domain *scinfo)
+                                  libxl_sched_domain_params *scinfo)
 {
     struct xen_domctl_sched_credit sdom;
     int rc;
 
-    libxl_sched_credit_domain_init(scinfo);
-
     rc = xc_sched_credit_domain_get(ctx->xch, domid, &sdom);
     if (rc != 0) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain sched credit");
         return ERROR_FAIL;
     }
 
+    libxl_sched_domain_params_init(scinfo);
+    scinfo->sched = LIBXL_SCHEDULER_CREDIT;
     scinfo->weight = sdom.weight;
     scinfo->cap = sdom.cap;
 
@@ -3188,7 +3188,7 @@ int libxl_sched_credit_domain_get(libxl_
 }
 
 int libxl_sched_credit_domain_set(libxl_ctx *ctx, uint32_t domid,
-                                  libxl_sched_credit_domain *scinfo)
+                                  libxl_sched_domain_params *scinfo)
 {
     struct xen_domctl_sched_credit sdom;
     xc_domaininfo_t domaininfo;
@@ -3202,22 +3202,33 @@ int libxl_sched_credit_domain_set(libxl_
     if (rc != 1 || domaininfo.domain != domid)
         return ERROR_INVAL;
 
-
-    if (scinfo->weight < 1 || scinfo->weight > 65535) {
-        LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
-            "Cpu weight out of range, valid values are within range from 1 to 
65535");
-        return ERROR_INVAL;
+    rc = xc_sched_credit_domain_get(ctx->xch, domid, &sdom);
+    if (rc != 0) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain sched credit");
+        return ERROR_FAIL;
     }
 
-    if (scinfo->cap < 0 || scinfo->cap > (domaininfo.max_vcpu_id + 1) * 100) {
-        LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
-            "Cpu cap out of range, valid range is from 0 to %d for specified 
number of vcpus",
-            ((domaininfo.max_vcpu_id + 1) * 100));
-        return ERROR_INVAL;
+    if (scinfo->weight != LIBXL_SCHED_DOMAIN_PARAM_WEIGHT_DEFAULT) {
+        if (scinfo->weight < 1 || scinfo->weight > 65535) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+                       "Cpu weight out of range, "
+                       "valid values are within range from 1 to 65535");
+            return ERROR_INVAL;
+        }
+        sdom.weight = scinfo->weight;
     }
 
-    sdom.weight = scinfo->weight;
-    sdom.cap = scinfo->cap;
+    if (scinfo->cap != LIBXL_SCHED_DOMAIN_PARAM_CAP_DEFAULT) {
+        if (scinfo->cap < 0
+            || scinfo->cap > (domaininfo.max_vcpu_id + 1) * 100) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+                "Cpu cap out of range, "
+                "valid range is from 0 to %d for specified number of vcpus",
+                       ((domaininfo.max_vcpu_id + 1) * 100));
+            return ERROR_INVAL;
+        }
+        sdom.cap = scinfo->cap;
+    }
 
     rc = xc_sched_credit_domain_set(ctx->xch, domid, &sdom);
     if ( rc < 0 ) {
@@ -3290,13 +3301,11 @@ int libxl_sched_credit_params_set(libxl_
 }
 
 int libxl_sched_credit2_domain_get(libxl_ctx *ctx, uint32_t domid,
-                                   libxl_sched_credit2_domain *scinfo)
+                                   libxl_sched_domain_params *scinfo)
 {
     struct xen_domctl_sched_credit2 sdom;
     int rc;
 
-    libxl_sched_credit2_domain_init(scinfo);
-
     rc = xc_sched_credit2_domain_get(ctx->xch, domid, &sdom);
     if (rc != 0) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
@@ -3304,36 +3313,37 @@ int libxl_sched_credit2_domain_get(libxl
         return ERROR_FAIL;
     }
 
+    libxl_sched_domain_params_init(scinfo);
+    scinfo->sched = LIBXL_SCHEDULER_CREDIT2;
     scinfo->weight = sdom.weight;
 
     return 0;
 }
 
 int libxl_sched_credit2_domain_set(libxl_ctx *ctx, uint32_t domid,
-                                   libxl_sched_credit2_domain *scinfo)
+                                   libxl_sched_domain_params *scinfo)
 {
     struct xen_domctl_sched_credit2 sdom;
-    xc_domaininfo_t domaininfo;
     int rc;
 
-    rc = xc_domain_getinfolist(ctx->xch, domid, 1, &domaininfo);
-    if (rc < 0) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
+    rc = xc_sched_credit2_domain_get(ctx->xch, domid, &sdom);
+    if (rc != 0) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
+                         "getting domain sched credit2");
         return ERROR_FAIL;
     }
-    if (rc != 1 || domaininfo.domain != domid)
-        return ERROR_INVAL;
-
-
-    if (scinfo->weight < 1 || scinfo->weight > 65535) {
-        LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
-            "Cpu weight out of range, valid values are within range from "
-            "1 to 65535");
-        return ERROR_INVAL;
+
+    if (scinfo->weight != LIBXL_SCHED_DOMAIN_PARAM_WEIGHT_DEFAULT) {
+        if (scinfo->weight < 1 || scinfo->weight > 65535) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+                       "Cpu weight out of range, "
+                       "valid values are within range from "
+                       "1 to 65535");
+            return ERROR_INVAL;
+        }
+        sdom.weight = scinfo->weight;
     }
 
-    sdom.weight = scinfo->weight;
-
     rc = xc_sched_credit2_domain_set(ctx->xch, domid, &sdom);
     if ( rc < 0 ) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
@@ -3345,7 +3355,7 @@ int libxl_sched_credit2_domain_set(libxl
 }
 
 int libxl_sched_sedf_domain_get(libxl_ctx *ctx, uint32_t domid,
-                                libxl_sched_sedf_domain *scinfo)
+                                libxl_sched_domain_params *scinfo)
 {
     uint64_t period;
     uint64_t slice;
@@ -3354,8 +3364,6 @@ int libxl_sched_sedf_domain_get(libxl_ct
     uint16_t weight;
     int rc;
 
-    libxl_sched_sedf_domain_init(scinfo);
-
     rc = xc_sedf_domain_get(ctx->xch, domid, &period, &slice, &latency,
                             &extratime, &weight);
     if (rc != 0) {
@@ -3363,6 +3371,8 @@ int libxl_sched_sedf_domain_get(libxl_ct
         return ERROR_FAIL;
     }
 
+    libxl_sched_domain_params_init(scinfo);
+    scinfo->sched = LIBXL_SCHEDULER_SEDF;
     scinfo->period = period / 1000000;
     scinfo->slice = slice / 1000000;
     scinfo->latency = latency / 1000000;
@@ -3373,24 +3383,37 @@ int libxl_sched_sedf_domain_get(libxl_ct
 }
 
 int libxl_sched_sedf_domain_set(libxl_ctx *ctx, uint32_t domid,
-                                libxl_sched_sedf_domain *scinfo)
+                                libxl_sched_domain_params *scinfo)
 {
-    xc_domaininfo_t domaininfo;
-    int rc;
-
-    rc = xc_domain_getinfolist(ctx->xch, domid, 1, &domaininfo);
-    if (rc < 0) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
+    uint64_t period;
+    uint64_t slice;
+    uint64_t latency;
+    uint16_t extratime;
+    uint16_t weight;
+
+    int ret;
+
+    ret = xc_sedf_domain_get(ctx->xch, domid, &period, &slice, &latency,
+                            &extratime, &weight);
+    if (ret != 0) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain sched sedf");
         return ERROR_FAIL;
     }
-    if (rc != 1 || domaininfo.domain != domid)
-        return ERROR_INVAL;
-
-
-    rc = xc_sedf_domain_set(ctx->xch, domid, scinfo->period * 1000000,
-                            scinfo->slice * 1000000, scinfo->latency * 1000000,
-                            scinfo->extratime, scinfo->weight);
-    if ( rc < 0 ) {
+
+    if (scinfo->period != LIBXL_SCHED_DOMAIN_PARAM_PERIOD_DEFAULT)
+        period = scinfo->period * 1000000;
+    if (scinfo->slice != LIBXL_SCHED_DOMAIN_PARAM_SLICE_DEFAULT)
+        period = scinfo->slice * 1000000;
+    if (scinfo->latency != LIBXL_SCHED_DOMAIN_PARAM_LATENCY_DEFAULT)
+        period = scinfo->latency * 1000000;
+    if (scinfo->extratime != LIBXL_SCHED_DOMAIN_PARAM_EXTRATIME_DEFAULT)
+        period = scinfo->extratime;
+    if (scinfo->weight != LIBXL_SCHED_DOMAIN_PARAM_WEIGHT_DEFAULT)
+        period = scinfo->weight;
+
+    ret = xc_sedf_domain_set(ctx->xch, domid, period, slice, latency,
+                            extratime, weight);
+    if ( ret < 0 ) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting domain sched sedf");
         return ERROR_FAIL;
     }
diff -r 426bbf58cea4 -r 355030f95eb3 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Tue May 22 14:19:07 2012 +0100
+++ b/tools/libxl/libxl.h       Tue May 22 15:58:47 2012 +0100
@@ -805,23 +805,33 @@ int libxl_set_vcpuonline(libxl_ctx *ctx,
 
 libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx);
 
-
-int libxl_sched_credit_domain_get(libxl_ctx *ctx, uint32_t domid,
-                                  libxl_sched_credit_domain *scinfo);
-int libxl_sched_credit_domain_set(libxl_ctx *ctx, uint32_t domid,
-                                  libxl_sched_credit_domain *scinfo);
+/* Per-scheduler parameters */
 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);
+
+/* Scheduler Per-domain parameters */
+
+#define LIBXL_SCHED_DOMAIN_PARAM_WEIGHT_DEFAULT    0
+#define LIBXL_SCHED_DOMAIN_PARAM_CAP_DEFAULT       -1
+#define LIBXL_SCHED_DOMAIN_PARAM_PERIOD_DEFAULT    0
+#define LIBXL_SCHED_DOMAIN_PARAM_SLICE_DEFAULT     0
+#define LIBXL_SCHED_DOMAIN_PARAM_LATENCY_DEFAULT   0
+#define LIBXL_SCHED_DOMAIN_PARAM_EXTRATIME_DEFAULT 0
+
+int libxl_sched_credit_domain_get(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_sched_domain_params *scinfo);
+int libxl_sched_credit_domain_set(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_sched_domain_params *scinfo);
 int libxl_sched_credit2_domain_get(libxl_ctx *ctx, uint32_t domid,
-                                   libxl_sched_credit2_domain *scinfo);
+                                   libxl_sched_domain_params *scinfo);
 int libxl_sched_credit2_domain_set(libxl_ctx *ctx, uint32_t domid,
-                                   libxl_sched_credit2_domain *scinfo);
+                                   libxl_sched_domain_params *scinfo);
 int libxl_sched_sedf_domain_get(libxl_ctx *ctx, uint32_t domid,
-                                libxl_sched_sedf_domain *scinfo);
+                                libxl_sched_domain_params *scinfo);
 int libxl_sched_sedf_domain_set(libxl_ctx *ctx, uint32_t domid,
-                                libxl_sched_sedf_domain *scinfo);
+                                libxl_sched_domain_params *scinfo);
 int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,
                        libxl_trigger trigger, uint32_t vcpuid);
 int libxl_send_sysrq(libxl_ctx *ctx, uint32_t domid, char sysrq);
diff -r 426bbf58cea4 -r 355030f95eb3 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Tue May 22 14:19:07 2012 +0100
+++ b/tools/libxl/libxl_dom.c   Tue May 22 15:58:47 2012 +0100
@@ -42,36 +42,30 @@ libxl_domain_type libxl__domain_type(lib
         return LIBXL_DOMAIN_TYPE_PV;
 }
 
-int libxl__sched_set_params(libxl__gc *gc, uint32_t domid, libxl_sched_params 
*scparams)
+int libxl__sched_set_params(libxl__gc *gc, uint32_t domid,
+                            libxl_sched_domain_params *scparams)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    libxl_scheduler sched;
-    libxl_sched_sedf_domain sedf_info;
-    libxl_sched_credit_domain credit_info;
-    libxl_sched_credit2_domain credit2_info;
+    libxl_scheduler sched = scparams->sched;
     int ret;
 
-    sched = libxl_get_scheduler (ctx);
+    if (sched == LIBXL_SCHEDULER_UNKNOWN)
+        sched = libxl_get_scheduler(ctx);
+
     switch (sched) {
     case LIBXL_SCHEDULER_SEDF:
-      sedf_info.period = scparams->period;
-      sedf_info.slice = scparams->slice;
-      sedf_info.latency = scparams->latency;
-      sedf_info.extratime = scparams->extratime;
-      sedf_info.weight = scparams->weight;
-      ret=libxl_sched_sedf_domain_set(ctx, domid, &sedf_info);
-      break;
+        ret=libxl_sched_sedf_domain_set(ctx, domid, scparams);
+        break;
     case LIBXL_SCHEDULER_CREDIT:
-      credit_info.weight = scparams->weight;
-      credit_info.cap = scparams->cap;
-      ret=libxl_sched_credit_domain_set(ctx, domid, &credit_info);
-      break;
+        ret=libxl_sched_credit_domain_set(ctx, domid, scparams);
+        break;
     case LIBXL_SCHEDULER_CREDIT2:
-      credit2_info.weight = scparams->weight;
-      ret=libxl_sched_credit2_domain_set(ctx, domid, &credit2_info);
-      break;
+        ret=libxl_sched_credit2_domain_set(ctx, domid, scparams);
+        break;
     default:
-      ret=-1;
+        LOG(ERROR, "Unknown scheduler");
+        ret=ERROR_INVAL;
+        break;
     }
     return ret;
 }
diff -r 426bbf58cea4 -r 355030f95eb3 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Tue May 22 14:19:07 2012 +0100
+++ b/tools/libxl/libxl_internal.h      Tue May 22 15:58:47 2012 +0100
@@ -716,7 +716,7 @@ _hidden int libxl__atfork_init(libxl_ctx
 /* from xl_dom */
 _hidden libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid);
-_hidden int libxl__sched_set_params(libxl__gc *gc, uint32_t domid, 
libxl_sched_params *scparams);
+_hidden int libxl__sched_set_params(libxl__gc *gc, uint32_t domid, 
libxl_sched_domain_params *scparams);
 #define LIBXL__DOMAIN_IS_TYPE(gc, domid, type) \
     libxl__domain_type((gc), (domid)) == LIBXL_DOMAIN_TYPE_##type
 typedef struct {
diff -r 426bbf58cea4 -r 355030f95eb3 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl       Tue May 22 14:19:07 2012 +0100
+++ b/tools/libxl/libxl_types.idl       Tue May 22 15:58:47 2012 +0100
@@ -109,7 +109,9 @@ libxl_bios_type = Enumeration("bios_type
     ])
 
 # Consistent with values defined in domctl.h
+# Except unknown which is special.
 libxl_scheduler = Enumeration("scheduler", [
+    (0, "unknown"),
     (4, "sedf"),
     (5, "credit"),
     (6, "credit2"),
@@ -224,15 +226,14 @@ libxl_domain_create_info = Struct("domai
 
 MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
 
-libxl_sched_params = Struct("sched_params",[
-    ("weight",       integer),
-    ("cap",          integer),
-    ("tslice_ms",    integer),
-    ("ratelimit_us", integer),
-    ("period",       integer),
-    ("slice",        integer),
-    ("latency",      integer),
-    ("extratime",    integer),
+libxl_sched_domain_params = Struct("sched_domain_params",[
+    ("sched",        libxl_scheduler),
+    ("weight",       integer, {'init_val': 
'LIBXL_SCHED_DOMAIN_PARAM_WEIGHT_DEFAULT'}),
+    ("cap",          integer, {'init_val': 
'LIBXL_SCHED_DOMAIN_PARAM_CAP_DEFAULT'}),
+    ("period",       integer, {'init_val': 
'LIBXL_SCHED_DOMAIN_PARAM_PERIOD_DEFAULT'}),
+    ("slice",        integer, {'init_val': 
'LIBXL_SCHED_DOMAIN_PARAM_SLICE_DEFAULT'}),
+    ("latency",      integer, {'init_val': 
'LIBXL_SCHED_DOMAIN_PARAM_LATENCY_DEFAULT'}),
+    ("extratime",    integer, {'init_val': 
'LIBXL_SCHED_DOMAIN_PARAM_EXTRATIME_DEFAULT'}),
     ], dir=DIR_IN)
 
 # Instances of libxl_file_reference contained in this struct which
@@ -267,7 +268,7 @@ libxl_domain_build_info = Struct("domain
     # extra parameters pass directly to qemu for HVM guest, NULL terminated
     ("extra_hvm",        libxl_string_list),
     #  parameters for all type of scheduler
-    ("sched_params",     libxl_sched_params),
+    ("sched_params",     libxl_sched_domain_params),
 
     ("u", KeyedUnion(None, libxl_domain_type, "type",
                 [("hvm", Struct(None, [("firmware",         string),
@@ -432,28 +433,11 @@ libxl_cputopology = Struct("cputopology"
     ("node", uint32),
     ], dir=DIR_OUT)
 
-libxl_sched_credit_domain = Struct("sched_credit_domain", [
-    ("weight", integer),
-    ("cap", integer),
-    ])
-
 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),
-    ])
-
-libxl_sched_sedf_domain = Struct("sched_sedf_domain", [
-    ("period", integer),
-    ("slice", integer),
-    ("latency", integer),
-    ("extratime", integer),
-    ("weight", integer),
-    ])
-
 libxl_domain_remus_info = Struct("domain_remus_info",[
     ("interval",     integer),
     ("blackhole",    bool),
diff -r 426bbf58cea4 -r 355030f95eb3 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Tue May 22 14:19:07 2012 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Tue May 22 15:58:47 2012 +0100
@@ -627,23 +627,20 @@ static void parse_config_data(const char
 
     libxl_domain_build_info_init_type(b_info, c_info->type);
 
-    /* the following is the actual config parsing with overriding values in 
the structures */
+    /* the following is the actual config parsing with overriding
+     * values in the structures */
     if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0))
         b_info->sched_params.weight = l;
     if (!xlu_cfg_get_long (config, "cap", &l, 0))
         b_info->sched_params.cap = l;
-    if (!xlu_cfg_get_long (config, "tslice_ms", &l, 0))
-        b_info->sched_params.tslice_ms = l;
-    if (!xlu_cfg_get_long (config, "ratelimit_us", &l, 0))
-        b_info->sched_params.ratelimit_us = l;
     if (!xlu_cfg_get_long (config, "period", &l, 0))
         b_info->sched_params.period = l;
     if (!xlu_cfg_get_long (config, "slice", &l, 0))
-        b_info->sched_params.period = l;
+        b_info->sched_params.slice = l;
     if (!xlu_cfg_get_long (config, "latency", &l, 0))
-        b_info->sched_params.period = l;
+        b_info->sched_params.latency = l;
     if (!xlu_cfg_get_long (config, "extratime", &l, 0))
-        b_info->sched_params.period = l;
+        b_info->sched_params.extratime = l;
 
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
@@ -4355,7 +4352,7 @@ int main_sharing(int argc, char **argv)
     return 0;
 }
 
-static int sched_credit_domain_get(int domid, libxl_sched_credit_domain 
*scinfo)
+static int sched_credit_domain_get(int domid, libxl_sched_domain_params 
*scinfo)
 {
     int rc;
 
@@ -4366,7 +4363,7 @@ static int sched_credit_domain_get(int d
     return rc;
 }
 
-static int sched_credit_domain_set(int domid, libxl_sched_credit_domain 
*scinfo)
+static int sched_credit_domain_set(int domid, libxl_sched_domain_params 
*scinfo)
 {
     int rc;
 
@@ -4402,7 +4399,7 @@ static int sched_credit_params_get(int p
 static int sched_credit_domain_output(int domid)
 {
     char *domname;
-    libxl_sched_credit_domain scinfo;
+    libxl_sched_domain_params scinfo;
     int rc;
 
     if (domid < 0) {
@@ -4419,7 +4416,7 @@ static int sched_credit_domain_output(in
         scinfo.weight,
         scinfo.cap);
     free(domname);
-    libxl_sched_credit_domain_dispose(&scinfo);
+    libxl_sched_domain_params_dispose(&scinfo);
     return 0;
 }
 
@@ -4445,7 +4442,7 @@ static int sched_credit_pool_output(uint
 }
 
 static int sched_credit2_domain_get(
-    int domid, libxl_sched_credit2_domain *scinfo)
+    int domid, libxl_sched_domain_params *scinfo)
 {
     int rc;
 
@@ -4457,7 +4454,7 @@ static int sched_credit2_domain_get(
 }
 
 static int sched_credit2_domain_set(
-    int domid, libxl_sched_credit2_domain *scinfo)
+    int domid, libxl_sched_domain_params *scinfo)
 {
     int rc;
 
@@ -4472,7 +4469,7 @@ static int sched_credit2_domain_output(
     int domid)
 {
     char *domname;
-    libxl_sched_credit2_domain scinfo;
+    libxl_sched_domain_params scinfo;
     int rc;
 
     if (domid < 0) {
@@ -4488,12 +4485,12 @@ static int sched_credit2_domain_output(
         domid,
         scinfo.weight);
     free(domname);
-    libxl_sched_credit2_domain_dispose(&scinfo);
+    libxl_sched_domain_params_dispose(&scinfo);
     return 0;
 }
 
 static int sched_sedf_domain_get(
-    int domid, libxl_sched_sedf_domain *scinfo)
+    int domid, libxl_sched_domain_params *scinfo)
 {
     int rc;
 
@@ -4505,7 +4502,7 @@ static int sched_sedf_domain_get(
 }
 
 static int sched_sedf_domain_set(
-    int domid, libxl_sched_sedf_domain *scinfo)
+    int domid, libxl_sched_domain_params *scinfo)
 {
     int rc;
 
@@ -4519,7 +4516,7 @@ static int sched_sedf_domain_output(
     int domid)
 {
     char *domname;
-    libxl_sched_sedf_domain scinfo;
+    libxl_sched_domain_params scinfo;
     int rc;
 
     if (domid < 0) {
@@ -4540,7 +4537,7 @@ static int sched_sedf_domain_output(
         scinfo.extratime,
         scinfo.weight);
     free(domname);
-    libxl_sched_sedf_domain_dispose(&scinfo);
+    libxl_sched_domain_params_dispose(&scinfo);
     return 0;
 }
 
@@ -4620,7 +4617,6 @@ static int sched_domain_output(libxl_sch
  */
 int main_sched_credit(int argc, char **argv)
 {
-    libxl_sched_credit_domain scinfo;
     const char *dom = NULL;
     const char *cpupool = NULL;
     int weight = 256, cap = 0, opt_w = 0, opt_c = 0;
@@ -4695,7 +4691,7 @@ int main_sched_credit(int argc, char **a
     }
 
     if (opt_s) {
-        libxl_sched_credit_params  scparam;
+        libxl_sched_credit_params scparam;
         uint32_t poolid = 0;
 
         if (cpupool) {
@@ -4731,20 +4727,19 @@ int main_sched_credit(int argc, char **a
     } else {
         find_domain(dom);
 
-        rc = sched_credit_domain_get(domid, &scinfo);
-        if (rc)
-            return -rc;
-
         if (!opt_w && !opt_c) { /* output credit scheduler info */
             sched_credit_domain_output(-1);
             return -sched_credit_domain_output(domid);
         } else { /* set credit scheduler paramaters */
+            libxl_sched_domain_params scinfo;
+            libxl_sched_domain_params_init(&scinfo);
+            scinfo.sched = LIBXL_SCHEDULER_CREDIT;
             if (opt_w)
                 scinfo.weight = weight;
             if (opt_c)
                 scinfo.cap = cap;
             rc = sched_credit_domain_set(domid, &scinfo);
-            libxl_sched_credit_domain_dispose(&scinfo);
+            libxl_sched_domain_params_dispose(&scinfo);
             if (rc)
                 return -rc;
         }
@@ -4755,7 +4750,6 @@ int main_sched_credit(int argc, char **a
 
 int main_sched_credit2(int argc, char **argv)
 {
-    libxl_sched_credit2_domain scinfo;
     const char *dom = NULL;
     const char *cpupool = NULL;
     int weight = 256, opt_w = 0;
@@ -4810,18 +4804,17 @@ int main_sched_credit2(int argc, char **
     } else {
         find_domain(dom);
 
-        rc = sched_credit2_domain_get(domid, &scinfo);
-        if (rc)
-            return -rc;
-
         if (!opt_w) { /* output credit2 scheduler info */
             sched_credit2_domain_output(-1);
             return -sched_credit2_domain_output(domid);
         } else { /* set credit2 scheduler paramaters */
+            libxl_sched_domain_params scinfo;
+            libxl_sched_domain_params_init(&scinfo);
+            scinfo.sched = LIBXL_SCHEDULER_CREDIT2;
             if (opt_w)
                 scinfo.weight = weight;
             rc = sched_credit2_domain_set(domid, &scinfo);
-            libxl_sched_credit2_domain_dispose(&scinfo);
+            libxl_sched_domain_params_dispose(&scinfo);
             if (rc)
                 return -rc;
         }
@@ -4832,7 +4825,6 @@ int main_sched_credit2(int argc, char **
 
 int main_sched_sedf(int argc, char **argv)
 {
-    libxl_sched_sedf_domain scinfo;
     const char *dom = NULL;
     const char *cpupool = NULL;
     int period = 0, opt_p = 0;
@@ -4915,15 +4907,15 @@ int main_sched_sedf(int argc, char **arg
     } else {
         find_domain(dom);
 
-        rc = sched_sedf_domain_get(domid, &scinfo);
-        if (rc)
-            return -rc;
-
         if (!opt_p && !opt_s && !opt_l && !opt_e && !opt_w) {
             /* output sedf scheduler info */
             sched_sedf_domain_output(-1);
             return -sched_sedf_domain_output(domid);
         } else { /* set sedf scheduler paramaters */
+            libxl_sched_domain_params scinfo;
+            libxl_sched_domain_params_init(&scinfo);
+            scinfo.sched = LIBXL_SCHEDULER_SEDF;
+
             if (opt_p) {
                 scinfo.period = period;
                 scinfo.weight = 0;
@@ -4942,7 +4934,7 @@ int main_sched_sedf(int argc, char **arg
                 scinfo.slice = 0;
             }
             rc = sched_sedf_domain_set(domid, &scinfo);
-            libxl_sched_sedf_domain_dispose(&scinfo);
+            libxl_sched_domain_params_dispose(&scinfo);
             if (rc)
                 return -rc;
         }



_______________________________________________
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®.