}
return -1;
}
+
+
+int
+virDomainDriverSetupPersistentDefBlkioParams(virDomainDefPtr persistentDef,
+ 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)) {
+ persistentDef->blkio.weight = param->value.ui;
+ } 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)) {
+ virBlkioDevicePtr devices = NULL;
+ size_t ndevices;
+
+ if (virDomainDriverParseBlkioDeviceStr(param->value.s,
+ param->field,
+ &devices,
+ &ndevices) < 0) {
+ ret = -1;
+ continue;
+ }
+
+ if (virDomainDriverMergeBlkioDevice(&persistentDef->blkio.devices,
+ &persistentDef->blkio.ndevices,
+ devices, ndevices,
+ param->field) < 0)
+ ret = -1;
+
+ virBlkioDeviceArrayClear(devices, ndevices);
+ g_free(devices);
+ }
+ }
+
+ return ret;
+}
int virDomainDriverParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
virBlkioDevicePtr *dev, size_t *size);
+
+int virDomainDriverSetupPersistentDefBlkioParams(virDomainDefPtr persistentDef,
+ virTypedParameterPtr params,
+ int nparams);
# hypervisor/domain_cgroup.h
virDomainDriverMergeBlkioDevice;
virDomainDriverParseBlkioDeviceStr;
+virDomainDriverSetupPersistentDefBlkioParams;
# libvirt_internal.h
unsigned int flags)
{
virLXCDriverPtr driver = dom->conn->privateData;
- size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr def = NULL;
virDomainDefPtr persistentDef = NULL;
if (ret < 0)
goto endjob;
if (persistentDef) {
- for (i = 0; i < nparams; i++) {
- virTypedParameterPtr param = ¶ms[i];
-
- if (STREQ(param->field, VIR_DOMAIN_BLKIO_WEIGHT)) {
- persistentDef->blkio.weight = params[i].value.ui;
- } 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)) {
- virBlkioDevicePtr devices = NULL;
- size_t ndevices;
-
- if (virDomainDriverParseBlkioDeviceStr(params[i].value.s,
- param->field,
- &devices,
- &ndevices) < 0) {
- ret = -1;
- continue;
- }
- if (virDomainDriverMergeBlkioDevice(&persistentDef->blkio.devices,
- &persistentDef->blkio.ndevices,
- devices, ndevices,
- param->field) < 0)
- ret = -1;
- virBlkioDeviceArrayClear(devices, ndevices);
- VIR_FREE(devices);
- }
- }
+ ret = virDomainDriverSetupPersistentDefBlkioParams(persistentDef,
+ params,
+ nparams);
if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < 0)
ret = -1;
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr def;
virDomainDefPtr persistentDef;
if (ret < 0)
goto endjob;
if (persistentDef) {
- for (i = 0; i < nparams; i++) {
- virTypedParameterPtr param = ¶ms[i];
-
- if (STREQ(param->field, VIR_DOMAIN_BLKIO_WEIGHT)) {
- persistentDef->blkio.weight = param->value.ui;
- } 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)) {
- virBlkioDevicePtr devices = NULL;
- size_t ndevices;
-
- if (virDomainDriverParseBlkioDeviceStr(param->value.s,
- param->field,
- &devices,
- &ndevices) < 0) {
- ret = -1;
- continue;
- }
- if (virDomainDriverMergeBlkioDevice(&persistentDef->blkio.devices,
- &persistentDef->blkio.ndevices,
- devices, ndevices,
- param->field) < 0)
- ret = -1;
- virBlkioDeviceArrayClear(devices, ndevices);
- VIR_FREE(devices);
- }
- }
+ ret = virDomainDriverSetupPersistentDefBlkioParams(persistentDef,
+ params,
+ nparams);
if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < 0)
ret = -1;