1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

virPortAllocatorSetUsed: ignore port 0

Similar to what commit 86dba8f3 did for virPortAllocatorRelease,
ignore port 0 in virPortAllocatorSetUsed.

For all the reasonable use cases the callers already check that
the port is non-zero, however if the port from the XML overflows
unsigned short and turns into 0, it can be set as used by
virPortAllocatorSetUsed but not released by virPortAllocatorRelease.

Also skip port '0' in virPortAllocatorSetUsed to make this behavior
symmetric.

The serenity was disturbed by commit 5dbda5e9 which started using
virPortAllocatorRelease instead of virPortAllocatorSetUsed (false).

https://bugzilla.redhat.com/show_bug.cgi?id=1591645

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Ján Tomko 2019-01-21 15:49:23 +01:00
parent 872b15dea6
commit c2a8256991

View File

@ -294,6 +294,9 @@ virPortAllocatorSetUsed(unsigned short port)
if (!pa)
return -1;
if (!port)
return 0;
virObjectLock(pa);
if (virBitmapIsBitSet(pa->bitmap, port) ||