qemu: Remove virDomainLiveConfigHelperMethod from qemuDomainGetBlkioParameters

This commit is contained in:
Peter Krempa 2016-05-25 09:11:52 +02:00
parent b30387732a
commit 31b4d75877

View File

@ -9089,10 +9089,10 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
virQEMUDriverPtr driver = dom->conn->privateData; virQEMUDriverPtr driver = dom->conn->privateData;
size_t i, j; size_t i, j;
virDomainObjPtr vm = NULL; virDomainObjPtr vm = NULL;
virDomainDefPtr def = NULL;
virDomainDefPtr persistentDef = NULL; virDomainDefPtr persistentDef = NULL;
unsigned int val; unsigned int val;
int ret = -1; int ret = -1;
virCapsPtr caps = NULL;
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
@ -9118,9 +9118,6 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
goto cleanup; goto cleanup;
} }
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
if ((*nparams) == 0) { if ((*nparams) == 0) {
/* Current number of blkio parameters supported by cgroups */ /* Current number of blkio parameters supported by cgroups */
*nparams = QEMU_NB_BLKIO_PARAM; *nparams = QEMU_NB_BLKIO_PARAM;
@ -9128,19 +9125,16 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
goto cleanup; goto cleanup;
} }
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
&persistentDef) < 0)
goto cleanup; goto cleanup;
if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (def) {
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)) { if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("blkio cgroup isn't mounted")); _("blkio cgroup isn't mounted"));
goto cleanup; goto cleanup;
} }
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
for (i = 0; i < *nparams && i < QEMU_NB_BLKIO_PARAM; i++) { for (i = 0; i < *nparams && i < QEMU_NB_BLKIO_PARAM; i++) {
virTypedParameterPtr param = &params[i]; virTypedParameterPtr param = &params[i];
val = 0; val = 0;
@ -9155,20 +9149,20 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
break; break;
case 1: /* blkiotune.device_weight */ case 1: /* blkiotune.device_weight */
if (vm->def->blkio.ndevices > 0) { if (def->blkio.ndevices > 0) {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
bool comma = false; bool comma = false;
for (j = 0; j < vm->def->blkio.ndevices; j++) { for (j = 0; j < def->blkio.ndevices; j++) {
if (!vm->def->blkio.devices[j].weight) if (!def->blkio.devices[j].weight)
continue; continue;
if (comma) if (comma)
virBufferAddChar(&buf, ','); virBufferAddChar(&buf, ',');
else else
comma = true; comma = true;
virBufferAsprintf(&buf, "%s,%u", virBufferAsprintf(&buf, "%s,%u",
vm->def->blkio.devices[j].path, def->blkio.devices[j].path,
vm->def->blkio.devices[j].weight); def->blkio.devices[j].weight);
} }
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto cleanup; goto cleanup;
@ -9182,20 +9176,20 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
break; break;
case 2: /* blkiotune.device_read_iops */ case 2: /* blkiotune.device_read_iops */
if (vm->def->blkio.ndevices > 0) { if (def->blkio.ndevices > 0) {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
bool comma = false; bool comma = false;
for (j = 0; j < vm->def->blkio.ndevices; j++) { for (j = 0; j < def->blkio.ndevices; j++) {
if (!vm->def->blkio.devices[j].riops) if (!def->blkio.devices[j].riops)
continue; continue;
if (comma) if (comma)
virBufferAddChar(&buf, ','); virBufferAddChar(&buf, ',');
else else
comma = true; comma = true;
virBufferAsprintf(&buf, "%s,%u", virBufferAsprintf(&buf, "%s,%u",
vm->def->blkio.devices[j].path, def->blkio.devices[j].path,
vm->def->blkio.devices[j].riops); def->blkio.devices[j].riops);
} }
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto cleanup; goto cleanup;
@ -9209,20 +9203,20 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
break; break;
case 3: /* blkiotune.device_write_iops */ case 3: /* blkiotune.device_write_iops */
if (vm->def->blkio.ndevices > 0) { if (def->blkio.ndevices > 0) {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
bool comma = false; bool comma = false;
for (j = 0; j < vm->def->blkio.ndevices; j++) { for (j = 0; j < def->blkio.ndevices; j++) {
if (!vm->def->blkio.devices[j].wiops) if (!def->blkio.devices[j].wiops)
continue; continue;
if (comma) if (comma)
virBufferAddChar(&buf, ','); virBufferAddChar(&buf, ',');
else else
comma = true; comma = true;
virBufferAsprintf(&buf, "%s,%u", virBufferAsprintf(&buf, "%s,%u",
vm->def->blkio.devices[j].path, def->blkio.devices[j].path,
vm->def->blkio.devices[j].wiops); def->blkio.devices[j].wiops);
} }
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto cleanup; goto cleanup;
@ -9236,20 +9230,20 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
break; break;
case 4: /* blkiotune.device_read_bps */ case 4: /* blkiotune.device_read_bps */
if (vm->def->blkio.ndevices > 0) { if (def->blkio.ndevices > 0) {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
bool comma = false; bool comma = false;
for (j = 0; j < vm->def->blkio.ndevices; j++) { for (j = 0; j < def->blkio.ndevices; j++) {
if (!vm->def->blkio.devices[j].rbps) if (!def->blkio.devices[j].rbps)
continue; continue;
if (comma) if (comma)
virBufferAddChar(&buf, ','); virBufferAddChar(&buf, ',');
else else
comma = true; comma = true;
virBufferAsprintf(&buf, "%s,%llu", virBufferAsprintf(&buf, "%s,%llu",
vm->def->blkio.devices[j].path, def->blkio.devices[j].path,
vm->def->blkio.devices[j].rbps); def->blkio.devices[j].rbps);
} }
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto cleanup; goto cleanup;
@ -9263,20 +9257,20 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
break; break;
case 5: /* blkiotune.device_write_bps */ case 5: /* blkiotune.device_write_bps */
if (vm->def->blkio.ndevices > 0) { if (def->blkio.ndevices > 0) {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
bool comma = false; bool comma = false;
for (j = 0; j < vm->def->blkio.ndevices; j++) { for (j = 0; j < def->blkio.ndevices; j++) {
if (!vm->def->blkio.devices[j].wbps) if (!def->blkio.devices[j].wbps)
continue; continue;
if (comma) if (comma)
virBufferAddChar(&buf, ','); virBufferAddChar(&buf, ',');
else else
comma = true; comma = true;
virBufferAsprintf(&buf, "%s,%llu", virBufferAsprintf(&buf, "%s,%llu",
vm->def->blkio.devices[j].path, def->blkio.devices[j].path,
vm->def->blkio.devices[j].wbps); def->blkio.devices[j].wbps);
} }
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto cleanup; goto cleanup;
@ -9295,7 +9289,7 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
/* should not hit here */ /* should not hit here */
} }
} }
} else if (flags & VIR_DOMAIN_AFFECT_CONFIG) { } else if (persistentDef) {
for (i = 0; i < *nparams && i < QEMU_NB_BLKIO_PARAM; i++) { for (i = 0; i < *nparams && i < QEMU_NB_BLKIO_PARAM; i++) {
virTypedParameterPtr param = &params[i]; virTypedParameterPtr param = &params[i];
val = 0; val = 0;
@ -9486,7 +9480,6 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
cleanup: cleanup:
virDomainObjEndAPI(&vm); virDomainObjEndAPI(&vm);
virObjectUnref(caps);
return ret; return ret;
} }