]> 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)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 8 Jul 2013 10:27:58 +0000 (12:27 +0200)
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.

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

index 6b488ca5093471464a9e262f1bf4ebff894ac36f..a6b7acb9022827fb0599b61e3f2f6c847feab075 100644 (file)
@@ -1159,7 +1159,7 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
 
 cleanup:
     VIR_FREE(diskAlias);
-    if ((ret < 0) && port)
+    if (ret < 0)
         virPortAllocatorRelease(driver->remotePorts, port);
     return ret;
 }
@@ -2448,7 +2448,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 114e8851d9497480f01de9c8e364830b2256d387..f8c652fff33990e2a559d5f1ca214191bf6fefe7 100644 (file)
@@ -3368,8 +3368,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
     return 0;
 
 error:
-    if (port)
-        virPortAllocatorRelease(driver->remotePorts, port);
+    virPortAllocatorRelease(driver->remotePorts, port);
     return -1;
 }
 
@@ -4093,10 +4092,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);
@@ -4217,20 +4214,18 @@ retry:
         virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
         if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
             if (graphics->data.vnc.autoport) {
-                ignore_value(virPortAllocatorRelease(driver->remotePorts,
-                                                     graphics->data.vnc.port));
-            }
-            if (graphics->data.vnc.websocket) {
-                ignore_value(virPortAllocatorRelease(driver->webSocketPorts,
-                                                     graphics->data.vnc.websocket));
+                virPortAllocatorRelease(driver->remotePorts,
+                                        graphics->data.vnc.port);
             }
+            virPortAllocatorRelease(driver->webSocketPorts,
+                                    graphics->data.vnc.websocket);
         }
         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 c7be10fe0ca007488ae029ee4a6e92bee2dcc5f6..07579664881f26afec38b422ed0d18464c25459d 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 ||