goto cleanup;
}
- if ((*nparams) != QEMU_NB_BLKIO_PARAM) {
- qemuReportError(VIR_ERR_INVALID_ARG,
- "%s", _("Invalid parameter count"));
- goto cleanup;
- }
-
isActive = virDomainObjIsActive(vm);
if (flags == VIR_DOMAIN_AFFECT_CURRENT) {
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
- for (i = 0; i < *nparams; i++) {
+ for (i = 0; i < *nparams && i < QEMU_NB_BLKIO_PARAM; i++) {
virTypedParameterPtr param = ¶ms[i];
val = 0;
param->value.ui = 0;
}
if (virStrcpyStatic(param->field, VIR_DOMAIN_BLKIO_WEIGHT) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field blkio weight too long for destination"));
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_BLKIO_WEIGHT);
goto cleanup;
}
param->value.ui = val;
}
}
} else if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- for (i = 0; i < *nparams; i++) {
+ for (i = 0; i < *nparams && i < QEMU_NB_BLKIO_PARAM; i++) {
virTypedParameterPtr param = ¶ms[i];
val = 0;
param->value.ui = 0;
case 0: /* fill blkio weight here */
if (virStrcpyStatic(param->field, VIR_DOMAIN_BLKIO_WEIGHT) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field blkio weight too long for destination"));
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_BLKIO_WEIGHT);
goto cleanup;
}
param->value.ui = persistentDef->blkio.weight;
}
}
+ if (QEMU_NB_BLKIO_PARAM < *nparams)
+ *nparams = QEMU_NB_BLKIO_PARAM;
ret = 0;
cleanup:
goto cleanup;
}
- if ((*nparams) < QEMU_NB_MEM_PARAM) {
- qemuReportError(VIR_ERR_INVALID_ARG,
- "%s", _("Invalid parameter count"));
- goto cleanup;
- }
-
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- for (i = 0; i < *nparams; i++) {
+ for (i = 0; i < *nparams && i < QEMU_NB_MEM_PARAM; i++) {
virMemoryParameterPtr param = ¶ms[i];
val = 0;
param->value.ul = 0;
case 0: /* fill memory hard limit here */
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_HARD_LIMIT) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field memory hard limit too long for destination"));
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_MEMORY_HARD_LIMIT);
goto cleanup;
}
param->value.ul = persistentDef->mem.hard_limit;
case 1: /* fill memory soft limit here */
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field memory soft limit too long for destination"));
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_MEMORY_SOFT_LIMIT);
goto cleanup;
}
param->value.ul = persistentDef->mem.soft_limit;
case 2: /* fill swap hard limit here */
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field swap hard limit too long for destination"));
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT);
goto cleanup;
}
param->value.ul = persistentDef->mem.swap_hard_limit;
goto out;
}
- for (i = 0; i < QEMU_NB_MEM_PARAM; i++) {
+ for (i = 0; i < *nparams && i < QEMU_NB_MEM_PARAM; i++) {
virTypedParameterPtr param = ¶ms[i];
val = 0;
param->value.ul = 0;
}
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_HARD_LIMIT) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field memory hard limit too long for destination"));
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_MEMORY_HARD_LIMIT);
goto cleanup;
}
param->value.ul = val;
}
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field memory soft limit too long for destination"));
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_MEMORY_SOFT_LIMIT);
goto cleanup;
}
param->value.ul = val;
}
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT) == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field swap hard limit too long for destination"));
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT);
goto cleanup;
}
param->value.ul = val;
}
out:
- *nparams = QEMU_NB_MEM_PARAM;
+ if (QEMU_NB_MEM_PARAM < *nparams)
+ *nparams = QEMU_NB_MEM_PARAM;
ret = 0;
cleanup:
goto cleanup;
}
- if (*nparams < 1) {
- qemuReportError(VIR_ERR_INVALID_ARG,
- "%s", _("Invalid parameter count"));
- goto cleanup;
- }
-
if (*nparams > 1) {
rc = qemuGetCpuBWStatus(driver->cgroup);
if (rc < 0)
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) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field cpu_shares too long for destination"));
+ _("Field name '%s' too long"),
+ "cpu_shares");
goto cleanup;
}
params[1].type = VIR_TYPED_PARAM_ULLONG;
if (virStrcpyStatic(params[1].field, "vcpu_period") == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s",
- _("Field vcpu_period too long for destination"));
+ _("Field name '%s' too long"),
+ "vcpu_period");
goto cleanup;
}
saved_nparams++;
params[2].type = VIR_TYPED_PARAM_LLONG;
if (virStrcpyStatic(params[2].field, "vcpu_quota") == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s",
- _("Field vcpu_quota too long for destination"));
+ _("Field name '%s' too long"),
+ "vcpu_quota");
goto cleanup;
}
saved_nparams++;
* not supported we detect this and return the appropriate error.
*/
static int
-qemudDomainBlockStats (virDomainPtr dom,
- const char *path,
- struct _virDomainBlockStats *stats)
+qemuDomainBlockStats(virDomainPtr dom,
+ const char *path,
+ struct _virDomainBlockStats *stats)
{
struct qemud_driver *driver = dom->conn->privateData;
int i, ret = -1;
}
static int
-qemudDomainBlockStatsFlags (virDomainPtr dom,
- const char *path,
- virTypedParameterPtr params,
- int *nparams,
- unsigned int flags)
+qemuDomainBlockStatsFlags(virDomainPtr dom,
+ const char *path,
+ virTypedParameterPtr params,
+ int *nparams,
+ unsigned int flags)
{
struct qemud_driver *driver = dom->conn->privateData;
int i, tmp, ret = -1;
qemuDomainObjPrivatePtr priv;
long long rd_req, rd_bytes, wr_req, wr_bytes, rd_total_times;
long long wr_total_times, flush_req, flush_total_times, errs;
+ virTypedParameterPtr param;
virCheckFlags(0, -1);
if (!disk->info.alias) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- _("missing disk device alias name for %s"), disk->dst);
+ _("missing disk device alias name for %s"),
+ disk->dst);
goto cleanup;
}
}
tmp = *nparams;
ret = qemuMonitorGetBlockStatsParamsNumber(priv->mon, nparams);
- if (tmp == 0) {
+ if (tmp == 0 || ret < 0) {
qemuDomainObjExitMonitor(driver, vm);
goto endjob;
}
if (ret < 0)
goto endjob;
- /* Field 'errs' is meaningless for QEMU, won't set it. */
- for (i = 0; i < *nparams; i++) {
- virTypedParameterPtr param = ¶ms[i];
-
- switch (i) {
- case 0: /* fill write_bytes here */
- if (virStrcpyStatic(param->field, VIR_DOMAIN_BLOCK_STATS_WRITE_BYTES) == NULL) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field write bytes too long for destination"));
- goto endjob;
- }
- param->type = VIR_TYPED_PARAM_LLONG;
- param->value.l = wr_bytes;
- break;
+ tmp = 0;
+ ret = -1;
- case 1: /* fill wr_operations here */
- if (virStrcpyStatic(param->field, VIR_DOMAIN_BLOCK_STATS_WRITE_REQ) == NULL) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field write requests too long for destination"));
- goto endjob;
- }
- param->type = VIR_TYPED_PARAM_LLONG;
- param->value.l = wr_req;
- break;
+ if (tmp < *nparams && wr_bytes != -1) {
+ param = ¶ms[tmp];
+ if (virStrcpyStatic(param->field,
+ VIR_DOMAIN_BLOCK_STATS_WRITE_BYTES) == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_BLOCK_STATS_WRITE_BYTES);
+ goto endjob;
+ }
+ param->type = VIR_TYPED_PARAM_LLONG;
+ param->value.l = wr_bytes;
+ tmp++;
+ }
- case 2: /* fill read_bytes here */
- if (virStrcpyStatic(param->field, VIR_DOMAIN_BLOCK_STATS_READ_BYTES) == NULL) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field read bytes too long for destination"));
- goto endjob;
- }
- param->type = VIR_TYPED_PARAM_LLONG;
- param->value.l = rd_bytes;
- break;
+ if (tmp < *nparams && wr_req != -1) {
+ if (virStrcpyStatic(param->field,
+ VIR_DOMAIN_BLOCK_STATS_WRITE_REQ) == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_BLOCK_STATS_WRITE_REQ);
+ goto endjob;
+ }
+ param->type = VIR_TYPED_PARAM_LLONG;
+ param->value.l = wr_req;
+ tmp++;
+ }
- case 3: /* fill rd_operations here */
- if (virStrcpyStatic(param->field, VIR_DOMAIN_BLOCK_STATS_READ_REQ) == NULL) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field read requests too long for destination"));
- goto endjob;
- }
- param->type = VIR_TYPED_PARAM_LLONG;
- param->value.l = rd_req;
- break;
+ if (tmp < *nparams && rd_bytes != -1) {
+ if (virStrcpyStatic(param->field,
+ VIR_DOMAIN_BLOCK_STATS_READ_BYTES) == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_BLOCK_STATS_READ_BYTES);
+ goto endjob;
+ }
+ param->type = VIR_TYPED_PARAM_LLONG;
+ param->value.l = rd_bytes;
+ tmp++;
+ }
- case 4: /* fill flush_operations here */
- if (virStrcpyStatic(param->field, VIR_DOMAIN_BLOCK_STATS_FLUSH_REQ) == NULL) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field flush requests too long for destination"));
- goto endjob;
- }
- param->type = VIR_TYPED_PARAM_LLONG;
- param->value.l = flush_req;
- break;
+ if (tmp < *nparams && rd_req != -1) {
+ if (virStrcpyStatic(param->field,
+ VIR_DOMAIN_BLOCK_STATS_READ_REQ) == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_BLOCK_STATS_READ_REQ);
+ goto endjob;
+ }
+ param->type = VIR_TYPED_PARAM_LLONG;
+ param->value.l = rd_req;
+ tmp++;
+ }
- case 5: /* fill wr_total_times_ns here */
- if (virStrcpyStatic(param->field, VIR_DOMAIN_BLOCK_STATS_WRITE_TOTAL_TIMES) == NULL) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field write total times too long for destination"));
- goto endjob;
- }
- param->type = VIR_TYPED_PARAM_LLONG;
- param->value.l = wr_total_times;
- break;
+ if (tmp < *nparams && flush_req != -1) {
+ if (virStrcpyStatic(param->field,
+ VIR_DOMAIN_BLOCK_STATS_FLUSH_REQ) == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_BLOCK_STATS_FLUSH_REQ);
+ goto endjob;
+ }
+ param->type = VIR_TYPED_PARAM_LLONG;
+ param->value.l = flush_req;
+ tmp++;
+ }
- case 6: /* fill rd_total_times_ns here */
- if (virStrcpyStatic(param->field, VIR_DOMAIN_BLOCK_STATS_READ_TOTAL_TIMES) == NULL) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field read total times too long for destination"));
- goto endjob;
- }
- param->type = VIR_TYPED_PARAM_LLONG;
- param->value.l = rd_total_times;
- break;
+ if (tmp < *nparams && wr_total_times != -1) {
+ if (virStrcpyStatic(param->field,
+ VIR_DOMAIN_BLOCK_STATS_WRITE_TOTAL_TIMES) == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_BLOCK_STATS_WRITE_TOTAL_TIMES);
+ goto endjob;
+ }
+ param->type = VIR_TYPED_PARAM_LLONG;
+ param->value.l = wr_total_times;
+ tmp++;
+ }
- case 7: /* fill flush_total_times_ns here */
- if (virStrcpyStatic(param->field, VIR_DOMAIN_BLOCK_STATS_READ_TOTAL_TIMES) == NULL) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Field flush total times too long for destination"));
- goto endjob;
- }
- param->type = VIR_TYPED_PARAM_LLONG;
- param->value.l = flush_total_times;
- break;
+ if (tmp < *nparams && rd_total_times != -1) {
+ if (virStrcpyStatic(param->field,
+ VIR_DOMAIN_BLOCK_STATS_READ_TOTAL_TIMES) == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_BLOCK_STATS_READ_TOTAL_TIMES);
+ goto endjob;
+ }
+ param->type = VIR_TYPED_PARAM_LLONG;
+ param->value.l = rd_total_times;
+ tmp++;
+ }
- default:
- break;
- /* should not hit here */
+ if (tmp < *nparams && flush_total_times != -1) {
+ if (virStrcpyStatic(param->field,
+ VIR_DOMAIN_BLOCK_STATS_READ_TOTAL_TIMES) == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Field name '%s' too long"),
+ VIR_DOMAIN_BLOCK_STATS_READ_TOTAL_TIMES);
+ goto endjob;
}
+ param->type = VIR_TYPED_PARAM_LLONG;
+ param->value.l = flush_total_times;
+ tmp++;
}
+ /* Field 'errs' is meaningless for QEMU, won't set it. */
+
+ ret = 0;
+ *nparams = tmp;
+
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
vm = NULL;
.domainSetSchedulerParameters = qemuSetSchedulerParameters, /* 0.7.0 */
.domainSetSchedulerParametersFlags = qemuSetSchedulerParametersFlags, /* 0.9.2 */
.domainMigratePerform = qemudDomainMigratePerform, /* 0.5.0 */
- .domainBlockStats = qemudDomainBlockStats, /* 0.4.1 */
- .domainBlockStatsFlags = qemudDomainBlockStatsFlags, /* 0.9.5 */
+ .domainBlockStats = qemuDomainBlockStats, /* 0.4.1 */
+ .domainBlockStatsFlags = qemuDomainBlockStatsFlags, /* 0.9.5 */
.domainInterfaceStats = qemudDomainInterfaceStats, /* 0.4.1 */
.domainMemoryStats = qemudDomainMemoryStats, /* 0.7.5 */
.domainBlockPeek = qemudDomainBlockPeek, /* 0.4.4 */