libxl_domain_sched_params_init(scinfo);
scinfo->sched = LIBXL_SCHEDULER_CREDIT2;
scinfo->weight = sdom.weight;
+ scinfo->cap = sdom.cap;
return 0;
}
const libxl_domain_sched_params *scinfo)
{
struct xen_domctl_sched_credit2 sdom;
+ xc_domaininfo_t info;
int rc;
+ rc = xc_domain_getinfolist(CTX->xch, domid, 1, &info);
+ if (rc < 0) {
+ LOGED(ERROR, domid, "Getting domain info");
+ return ERROR_FAIL;
+ }
+ if (rc != 1 || info.domain != domid)
+ return ERROR_INVAL;
+
rc = xc_sched_credit2_domain_get(CTX->xch, domid, &sdom);
if (rc != 0) {
LOGED(ERROR, domid, "Getting domain sched credit2");
sdom.weight = scinfo->weight;
}
+ if (scinfo->cap != LIBXL_DOMAIN_SCHED_PARAM_CAP_DEFAULT) {
+ if (scinfo->cap < 0
+ || scinfo->cap > (info.max_vcpu_id + 1) * 100) {
+ LOGD(ERROR, domid, "Cpu cap out of range, "
+ "valid range is from 0 to %d for specified number of vcpus",
+ ((info.max_vcpu_id + 1) * 100));
+ return ERROR_INVAL;
+ }
+ sdom.cap = scinfo->cap;
+ }
+
rc = xc_sched_credit2_domain_set(CTX->xch, domid, &sdom);
if ( rc < 0 ) {
LOGED(ERROR, domid, "Setting domain sched credit2");
"[-d <Domain> [-w[=WEIGHT]]] [-p CPUPOOL]",
"-d DOMAIN, --domain=DOMAIN Domain to modify\n"
"-w WEIGHT, --weight=WEIGHT Weight (int)\n"
+ "-c CAP, --cap=CAP Cap (int)\n"
"-s --schedparam Query / modify scheduler parameters\n"
"-r RLIMIT, --ratelimit_us=RLIMIT Set the scheduling rate limit, in microseconds\n"
"-p CPUPOOL, --cpupool=CPUPOOL Restrict output to CPUPOOL"
libxl_domain_sched_params scinfo;
if (domid < 0) {
- printf("%-33s %4s %6s\n", "Name", "ID", "Weight");
+ printf("%-33s %4s %6s %4s\n", "Name", "ID", "Weight", "Cap");
return 0;
}
return 1;
}
domname = libxl_domid_to_name(ctx, domid);
- printf("%-33s %4d %6d\n",
+ printf("%-33s %4d %6d %4d\n",
domname,
domid,
- scinfo.weight);
+ scinfo.weight,
+ scinfo.cap);
free(domname);
libxl_domain_sched_params_dispose(&scinfo);
return 0;
const char *dom = NULL;
const char *cpupool = NULL;
int ratelimit = 0;
- int weight = 256;
+ int weight = 256, cap = 0;
bool opt_s = false;
bool opt_r = false;
bool opt_w = false;
+ bool opt_c = false;
int opt, rc;
static struct option opts[] = {
{"domain", 1, 0, 'd'},
{"weight", 1, 0, 'w'},
+ {"cap", 1, 0, 'c'},
{"schedparam", 0, 0, 's'},
{"ratelimit_us", 1, 0, 'r'},
{"cpupool", 1, 0, 'p'},
COMMON_LONG_OPTS
};
- SWITCH_FOREACH_OPT(opt, "d:w:p:r:s", opts, "sched-credit2", 0) {
+ SWITCH_FOREACH_OPT(opt, "d:w:c:p:r:s", opts, "sched-credit2", 0) {
case 'd':
dom = optarg;
break;
weight = strtol(optarg, NULL, 10);
opt_w = true;
break;
+ case 'c':
+ cap = strtol(optarg, NULL, 10);
+ opt_c = true;
+ break;
case 's':
opt_s = true;
break;
break;
}
- if (cpupool && (dom || opt_w)) {
+ if (cpupool && (dom || opt_w || opt_c)) {
fprintf(stderr, "Specifying a cpupool is not allowed with other "
"options.\n");
return EXIT_FAILURE;
}
- if (!dom && opt_w) {
+ if (!dom && (opt_w || opt_c)) {
fprintf(stderr, "Must specify a domain.\n");
return EXIT_FAILURE;
}
} else {
uint32_t domid = find_domain(dom);
- if (!opt_w) { /* output credit2 scheduler info */
+ if (!opt_w && !opt_c) { /* output credit2 scheduler info */
sched_credit2_domain_output(-1);
if (sched_credit2_domain_output(domid))
return EXIT_FAILURE;
scinfo.sched = LIBXL_SCHEDULER_CREDIT2;
if (opt_w)
scinfo.weight = weight;
+ if (opt_c)
+ scinfo.cap = cap;
rc = sched_domain_set(domid, &scinfo);
libxl_domain_sched_params_dispose(&scinfo);
if (rc)