[PATCH 2/2] Report an error if port range is exhausted

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the port range is full, virPortAllocatorAcquire will
return 0 and set the port to 0, leaving the error reporting
to the caller.

This didn't happen when allocating ports for QEMU's VNC (introduced
along with the virPortAllocator in dfb1022), VNC WebSockets and
NBD migration (introduced with these features in f1ad8d2 and 86d90b3)
---
 src/qemu/qemu_migration.c | 14 ++++++++++----
 src/qemu/qemu_process.c   | 10 ++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 5607098..addc78e 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1114,10 +1114,16 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
                                            QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
             goto cleanup;
 
-        if (!port &&
-            ((virPortAllocatorAcquire(driver->remotePorts, &port) < 0) ||
-             (qemuMonitorNBDServerStart(priv->mon, listenAddr, port) < 0))) {
-            goto exit_monitor;
+        if (!port) {
+            if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0)
+                goto exit_monitor;
+            if (port == 0) {
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("Unable to find unused port for NBD migration"));
+                goto exit_monitor;
+            }
+            if (qemuMonitorNBDServerStart(priv->mon, listenAddr, port) < 0)
+                goto exit_monitor;
         }
 
         if (qemuMonitorNBDServerAdd(priv->mon, diskAlias, true) < 0)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 354e079..3d9bffc 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3345,12 +3345,22 @@ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
     if (graphics->data.vnc.autoport) {
         if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0)
             return -1;
+        if (port == 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Unable to find an unused port for VNC"));
+            return -1;
+        }
         graphics->data.vnc.port = port;
     }
 
     if (graphics->data.vnc.websocket == -1) {
         if (virPortAllocatorAcquire(driver->webSocketPorts, &port) < 0)
             return -1;
+        if (port == 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Unable to find an unused port for VNC WebSocket"));
+            return -1;
+        }
         graphics->data.vnc.websocket = port;
     }
 
-- 
1.8.1.5

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]