Always report an error if virBitmapFormat fails

It already reports an error if STRDUP fails.
This commit is contained in:
Ján Tomko 2014-06-05 11:24:24 +02:00
parent cd09ab4db0
commit d4edce5f1e
7 changed files with 14 additions and 49 deletions

View File

@ -791,10 +791,8 @@ virCapabilitiesFormatNUMATopology(virBufferPtr buf,
virBufferAsprintf(buf, "<cpu id='%d'", cells[i]->cpus[j].id);
if (cells[i]->cpus[j].siblings) {
if (!(siblings = virBitmapFormat(cells[i]->cpus[j].siblings))) {
virReportOOMError();
if (!(siblings = virBitmapFormat(cells[i]->cpus[j].siblings)))
return -1;
}
virBufferAsprintf(buf,
" socket_id='%d' core_id='%d' siblings='%s'",

View File

@ -17363,11 +17363,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAsprintf(buf, "<vcpupin vcpu='%u' ",
def->cputune.vcpupin[i]->vcpuid);
if (!(cpumask = virBitmapFormat(def->cputune.vcpupin[i]->cpumask))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to format cpuset for vcpupin"));
if (!(cpumask = virBitmapFormat(def->cputune.vcpupin[i]->cpumask)))
goto error;
}
virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
VIR_FREE(cpumask);
@ -17377,11 +17374,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
char *cpumask;
virBufferAddLit(buf, "<emulatorpin ");
if (!(cpumask = virBitmapFormat(def->cputune.emulatorpin->cpumask))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to format cpuset for emulator"));
goto error;
}
if (!(cpumask = virBitmapFormat(def->cputune.emulatorpin->cpumask)))
goto error;
virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
VIR_FREE(cpumask);
@ -17407,13 +17401,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (def->numatune.memory.placement_mode ==
VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC) {
nodemask = virBitmapFormat(def->numatune.memory.nodemask);
if (nodemask == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to format nodeset for "
"NUMA memory tuning"));
if (!(nodemask = virBitmapFormat(def->numatune.memory.nodemask)))
goto error;
}
virBufferAsprintf(buf, "nodeset='%s'/>\n", nodemask);
VIR_FREE(nodemask);
} else if (def->numatune.memory.placement_mode) {

View File

@ -2851,7 +2851,7 @@ virNetworkObjFormat(virNetworkObjPtr net,
size_t i;
if (!class_id)
goto no_memory;
goto error;
virBufferAddLit(&buf, "<networkstatus>\n");
virBufferAdjustIndent(&buf, 2);

View File

@ -72,12 +72,8 @@ static int virLXCCgroupSetupCpusetTune(virDomainDefPtr def,
if (def->placement_mode != VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
def->cpumask) {
mask = virBitmapFormat(def->cpumask);
if (!mask) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to convert cpumask"));
if (!(mask = virBitmapFormat(def->cpumask)))
return -1;
}
if (virCgroupSetCpusetCpus(cgroup, mask) < 0)
goto cleanup;
@ -93,11 +89,8 @@ static int virLXCCgroupSetupCpusetTune(virDomainDefPtr def,
else
mask = virBitmapFormat(def->numatune.memory.nodemask);
if (!mask) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to convert memory nodemask"));
if (!mask)
return -1;
}
if (virCgroupSetCpusetMems(cgroup, mask) < 0)
goto cleanup;

View File

@ -599,11 +599,8 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm,
else
mem_mask = virBitmapFormat(vm->def->numatune.memory.nodemask);
if (!mem_mask) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to convert memory nodemask"));
if (!mem_mask)
goto cleanup;
}
if (virCgroupSetCpusetMems(priv->cgroup, mem_mask) < 0)
goto cleanup;
@ -622,11 +619,8 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm,
cpu_mask = virBitmapFormat(vm->def->cpumask);
}
if (!cpu_mask) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to convert cpu mask"));
if (!cpu_mask)
goto cleanup;
}
if (virCgroupSetCpusetCpus(priv->cgroup, cpu_mask) < 0)
goto cleanup;
@ -870,12 +864,8 @@ qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup,
int ret = -1;
char *new_cpus = NULL;
new_cpus = virBitmapFormat(cpumask);
if (!new_cpus) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to convert cpu mask"));
if (!(new_cpus = virBitmapFormat(cpumask)))
goto cleanup;
}
if (virCgroupSetCpusetCpus(cgroup, new_cpus) < 0)
goto cleanup;

View File

@ -8679,22 +8679,16 @@ qemuDomainSetNumaParamsLive(virDomainObjPtr vm,
}
}
if (!(nodeset_str = virBitmapFormat(temp_nodeset))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to format nodeset"));
if (!(nodeset_str = virBitmapFormat(temp_nodeset)))
goto cleanup;
}
if (virCgroupSetCpusetMems(priv->cgroup, nodeset_str) < 0)
goto cleanup;
VIR_FREE(nodeset_str);
/* Ensure the cpuset string is formatted before passing to cgroup */
if (!(nodeset_str = virBitmapFormat(nodeset))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to format nodeset"));
if (!(nodeset_str = virBitmapFormat(nodeset)))
goto cleanup;
}
for (i = 0; i < priv->nvcpupids; i++) {
if (virCgroupNewVcpu(priv->cgroup, i, false, &cgroup_temp) < 0 ||

View File

@ -261,6 +261,7 @@ char *virBitmapFormat(virBitmapPtr bitmap)
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
return NULL;
}