mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-28 22:32:19 +00:00
virDomainCputuneDefFormat: Refactor bitmap formatting
Use g_autofree for the temporary variables, remove error checks for virBitmapFormat and simplify formatting of multiple attributes. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5e4262b9ac
commit
a44a48b681
@ -27479,47 +27479,35 @@ virDomainCputuneDefFormat(virBuffer *buf,
|
|||||||
def->cputune.iothread_quota);
|
def->cputune.iothread_quota);
|
||||||
|
|
||||||
for (i = 0; i < def->maxvcpus; i++) {
|
for (i = 0; i < def->maxvcpus; i++) {
|
||||||
char *cpumask;
|
g_autofree char *cpumask = NULL;
|
||||||
virDomainVcpuDef *vcpu = def->vcpus[i];
|
virDomainVcpuDef *vcpu = def->vcpus[i];
|
||||||
|
|
||||||
if (!vcpu->cpumask)
|
if (!vcpu->cpumask)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!(cpumask = virBitmapFormat(vcpu->cpumask)))
|
cpumask = virBitmapFormat(vcpu->cpumask);
|
||||||
return -1;
|
|
||||||
|
|
||||||
virBufferAsprintf(&childrenBuf,
|
virBufferAsprintf(&childrenBuf,
|
||||||
"<vcpupin vcpu='%zu' cpuset='%s'/>\n", i, cpumask);
|
"<vcpupin vcpu='%zu' cpuset='%s'/>\n", i, cpumask);
|
||||||
|
|
||||||
VIR_FREE(cpumask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->cputune.emulatorpin) {
|
if (def->cputune.emulatorpin) {
|
||||||
char *cpumask;
|
g_autofree char *cpumask = virBitmapFormat(def->cputune.emulatorpin);
|
||||||
virBufferAddLit(&childrenBuf, "<emulatorpin ");
|
|
||||||
|
|
||||||
if (!(cpumask = virBitmapFormat(def->cputune.emulatorpin)))
|
virBufferAsprintf(&childrenBuf, "<emulatorpin cpuset='%s'/>\n", cpumask);
|
||||||
return -1;
|
|
||||||
|
|
||||||
virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask);
|
|
||||||
VIR_FREE(cpumask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < def->niothreadids; i++) {
|
for (i = 0; i < def->niothreadids; i++) {
|
||||||
char *cpumask;
|
g_autofree char *cpumask = NULL;
|
||||||
|
|
||||||
/* Ignore iothreadids with no cpumask */
|
/* Ignore iothreadids with no cpumask */
|
||||||
if (!def->iothreadids[i]->cpumask)
|
if (!def->iothreadids[i]->cpumask)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
virBufferAsprintf(&childrenBuf, "<iothreadpin iothread='%u' ",
|
cpumask = virBitmapFormat(def->iothreadids[i]->cpumask);
|
||||||
def->iothreadids[i]->iothread_id);
|
|
||||||
|
|
||||||
if (!(cpumask = virBitmapFormat(def->iothreadids[i]->cpumask)))
|
virBufferAsprintf(&childrenBuf, "<iothreadpin iothread='%u' cpuset='%s'/>\n",
|
||||||
return -1;
|
def->iothreadids[i]->iothread_id, cpumask);
|
||||||
|
|
||||||
virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask);
|
|
||||||
VIR_FREE(cpumask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->cputune.emulatorsched) {
|
if (def->cputune.emulatorsched) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user