/* Management of scheduler parameters */
+/**
+ * VIR_DOMAIN_SCHEDULER_CPU_SHARES:
+ *
+ * Macro represents proportional weight of the scheduler used on the
+ * host cpu, when using the posix scheduler, as a ullong.
+ */
+#define VIR_DOMAIN_SCHEDULER_CPU_SHARES "cpu_shares"
+
+/**
+ * VIR_DOMAIN_SCHEDULER_VCPU_PERIOD:
+ *
+ * Macro represents the enforcement period for a quota, in microseconds,
+ * when using the posix scheduler, as a ullong.
+ */
+#define VIR_DOMAIN_SCHEDULER_VCPU_PERIOD "vcpu_period"
+
+/**
+ * VIR_DOMAIN_SCHEDULER_VCPU_QUOTA:
+ *
+ * Macro represents the maximum bandwidth to be used within a period,
+ * when using the posix scheduler, as an llong.
+ */
+#define VIR_DOMAIN_SCHEDULER_VCPU_QUOTA "vcpu_quota"
+
+/**
+ * VIR_DOMAIN_SCHEDULER_WEIGHT:
+ *
+ * Macro represents the relative weight, when using the credit
+ * scheduler, as a uint.
+ */
+#define VIR_DOMAIN_SCHEDULER_WEIGHT "weight"
+
+/**
+ * VIR_DOMAIN_SCHEDULER_CAP:
+ *
+ * Macro represents the maximum scheduler cap, when using the credit
+ * scheduler, as a uint.
+ */
+#define VIR_DOMAIN_SCHEDULER_CAP "cap"
+
+/**
+ * VIR_DOMAIN_SCHEDULER_RESERVATION:
+ *
+ * Macro represents the scheduler reservation value, when using the
+ * allocation scheduler, as an llong.
+ */
+#define VIR_DOMAIN_SCHEDULER_RESERVATION "reservation"
+
+/**
+ * VIR_DOMAIN_SCHEDULER_LIMIT:
+ *
+ * Macro represents the scheduler limit value, when using the
+ * allocation scheduler, as an llong.
+ */
+#define VIR_DOMAIN_SCHEDULER_LIMIT "limit"
+
+/**
+ * VIR_DOMAIN_SCHEDULER_SHARES:
+ *
+ * Macro represents the scheduler shares value, when using the
+ * allocation scheduler, as an int.
+ */
+#define VIR_DOMAIN_SCHEDULER_SHARES "shares"
+
/*
* Fetch scheduler parameters, caller allocates 'params' field of size 'nparams'
*/
/**
* VIR_DOMAIN_BLOCK_STATS_FIELD_LENGTH:
*
- * Macro providing the field length of virDomainBlockStatsFlagsStruct
+ * Macro providing the field length of parameter names when using
+ * virDomainBlockStatsFlags().
*/
-#define VIR_DOMAIN_BLOCK_STATS_FIELD_LENGTH 80
+#define VIR_DOMAIN_BLOCK_STATS_FIELD_LENGTH VIR_TYPED_PARAM_FIELD_LENGTH
/**
* VIR_DOMAIN_BLOCK_STATS_READ_BYTES:
*
* Macro represents the total number of read bytes of the
- * block device.
+ * block device, as an llong.
*/
#define VIR_DOMAIN_BLOCK_STATS_READ_BYTES "rd_bytes"
* VIR_DOMAIN_BLOCK_STATS_READ_REQ:
*
* Macro represents the total read requests of the
- * block device.
+ * block device, as an llong.
*/
#define VIR_DOMAIN_BLOCK_STATS_READ_REQ "rd_operations"
* VIR_DOMAIN_BLOCK_STATS_READ_TOTAL_TIMES:
*
* Macro represents the total time spend on cache reads in
- * nano-seconds of the block device.
+ * nano-seconds of the block device, as an llong.
*/
#define VIR_DOMAIN_BLOCK_STATS_READ_TOTAL_TIMES "rd_total_times"
* VIR_DOMAIN_BLOCK_STATS_WRITE_BYTES:
*
* Macro represents the total number of write bytes of the
- * block device.
+ * block device, as an llong.
*/
#define VIR_DOMAIN_BLOCK_STATS_WRITE_BYTES "wr_bytes"
* VIR_DOMAIN_BLOCK_STATS_WRITE_REQ:
*
* Macro represents the total write requests of the
- * block device.
+ * block device, as an llong.
*/
#define VIR_DOMAIN_BLOCK_STATS_WRITE_REQ "wr_operations"
* VIR_DOMAIN_BLOCK_STATS_WRITE_TOTAL_TIMES:
*
* Macro represents the total time spend on cache writes in
- * nano-seconds of the block device.
+ * nano-seconds of the block device, as an llong.
*/
#define VIR_DOMAIN_BLOCK_STATS_WRITE_TOTAL_TIMES "wr_total_times"
* VIR_DOMAIN_BLOCK_STATS_FLUSH_REQ:
*
* Macro represents the total flush requests of the
- * block device.
+ * block device, as an llong.
*/
#define VIR_DOMAIN_BLOCK_STATS_FLUSH_REQ "flush_operations"
* VIR_DOMAIN_BLOCK_STATS_FLUSH_TOTAL_TIMES:
*
* Macro represents the total time spend on cache flushing in
- * nano-seconds of the block device.
+ * nano-seconds of the block device, as an llong.
*/
#define VIR_DOMAIN_BLOCK_STATS_FLUSH_TOTAL_TIMES "flush_total_times"
/**
* VIR_DOMAIN_BLOCK_STATS_ERRS:
*
- * In Xen this returns the mysterious 'oo_req'
+ * In Xen this returns the mysterious 'oo_req', as an llong.
*/
#define VIR_DOMAIN_BLOCK_STATS_ERRS "errs"
* VIR_DOMAIN_BLKIO_WEIGHT:
*
* Macro for the Blkio tunable weight: it represents the io weight
- * the guest can use.
+ * the guest can use, as a uint.
*/
#define VIR_DOMAIN_BLKIO_WEIGHT "weight"
* VIR_DOMAIN_MEMORY_HARD_LIMIT:
*
* Macro for the memory tunable hard_limit: it represents the maximum memory
- * the guest can use.
+ * the guest can use, as a ullong.
*/
#define VIR_DOMAIN_MEMORY_HARD_LIMIT "hard_limit"
* VIR_DOMAIN_MEMORY_SOFT_LIMIT:
*
* Macro for the memory tunable soft_limit: it represents the memory upper
- * limit enforced during memory contention.
+ * limit enforced during memory contention, as a ullong.
*/
#define VIR_DOMAIN_MEMORY_SOFT_LIMIT "soft_limit"
* VIR_DOMAIN_MEMORY_MIN_GUARANTEE:
*
* Macro for the memory tunable min_guarantee: it represents the minimum
- * memory guaranteed to be reserved for the guest.
+ * memory guaranteed to be reserved for the guest, as a ullong.
*/
#define VIR_DOMAIN_MEMORY_MIN_GUARANTEE "min_guarantee"
* VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT:
*
* Macro for the swap tunable swap_hard_limit: it represents the maximum swap
- * plus memory the guest can use. This limit has to be more than
+ * plus memory the guest can use, as a ullong. This limit has to be more than
* VIR_DOMAIN_MEMORY_HARD_LIMIT.
*/
if (STREQ(dynamicProperty->name, "config.cpuAllocation.reservation") &&
! (mask & (1 << 0))) {
snprintf (params[i].field, VIR_TYPED_PARAM_FIELD_LENGTH, "%s",
- "reservation");
+ VIR_DOMAIN_SCHEDULER_RESERVATION);
params[i].type = VIR_TYPED_PARAM_LLONG;
"config.cpuAllocation.limit") &&
! (mask & (1 << 1))) {
snprintf (params[i].field, VIR_TYPED_PARAM_FIELD_LENGTH, "%s",
- "limit");
+ VIR_DOMAIN_SCHEDULER_LIMIT);
params[i].type = VIR_TYPED_PARAM_LLONG;
"config.cpuAllocation.shares") &&
! (mask & (1 << 2))) {
snprintf (params[i].field, VIR_TYPED_PARAM_FIELD_LENGTH, "%s",
- "shares");
+ VIR_DOMAIN_SCHEDULER_SHARES);
params[i].type = VIR_TYPED_PARAM_INT;
}
for (i = 0; i < nparams; ++i) {
- if (STREQ (params[i].field, "reservation") &&
+ if (STREQ (params[i].field, VIR_DOMAIN_SCHEDULER_RESERVATION) &&
params[i].type == VIR_TYPED_PARAM_LLONG) {
if (esxVI_Long_Alloc(&spec->cpuAllocation->reservation) < 0) {
goto cleanup;
}
spec->cpuAllocation->reservation->value = params[i].value.l;
- } else if (STREQ (params[i].field, "limit") &&
+ } else if (STREQ (params[i].field, VIR_DOMAIN_SCHEDULER_LIMIT) &&
params[i].type == VIR_TYPED_PARAM_LLONG) {
if (esxVI_Long_Alloc(&spec->cpuAllocation->limit) < 0) {
goto cleanup;
}
spec->cpuAllocation->limit->value = params[i].value.l;
- } else if (STREQ (params[i].field, "shares") &&
+ } else if (STREQ (params[i].field, VIR_DOMAIN_SCHEDULER_SHARES) &&
params[i].type == VIR_TYPED_PARAM_INT) {
if (esxVI_SharesInfo_Alloc(&sharesInfo) < 0 ||
esxVI_Int_Alloc(&sharesInfo->shares) < 0) {
params[0].value.ui = sc_info.weight;
params[0].type = VIR_TYPED_PARAM_UINT;
- if (virStrcpyStatic(params[0].field, "weight") == NULL) {
+ if (virStrcpyStatic(params[0].field,
+ VIR_DOMAIN_SCHEDULER_WEIGHT) == NULL) {
libxlError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field weight too long for destination"));
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_SCHEDULER_WEIGHT);
goto cleanup;
}
params[1].value.ui = sc_info.cap;
params[1].type = VIR_TYPED_PARAM_UINT;
- if (virStrcpyStatic(params[1].field, "cap") == NULL) {
+ if (virStrcpyStatic(params[1].field, VIR_DOMAIN_SCHEDULER_CAP) == NULL) {
libxlError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field cap too long for destination"));
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_SCHEDULER_CAP);
goto cleanup;
}
for (i = 0; i < nparams; ++i) {
virTypedParameterPtr param = ¶ms[i];
- if (STREQ(param->field, "weight")) {
+ if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_WEIGHT)) {
if (param->type != VIR_TYPED_PARAM_UINT) {
libxlError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for weight tunable, expected a 'uint'"));
}
sc_info.weight = params[i].value.ui;
- } else if (STREQ(param->field, "cap")) {
+ } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CAP)) {
if (param->type != VIR_TYPED_PARAM_UINT) {
libxlError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for cap tunable, expected a 'uint'"));
for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = ¶ms[i];
- if (STRNEQ(param->field, "cpu_shares")) {
+ if (STRNEQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
lxcError(VIR_ERR_INVALID_ARG,
_("Invalid parameter `%s'"), param->field);
goto cleanup;
if (virCgroupGetCpuShares(group, &val) != 0)
goto cleanup;
params[0].value.ul = val;
- if (virStrcpyStatic(params[0].field, "cpu_shares") == NULL) {
+ if (virStrcpyStatic(params[0].field,
+ VIR_DOMAIN_SCHEDULER_CPU_SHARES) == NULL) {
lxcError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field cpu_shares too big for destination"));
goto cleanup;
}
} else if (STREQ(param->field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE)) {
qemuReportError(VIR_ERR_INVALID_ARG,
- _("Memory tunable `%s' not implemented"), param->field);
+ _("Memory tunable `%s' not implemented"),
+ param->field);
ret = -1;
} else {
qemuReportError(VIR_ERR_INVALID_ARG,
for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = ¶ms[i];
- if (STREQ(param->field, "cpu_shares")) {
+ if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
if (param->type != VIR_TYPED_PARAM_ULLONG) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for cpu_shares tunable, expected a 'ullong'"));
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vmdef->cputune.shares = params[i].value.ul;
}
- } else if (STREQ(param->field, "vcpu_period")) {
+ } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)) {
if (param->type != VIR_TYPED_PARAM_ULLONG) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for vcpu_period tunable,"
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vmdef->cputune.period = params[i].value.ul;
}
- } else if (STREQ(param->field, "vcpu_quota")) {
+ } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA)) {
if (param->type != VIR_TYPED_PARAM_LLONG) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for vcpu_quota tunable,"
out:
params[0].value.ul = shares;
params[0].type = VIR_TYPED_PARAM_ULLONG;
- /* XXX make these field names public in libvirt.h */
- if (virStrcpyStatic(params[0].field, "cpu_shares") == NULL) {
+ if (virStrcpyStatic(params[0].field,
+ VIR_DOMAIN_SCHEDULER_CPU_SHARES) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("Field name '%s' too long"),
- "cpu_shares");
+ VIR_DOMAIN_SCHEDULER_CPU_SHARES);
goto cleanup;
}
if (*nparams > saved_nparams) {
params[1].value.ul = period;
params[1].type = VIR_TYPED_PARAM_ULLONG;
- if (virStrcpyStatic(params[1].field, "vcpu_period") == NULL) {
+ if (virStrcpyStatic(params[1].field,
+ VIR_DOMAIN_SCHEDULER_VCPU_PERIOD) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("Field name '%s' too long"),
- "vcpu_period");
+ VIR_DOMAIN_SCHEDULER_VCPU_PERIOD);
goto cleanup;
}
saved_nparams++;
if (*nparams > saved_nparams) {
params[2].value.ul = quota;
params[2].type = VIR_TYPED_PARAM_LLONG;
- if (virStrcpyStatic(params[2].field, "vcpu_quota") == NULL) {
+ if (virStrcpyStatic(params[2].field,
+ VIR_DOMAIN_SCHEDULER_VCPU_QUOTA) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("Field name '%s' too long"),
- "vcpu_quota");
+ VIR_DOMAIN_SCHEDULER_VCPU_QUOTA);
goto cleanup;
}
saved_nparams++;
testError(VIR_ERR_INVALID_ARG, "%s", _("Invalid parameter count"));
goto cleanup;
}
- strcpy(params[0].field, "weight");
+ strcpy(params[0].field, VIR_DOMAIN_SCHEDULER_WEIGHT);
params[0].type = VIR_TYPED_PARAM_UINT;
/* XXX */
/*params[0].value.ui = privdom->weight;*/
}
for (i = 0; i < nparams; i++) {
- if (STRNEQ(params[i].field, "weight")) {
+ if (STRNEQ(params[i].field, VIR_DOMAIN_SCHEDULER_WEIGHT)) {
testError(VIR_ERR_INVALID_ARG, "field");
goto cleanup;
}
return schedulertype;
}
-static const char *str_weight = "weight";
-static const char *str_cap = "cap";
-
/**
* xenHypervisorGetSchedulerParameters:
* @domain: pointer to the Xen Hypervisor block
if (ret < 0)
return(-1);
- if (virStrcpyStatic(params[0].field, str_weight) == NULL) {
+ if (virStrcpyStatic(params[0].field,
+ VIR_DOMAIN_SCHEDULER_WEIGHT) == NULL) {
virXenError(VIR_ERR_INTERNAL_ERROR,
- "Weight %s too big for destination", str_weight);
+ "Weight %s too big for destination",
+ VIR_DOMAIN_SCHEDULER_WEIGHT);
return -1;
}
params[0].type = VIR_TYPED_PARAM_UINT;
params[0].value.ui = op_dom.u.getschedinfo.u.credit.weight;
- if (virStrcpyStatic(params[1].field, str_cap) == NULL) {
+ if (virStrcpyStatic(params[1].field,
+ VIR_DOMAIN_SCHEDULER_CAP) == NULL) {
virXenError(VIR_ERR_INTERNAL_ERROR,
- "Cap %s too big for destination", str_cap);
+ "Cap %s too big for destination",
+ VIR_DOMAIN_SCHEDULER_CAP);
return -1;
}
params[1].type = VIR_TYPED_PARAM_UINT;
for (i = 0; i < nparams; i++) {
memset(&buf, 0, sizeof(buf));
- if (STREQ (params[i].field, str_weight) &&
+ if (STREQ (params[i].field, VIR_DOMAIN_SCHEDULER_WEIGHT) &&
params[i].type == VIR_TYPED_PARAM_UINT) {
val = params[i].value.ui;
if ((val < 1) || (val > USHRT_MAX)) {
return(-1);
}
op_dom.u.getschedinfo.u.credit.weight = val;
- } else if (STREQ (params[i].field, str_cap) &&
+ } else if (STREQ (params[i].field, VIR_DOMAIN_SCHEDULER_CAP) &&
params[i].type == VIR_TYPED_PARAM_UINT) {
val = params[i].value.ui;
if (val >= USHRT_MAX) {
}
-static const char *str_weight = "weight";
-static const char *str_cap = "cap";
-
/**
* xenDaemonGetSchedulerParameters:
* @domain: pointer to the Domain block
goto error;
}
- if (virStrcpyStatic(params[0].field, str_weight) == NULL) {
+ if (virStrcpyStatic(params[0].field,
+ VIR_DOMAIN_SCHEDULER_WEIGHT) == NULL) {
virXendError(VIR_ERR_INTERNAL_ERROR,
_("Weight %s too big for destination"),
- str_weight);
+ VIR_DOMAIN_SCHEDULER_WEIGHT);
goto error;
}
params[0].type = VIR_TYPED_PARAM_UINT;
params[0].value.ui = sexpr_int(root, "domain/cpu_weight");
- if (virStrcpyStatic(params[1].field, str_cap) == NULL) {
+ if (virStrcpyStatic(params[1].field,
+ VIR_DOMAIN_SCHEDULER_CAP) == NULL) {
virXendError(VIR_ERR_INTERNAL_ERROR,
- _("Cap %s too big for destination"), str_cap);
+ _("Cap %s too big for destination"),
+ VIR_DOMAIN_SCHEDULER_CAP);
goto error;
}
params[1].type = VIR_TYPED_PARAM_UINT;
memset(&buf_weight, 0, VIR_UUID_BUFLEN);
memset(&buf_cap, 0, VIR_UUID_BUFLEN);
for (i = 0; i < nparams; i++) {
- if (STREQ (params[i].field, str_weight) &&
+ if (STREQ (params[i].field, VIR_DOMAIN_SCHEDULER_WEIGHT) &&
params[i].type == VIR_TYPED_PARAM_UINT) {
snprintf(buf_weight, sizeof(buf_weight), "%u", params[i].value.ui);
- } else if (STREQ (params[i].field, str_cap) &&
+ } else if (STREQ (params[i].field, VIR_DOMAIN_SCHEDULER_CAP) &&
params[i].type == VIR_TYPED_PARAM_UINT) {
snprintf(buf_cap, sizeof(buf_cap), "%u", params[i].value.ui);
} else {