@SRCDIR@/src/hyperv/hyperv_driver.c
@SRCDIR@/src/hyperv/hyperv_util.c
@SRCDIR@/src/hyperv/hyperv_wmi.c
+@SRCDIR@/src/hypervisor/domain_cgroup.c
@SRCDIR@/src/hypervisor/domain_driver.c
@SRCDIR@/src/interface/interface_backend_netcf.c
@SRCDIR@/src/interface/interface_backend_udev.c
#include <config.h>
#include "domain_cgroup.h"
+#include "domain_driver.h"
+
+#define VIR_FROM_THIS VIR_FROM_DOMAIN
int
return 0;
}
+
+
+int
+virDomainCgroupSetupDomainBlkioParameters(virCgroupPtr cgroup,
+ virDomainDefPtr def,
+ virTypedParameterPtr params,
+ int nparams)
+{
+ size_t i;
+ int ret = 0;
+
+ for (i = 0; i < nparams; i++) {
+ virTypedParameterPtr param = ¶ms[i];
+
+ if (STREQ(param->field, VIR_DOMAIN_BLKIO_WEIGHT)) {
+ if (virCgroupSetBlkioWeight(cgroup, params[i].value.ui) < 0)
+ ret = -1;
+ } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT) ||
+ STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS) ||
+ STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS) ||
+ STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS) ||
+ STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
+ size_t ndevices;
+ virBlkioDevicePtr devices = NULL;
+ size_t j;
+
+ if (virDomainDriverParseBlkioDeviceStr(params[i].value.s,
+ param->field,
+ &devices,
+ &ndevices) < 0) {
+ ret = -1;
+ continue;
+ }
+
+ if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
+ for (j = 0; j < ndevices; j++) {
+ if (virCgroupSetupBlkioDeviceWeight(cgroup, devices[j].path,
+ &devices[j].weight) < 0) {
+ ret = -1;
+ break;
+ }
+ }
+ } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
+ for (j = 0; j < ndevices; j++) {
+ if (virCgroupSetupBlkioDeviceReadIops(cgroup, devices[j].path,
+ &devices[j].riops) < 0) {
+ ret = -1;
+ break;
+ }
+ }
+ } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
+ for (j = 0; j < ndevices; j++) {
+ if (virCgroupSetupBlkioDeviceWriteIops(cgroup, devices[j].path,
+ &devices[j].wiops) < 0) {
+ ret = -1;
+ break;
+ }
+ }
+ } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
+ for (j = 0; j < ndevices; j++) {
+ if (virCgroupSetupBlkioDeviceReadBps(cgroup, devices[j].path,
+ &devices[j].rbps) < 0) {
+ ret = -1;
+ break;
+ }
+ }
+ } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
+ for (j = 0; j < ndevices; j++) {
+ if (virCgroupSetupBlkioDeviceWriteBps(cgroup, devices[j].path,
+ &devices[j].wbps) < 0) {
+ ret = -1;
+ break;
+ }
+ }
+ } else {
+ virReportError(VIR_ERR_INVALID_ARG, _("Unknown blkio parameter %s"),
+ param->field);
+ ret = -1;
+ virBlkioDeviceArrayClear(devices, ndevices);
+ g_free(devices);
+
+ continue;
+ }
+
+ if (j != ndevices ||
+ virDomainDriverMergeBlkioDevice(&def->blkio.devices,
+ &def->blkio.ndevices,
+ devices, ndevices,
+ param->field) < 0)
+ ret = -1;
+
+ virBlkioDeviceArrayClear(devices, ndevices);
+ g_free(devices);
+ }
+ }
+
+ return ret;
+}
int virDomainCgroupSetupBlkio(virCgroupPtr cgroup, virDomainBlkiotune blkio);
int virDomainCgroupSetupMemtune(virCgroupPtr cgroup, virDomainMemtune mem);
+int virDomainCgroupSetupDomainBlkioParameters(virCgroupPtr cgroup,
+ virDomainDefPtr def,
+ virTypedParameterPtr params,
+ int nparams);
# hypervisor/domain_cgroup.h
virDomainCgroupSetupBlkio;
+virDomainCgroupSetupDomainBlkioParameters;
virDomainCgroupSetupMemtune;
#include "virpidfile.h"
#include "virfdstream.h"
#include "domain_audit.h"
+#include "domain_cgroup.h"
#include "domain_driver.h"
#include "domain_nwfilter.h"
#include "virinitctl.h"
ret = 0;
if (def) {
- for (i = 0; i < nparams; i++) {
- virTypedParameterPtr param = ¶ms[i];
-
- if (STREQ(param->field, VIR_DOMAIN_BLKIO_WEIGHT)) {
- if (virCgroupSetBlkioWeight(priv->cgroup, params[i].value.ui) < 0)
- ret = -1;
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT) ||
- STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS) ||
- STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS) ||
- STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS) ||
- STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
- virCgroupPtr cgroup = priv->cgroup;
- size_t ndevices;
- virBlkioDevicePtr devices = NULL;
- size_t j;
-
- if (virDomainDriverParseBlkioDeviceStr(params[i].value.s,
- param->field,
- &devices,
- &ndevices) < 0) {
- ret = -1;
- continue;
- }
-
- if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
- for (j = 0; j < ndevices; j++) {
- if (virCgroupSetupBlkioDeviceWeight(cgroup, devices[j].path,
- &devices[j].weight) < 0) {
- ret = -1;
- break;
- }
- }
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
- for (j = 0; j < ndevices; j++) {
- if (virCgroupSetupBlkioDeviceReadIops(cgroup, devices[j].path,
- &devices[j].riops) < 0) {
- ret = -1;
- break;
- }
- }
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
- for (j = 0; j < ndevices; j++) {
- if (virCgroupSetupBlkioDeviceWriteIops(cgroup, devices[j].path,
- &devices[j].wiops) < 0) {
- ret = -1;
- break;
- }
- }
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
- for (j = 0; j < ndevices; j++) {
- if (virCgroupSetupBlkioDeviceReadBps(cgroup, devices[j].path,
- &devices[j].rbps) < 0) {
- ret = -1;
- break;
- }
- }
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
- for (j = 0; j < ndevices; j++) {
- if (virCgroupSetupBlkioDeviceWriteBps(cgroup, devices[j].path,
- &devices[j].wbps) < 0) {
- ret = -1;
- break;
- }
- }
- } else {
- virReportError(VIR_ERR_INVALID_ARG, _("Unknown blkio parameter %s"),
- param->field);
- ret = -1;
- virBlkioDeviceArrayClear(devices, ndevices);
- VIR_FREE(devices);
-
- continue;
- }
-
- if (j != ndevices ||
- virDomainDriverMergeBlkioDevice(&def->blkio.devices,
- &def->blkio.ndevices,
- devices, ndevices,
- param->field) < 0)
- ret = -1;
- virBlkioDeviceArrayClear(devices, ndevices);
- VIR_FREE(devices);
- }
- }
+ ret = virDomainCgroupSetupDomainBlkioParameters(priv->cgroup, def,
+ params, nparams);
}
if (ret < 0)
goto endjob;
#include "viruuid.h"
#include "domain_conf.h"
#include "domain_audit.h"
+#include "domain_cgroup.h"
#include "domain_driver.h"
#include "node_device_conf.h"
#include "virpci.h"
ret = 0;
if (def) {
- for (i = 0; i < nparams; i++) {
- virTypedParameterPtr param = ¶ms[i];
-
- if (STREQ(param->field, VIR_DOMAIN_BLKIO_WEIGHT)) {
- if (virCgroupSetBlkioWeight(priv->cgroup, param->value.ui) < 0 ||
- virCgroupGetBlkioWeight(priv->cgroup, &def->blkio.weight) < 0)
- ret = -1;
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT) ||
- STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS) ||
- STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS) ||
- STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS) ||
- STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
- virCgroupPtr cgroup = priv->cgroup;
- size_t ndevices;
- virBlkioDevicePtr devices = NULL;
- size_t j;
-
- if (virDomainDriverParseBlkioDeviceStr(param->value.s,
- param->field,
- &devices,
- &ndevices) < 0) {
- ret = -1;
- continue;
- }
-
- if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
- for (j = 0; j < ndevices; j++) {
- if (virCgroupSetupBlkioDeviceWeight(cgroup, devices[j].path,
- &devices[j].weight) < 0) {
- ret = -1;
- break;
- }
- }
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
- for (j = 0; j < ndevices; j++) {
- if (virCgroupSetupBlkioDeviceReadIops(cgroup, devices[j].path,
- &devices[j].riops) < 0) {
- ret = -1;
- break;
- }
- }
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
- for (j = 0; j < ndevices; j++) {
- if (virCgroupSetupBlkioDeviceWriteIops(cgroup, devices[j].path,
- &devices[j].wiops) < 0) {
- ret = -1;
- break;
- }
- }
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
- for (j = 0; j < ndevices; j++) {
- if (virCgroupSetupBlkioDeviceReadBps(cgroup, devices[j].path,
- &devices[j].rbps) < 0) {
- ret = -1;
- break;
- }
- }
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
- for (j = 0; j < ndevices; j++) {
- if (virCgroupSetupBlkioDeviceWriteBps(cgroup, devices[j].path,
- &devices[j].wbps) < 0) {
- ret = -1;
- break;
- }
- }
- } else {
- virReportError(VIR_ERR_INVALID_ARG, _("Unknown blkio parameter %s"),
- param->field);
- ret = -1;
- virBlkioDeviceArrayClear(devices, ndevices);
- VIR_FREE(devices);
-
- continue;
- }
-
- if (j != ndevices ||
- virDomainDriverMergeBlkioDevice(&def->blkio.devices,
- &def->blkio.ndevices,
- devices, ndevices,
- param->field) < 0)
- ret = -1;
- virBlkioDeviceArrayClear(devices, ndevices);
- VIR_FREE(devices);
- }
- }
+ ret = virDomainCgroupSetupDomainBlkioParameters(priv->cgroup, def,
+ params, nparams);
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
goto endjob;