]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Don't spam logs with "port 0 must be in range" errors
authorJiri Denemark <jdenemar@redhat.com>
Thu, 4 Jul 2013 19:16:57 +0000 (21:16 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 9 Jan 2014 13:25:35 +0000 (14:25 +0100)
Whenever virPortAllocatorRelease is called with port == 0, it complains
that the port is not in an allowed range, which is expectable as the
port was never allocated. Let's make virPortAllocatorRelease ignore 0
ports in a similar way free() ignores NULL pointers.

(cherry picked from commit 86dba8f3de32cb4d32156f64e7f580f6c5f42a12)

Conflicts:
  missing VNC websocket support
src/qemu/qemu_process.c

src/qemu/qemu_migration.c
src/qemu/qemu_process.c
src/util/virportallocator.c

index e6223717d0c0457226a57dee02aede2fa57f4c1b..f89aa90e7599bc37dc35552a1dbcb5d8f98af544 100644 (file)
@@ -1158,7 +1158,7 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
 
 cleanup:
     VIR_FREE(diskAlias);
-    if ((ret < 0) && port)
+    if (ret < 0)
         virPortAllocatorRelease(driver->remotePorts, port);
     return ret;
 }
@@ -2291,7 +2291,7 @@ cleanup:
             virObjectUnlock(vm);
         else
             qemuDomainRemoveInactive(driver, vm);
-        if (ret < 0 && priv->nbdPort) {
+        if (ret < 0) {
             virPortAllocatorRelease(driver->remotePorts, priv->nbdPort);
             priv->nbdPort = 0;
         }
index d4c654b3cf8bf6aee8f95041f1c55ab555d21723..8f36d8828ef02b0b7664ce5eafad5156ba8df7af 100644 (file)
@@ -3340,8 +3340,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
     return 0;
 
 error:
-    if (port)
-        virPortAllocatorRelease(driver->remotePorts, port);
+    virPortAllocatorRelease(driver->remotePorts, port);
     return -1;
 }
 
@@ -4052,10 +4051,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
         }
     }
 
-    if (priv->nbdPort) {
-        virPortAllocatorRelease(driver->remotePorts, priv->nbdPort);
-        priv->nbdPort = 0;
-    }
+    virPortAllocatorRelease(driver->remotePorts, priv->nbdPort);
+    priv->nbdPort = 0;
 
     if (priv->agent) {
         qemuAgentClose(priv->agent);
@@ -4172,15 +4169,15 @@ retry:
         virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
         if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
             graphics->data.vnc.autoport) {
-            ignore_value(virPortAllocatorRelease(driver->remotePorts,
-                                                 graphics->data.vnc.port));
+            virPortAllocatorRelease(driver->remotePorts,
+                                    graphics->data.vnc.port);
         }
         if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
             graphics->data.spice.autoport) {
-            ignore_value(virPortAllocatorRelease(driver->remotePorts,
-                                                 graphics->data.spice.port));
-            ignore_value(virPortAllocatorRelease(driver->remotePorts,
-                                                 graphics->data.spice.tlsPort));
+            virPortAllocatorRelease(driver->remotePorts,
+                                    graphics->data.spice.port);
+            virPortAllocatorRelease(driver->remotePorts,
+                                    graphics->data.spice.tlsPort);
         }
     }
 
index 590bb570f6cd866e5a248f682f65c011319f1e5f..778c063fcb669038eebd96ff334d99ec56c68735 100644 (file)
@@ -166,6 +166,10 @@ int virPortAllocatorRelease(virPortAllocatorPtr pa,
                             unsigned short port)
 {
     int ret = -1;
+
+    if (!port)
+        return 0;
+
     virObjectLock(pa);
 
     if (port < pa->start ||