[libvirt] [PATCH] virtportallocator: Change number of ports to 65536

Pavel Hrdina posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/650d7eda3fbf185cecabdbfd6d3d196927587ad3.1528960954.git.phrdina@redhat.com
Test syntax-check failed
src/util/virportallocator.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[libvirt] [PATCH] virtportallocator: Change number of ports to 65536
Posted by Pavel Hrdina 5 years, 10 months ago
USHRT_MAX is not good enough because the value is 65535 which specifies
the number of bits in bitmap.  The allowed port range is 0-65535 so we
need to increase the number.

We could have USHRT_MAX + 1 but let's define the number explicitly.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/util/virportallocator.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c
index 004a2dab81..db95a601c7 100644
--- a/src/util/virportallocator.c
+++ b/src/util/virportallocator.c
@@ -35,6 +35,8 @@
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
+#define VIR_PORT_ALLOCATOR_NUM_PORTS 65536
+
 typedef struct _virPortAllocator virPortAllocator;
 typedef virPortAllocator *virPortAllocatorPtr;
 struct _virPortAllocator {
@@ -68,7 +70,7 @@ virPortAllocatorNew(void)
     if (!(pa = virObjectLockableNew(virPortAllocatorClass)))
         return NULL;
 
-    if (!(pa->bitmap = virBitmapNew(USHRT_MAX)))
+    if (!(pa->bitmap = virBitmapNew(VIR_PORT_ALLOCATOR_NUM_PORTS)))
         goto error;
 
     return pa;
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virtportallocator: Change number of ports to 65536
Posted by Ján Tomko 5 years, 10 months ago
On Thu, Jun 14, 2018 at 09:31:55AM +0200, Pavel Hrdina wrote:
>USHRT_MAX is not good enough because the value is 65535 which specifies
>the number of bits in bitmap.  The allowed port range is 0-65535 so we
>need to increase the number.
>
>We could have USHRT_MAX + 1 but let's define the number explicitly.
>
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1590214
>
>Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>---
> src/util/virportallocator.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list