if (virPortAllocatorAcquire(driver->reservedVNCPorts, &port) < 0)
return -1;
- if (port == 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Unable to find an unused VNC port"));
- return -1;
- }
l_vfb->data.vnc.port = port;
}
x_vfb->vnc.display = l_vfb->data.vnc.port - LIBXL_VNC_PORT_MIN;
* to be a correct hostname which refers to the target machine).
*/
if (uri_in == NULL) {
- if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0) {
+ if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0)
goto cleanup;
- } else if (!port) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("No migration port available within the "
- "configured range"));
- goto cleanup;
- }
if ((hostname = virGetHostname()) == NULL)
goto cleanup;
}
if (uri->port == 0) {
- if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0) {
+ if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0)
goto cleanup;
- } else if (!port) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("No migration port available within the "
- "configured range"));
- goto cleanup;
- }
if (well_formed_uri) {
uri->port = port;
if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0)
goto error;
- if (port == 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to find an unused port for SPICE"));
- goto error;
- }
-
graphics->data.spice.port = port;
}
if (virPortAllocatorAcquire(driver->remotePorts, &tlsPort) < 0)
goto error;
- if (tlsPort == 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to find an unused port for SPICE TLS"));
- goto error;
- }
graphics->data.spice.tlsPort = tlsPort;
}
}
goto cleanup;
}
*port = i;
+ ret = 0;
}
}
- ret = 0;
+ if (*port == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to find an unused port in range '%s' (%d-%d)"),
+ pa->name, pa->start, pa->end);
+ }
cleanup:
virObjectUnlock(pa);
VIR_FORCE_CLOSE(fd);
goto cleanup;
}
- if (virPortAllocatorAcquire(alloc, &p7) < 0)
- goto cleanup;
- if (p7 != 0) {
+ if (virPortAllocatorAcquire(alloc, &p7) == 0) {
if (virTestGetDebug())
- fprintf(stderr, "Expected 0, got %d", p7);
+ fprintf(stderr, "Expected error, got %d", p7);
goto cleanup;
}