goto cleanup;
if (!(bhyve_driver->remotePorts = virPortAllocatorRangeNew(_("display"),
- 5900, 65535, 0)))
+ 5900, 65535)))
goto cleanup;
bhyve_driver->hostsysinfo = virSysinfoRead();
if (!(libxl_driver->reservedGraphicsPorts =
virPortAllocatorRangeNew(_("VNC"),
LIBXL_VNC_PORT_MIN,
- LIBXL_VNC_PORT_MAX,
- 0)))
+ LIBXL_VNC_PORT_MAX)))
goto error;
/* Allocate bitmap for migration port reservation */
if (!(libxl_driver->migrationPorts =
virPortAllocatorRangeNew(_("migration"),
LIBXL_MIGRATION_PORT_MIN,
- LIBXL_MIGRATION_PORT_MAX, 0)))
+ LIBXL_MIGRATION_PORT_MAX)))
goto error;
if (!(libxl_driver->domains = virDomainObjListNew()))
if ((qemu_driver->remotePorts =
virPortAllocatorRangeNew(_("display"),
cfg->remotePortMin,
- cfg->remotePortMax,
- 0)) == NULL)
+ cfg->remotePortMax)) == NULL)
goto error;
if ((qemu_driver->webSocketPorts =
virPortAllocatorRangeNew(_("webSocket"),
cfg->webSocketPortMin,
- cfg->webSocketPortMax,
- 0)) == NULL)
+ cfg->webSocketPortMax)) == NULL)
goto error;
if ((qemu_driver->migrationPorts =
virPortAllocatorRangeNew(_("migration"),
cfg->migrationPortMin,
- cfg->migrationPortMax,
- 0)) == NULL)
+ cfg->migrationPortMax)) == NULL)
goto error;
if (qemuSecurityInit(qemu_driver) < 0)
unsigned short start;
unsigned short end;
-
- unsigned int flags;
};
static virClassPtr virPortAllocatorClass;
virPortAllocatorRangePtr
virPortAllocatorRangeNew(const char *name,
unsigned short start,
- unsigned short end,
- unsigned int flags)
+ unsigned short end)
{
virPortAllocatorRangePtr range;
if (VIR_ALLOC(range) < 0)
return NULL;
- range->flags = flags;
range->start = start;
range->end = end;
if (virBitmapIsBitSet(pa->bitmap, i))
continue;
- if (!(range->flags & VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK)) {
- if (virPortAllocatorBindToPort(&v6used, i, AF_INET6) < 0 ||
- virPortAllocatorBindToPort(&used, i, AF_INET) < 0)
- goto cleanup;
- }
+ 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 _virPortAllocatorRange virPortAllocatorRange;
typedef virPortAllocatorRange *virPortAllocatorRangePtr;
-typedef enum {
- VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK = (1 << 0),
-} virPortAllocatorFlags;
-
virPortAllocatorRangePtr
virPortAllocatorRangeNew(const char *name,
unsigned short start,
- unsigned short end,
- unsigned int flags);
+ unsigned short end);
void virPortAllocatorRangeFree(virPortAllocatorRangePtr range);
{
return 0;
}
+
+int bind(int sockfd ATTRIBUTE_UNUSED,
+ const struct sockaddr *addr ATTRIBUTE_UNUSED,
+ socklen_t addrlen ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
if ((driver.xmlopt = virBhyveDriverCreateXMLConf(&driver)) == NULL)
return EXIT_FAILURE;
- if (!(driver.remotePorts = virPortAllocatorRangeNew("display", 5900, 65535,
- VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK)))
+ if (!(driver.remotePorts = virPortAllocatorRangeNew("display", 5900, 65535)))
return EXIT_FAILURE;
if (libxl_ctx_alloc(&ctx, LIBXL_VERSION, 0, log) < 0)
goto cleanup;
- if (!(gports = virPortAllocatorRangeNew("vnc", 5900, 6000,
- VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK)))
+ if (!(gports = virPortAllocatorRangeNew("vnc", 5900, 6000)))
goto cleanup;
if (!(xmlopt = libxlCreateXMLConf()))
# include <libxl.h>
# include <xenstore.h>
# include <xenctrl.h>
+# include <sys/socket.h>
VIR_MOCK_IMPL_RET_VOID(xs_daemon_open,
struct xs_handle *)
VIR_MOCK_STUB_VOID_ARGS(xs_daemon_close,
struct xs_handle *, handle)
+VIR_MOCK_STUB_RET_ARGS(bind,
+ int, 0,
+ int, sockfd,
+ const struct sockaddr *, addr,
+ socklen_t, addrlen)
+
VIR_MOCK_IMPL_RET_ARGS(__xstat, int,
int, ver,
const char *, path,
static int testAllocAll(const void *args ATTRIBUTE_UNUSED)
{
- virPortAllocatorRangePtr ports = virPortAllocatorRangeNew("test", 5900, 5909, 0);
+ virPortAllocatorRangePtr ports = virPortAllocatorRangeNew("test", 5900, 5909);
int ret = -1;
unsigned short p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7 = 0;
static int testAllocReuse(const void *args ATTRIBUTE_UNUSED)
{
- virPortAllocatorRangePtr ports = virPortAllocatorRangeNew("test", 5900, 5910, 0);
+ virPortAllocatorRangePtr ports = virPortAllocatorRangeNew("test", 5900, 5910);
int ret = -1;
unsigned short p1 = 0, p2 = 0, p3 = 0, p4 = 0;