if (!(libxl_driver->reservedVNCPorts =
virPortAllocatorNew(_("VNC"),
LIBXL_VNC_PORT_MIN,
- LIBXL_VNC_PORT_MAX)))
+ LIBXL_VNC_PORT_MAX,
+ 0)))
goto error;
/* Allocate bitmap for migration port reservation */
if (!(libxl_driver->migrationPorts =
virPortAllocatorNew(_("migration"),
LIBXL_MIGRATION_PORT_MIN,
- LIBXL_MIGRATION_PORT_MAX)))
+ LIBXL_MIGRATION_PORT_MAX, 0)))
goto error;
if (!(libxl_driver->domains = virDomainObjListNew()))
if ((qemu_driver->remotePorts =
virPortAllocatorNew(_("display"),
cfg->remotePortMin,
- cfg->remotePortMax)) == NULL)
+ cfg->remotePortMax,
+ 0)) == NULL)
goto error;
if ((qemu_driver->webSocketPorts =
virPortAllocatorNew(_("webSocket"),
cfg->webSocketPortMin,
- cfg->webSocketPortMax)) == NULL)
+ cfg->webSocketPortMax,
+ 0)) == NULL)
goto error;
if ((qemu_driver->migrationPorts =
virPortAllocatorNew(_("migration"),
cfg->migrationPortMin,
- cfg->migrationPortMax)) == NULL)
+ cfg->migrationPortMax,
+ 0)) == NULL)
goto error;
if (qemuSecurityInit(qemu_driver) < 0)
unsigned short start;
unsigned short end;
+
+ unsigned int flags;
};
static virClassPtr virPortAllocatorClass;
virPortAllocatorPtr virPortAllocatorNew(const char *name,
unsigned short start,
- unsigned short end)
+ unsigned short end,
+ unsigned int flags)
{
virPortAllocatorPtr pa;
if (!(pa = virObjectLockableNew(virPortAllocatorClass)))
return NULL;
+ pa->flags = flags;
pa->start = start;
pa->end = end;
if (used)
continue;
- if (virPortAllocatorBindToPort(&v6used, i, AF_INET6) < 0 ||
- virPortAllocatorBindToPort(&used, i, AF_INET) < 0)
- goto cleanup;
+ if (!(pa->flags & VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK)) {
+ if (virPortAllocatorBindToPort(&v6used, i, AF_INET6) < 0 ||
+ virPortAllocatorBindToPort(&used, i, AF_INET) < 0)
+ goto cleanup;
+ }
if (!used && !v6used) {
/* Add port to bitmap of reserved ports */
typedef struct _virPortAllocator virPortAllocator;
typedef virPortAllocator *virPortAllocatorPtr;
+typedef enum {
+ VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK = (1 << 0),
+} virPortAllocatorFlags;
+
virPortAllocatorPtr virPortAllocatorNew(const char *name,
unsigned short start,
- unsigned short end);
+ unsigned short end,
+ unsigned int flags);
int virPortAllocatorAcquire(virPortAllocatorPtr pa,
unsigned short *port);
static int testAllocAll(const void *args ATTRIBUTE_UNUSED)
{
- virPortAllocatorPtr alloc = virPortAllocatorNew("test", 5900, 5909);
+ virPortAllocatorPtr alloc = virPortAllocatorNew("test", 5900, 5909, 0);
int ret = -1;
unsigned short p1, p2, p3, p4, p5, p6, p7;
static int testAllocReuse(const void *args ATTRIBUTE_UNUSED)
{
- virPortAllocatorPtr alloc = virPortAllocatorNew("test", 5900, 5910);
+ virPortAllocatorPtr alloc = virPortAllocatorNew("test", 5900, 5910, 0);
int ret = -1;
unsigned short p1, p2, p3, p4;