mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-20 21:19:19 +00:00
qemuDomainFilterHotplugVcpuEntities: Refactor memory freeing to remove 'cleanup' label
After recent refactors the function can be refactored to remove the 'cleanup' label by using autoptr for the 'map' variable. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f12f4e2658
commit
28027f1fb1
@ -6419,13 +6419,10 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
|
|||||||
{
|
{
|
||||||
qemuDomainVcpuPrivatePtr vcpupriv;
|
qemuDomainVcpuPrivatePtr vcpupriv;
|
||||||
virDomainVcpuDefPtr vcpu;
|
virDomainVcpuDefPtr vcpu;
|
||||||
virBitmapPtr map = NULL;
|
g_autoptr(virBitmap) map = virBitmapNewCopy(vcpus);
|
||||||
virBitmapPtr ret = NULL;
|
|
||||||
ssize_t next = -1;
|
ssize_t next = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
map = virBitmapNewCopy(vcpus);
|
|
||||||
|
|
||||||
/* make sure that all selected vcpus are in the correct state */
|
/* make sure that all selected vcpus are in the correct state */
|
||||||
while ((next = virBitmapNextSetBit(map, next)) >= 0) {
|
while ((next = virBitmapNextSetBit(map, next)) >= 0) {
|
||||||
if (!(vcpu = virDomainDefGetVcpu(def, next)))
|
if (!(vcpu = virDomainDefGetVcpu(def, next)))
|
||||||
@ -6434,13 +6431,13 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
|
|||||||
if (vcpu->online == state) {
|
if (vcpu->online == state) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("vcpu '%zd' is already in requested state"), next);
|
_("vcpu '%zd' is already in requested state"), next);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vcpu->online && !vcpu->hotpluggable) {
|
if (vcpu->online && !vcpu->hotpluggable) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("vcpu '%zd' can't be hotunplugged"), next);
|
_("vcpu '%zd' can't be hotunplugged"), next);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6457,7 +6454,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
|
|||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("vcpu '%zd' belongs to a larger hotpluggable entity, "
|
_("vcpu '%zd' belongs to a larger hotpluggable entity, "
|
||||||
"but siblings were not selected"), next);
|
"but siblings were not selected"), next);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = next + 1; i < next + vcpupriv->vcpus; i++) {
|
for (i = next + 1; i < next + vcpupriv->vcpus; i++) {
|
||||||
@ -6467,7 +6464,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
|
|||||||
"hotpluggable entity '%zd-%zd' which was "
|
"hotpluggable entity '%zd-%zd' which was "
|
||||||
"partially selected"),
|
"partially selected"),
|
||||||
i, next, next + vcpupriv->vcpus - 1);
|
i, next, next + vcpupriv->vcpus - 1);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear the subthreads */
|
/* clear the subthreads */
|
||||||
@ -6475,11 +6472,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = g_steal_pointer(&map);
|
return g_steal_pointer(&map);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virBitmapFree(map);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user