mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
Don't spam logs with "port 0 must be in range" errors
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.
This commit is contained in:
parent
0d7dc70824
commit
86dba8f3de
@ -1159,7 +1159,7 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(diskAlias);
|
VIR_FREE(diskAlias);
|
||||||
if ((ret < 0) && port)
|
if (ret < 0)
|
||||||
virPortAllocatorRelease(driver->remotePorts, port);
|
virPortAllocatorRelease(driver->remotePorts, port);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2448,7 +2448,7 @@ cleanup:
|
|||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
else
|
else
|
||||||
qemuDomainRemoveInactive(driver, vm);
|
qemuDomainRemoveInactive(driver, vm);
|
||||||
if (ret < 0 && priv->nbdPort) {
|
if (ret < 0) {
|
||||||
virPortAllocatorRelease(driver->remotePorts, priv->nbdPort);
|
virPortAllocatorRelease(driver->remotePorts, priv->nbdPort);
|
||||||
priv->nbdPort = 0;
|
priv->nbdPort = 0;
|
||||||
}
|
}
|
||||||
|
@ -3368,8 +3368,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (port)
|
virPortAllocatorRelease(driver->remotePorts, port);
|
||||||
virPortAllocatorRelease(driver->remotePorts, port);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4093,10 +4092,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->nbdPort) {
|
virPortAllocatorRelease(driver->remotePorts, priv->nbdPort);
|
||||||
virPortAllocatorRelease(driver->remotePorts, priv->nbdPort);
|
priv->nbdPort = 0;
|
||||||
priv->nbdPort = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->agent) {
|
if (priv->agent) {
|
||||||
qemuAgentClose(priv->agent);
|
qemuAgentClose(priv->agent);
|
||||||
@ -4217,20 +4214,18 @@ retry:
|
|||||||
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
|
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
|
||||||
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
|
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
|
||||||
if (graphics->data.vnc.autoport) {
|
if (graphics->data.vnc.autoport) {
|
||||||
ignore_value(virPortAllocatorRelease(driver->remotePorts,
|
virPortAllocatorRelease(driver->remotePorts,
|
||||||
graphics->data.vnc.port));
|
graphics->data.vnc.port);
|
||||||
}
|
|
||||||
if (graphics->data.vnc.websocket) {
|
|
||||||
ignore_value(virPortAllocatorRelease(driver->webSocketPorts,
|
|
||||||
graphics->data.vnc.websocket));
|
|
||||||
}
|
}
|
||||||
|
virPortAllocatorRelease(driver->webSocketPorts,
|
||||||
|
graphics->data.vnc.websocket);
|
||||||
}
|
}
|
||||||
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
|
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
|
||||||
graphics->data.spice.autoport) {
|
graphics->data.spice.autoport) {
|
||||||
ignore_value(virPortAllocatorRelease(driver->remotePorts,
|
virPortAllocatorRelease(driver->remotePorts,
|
||||||
graphics->data.spice.port));
|
graphics->data.spice.port);
|
||||||
ignore_value(virPortAllocatorRelease(driver->remotePorts,
|
virPortAllocatorRelease(driver->remotePorts,
|
||||||
graphics->data.spice.tlsPort));
|
graphics->data.spice.tlsPort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +166,10 @@ int virPortAllocatorRelease(virPortAllocatorPtr pa,
|
|||||||
unsigned short port)
|
unsigned short port)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
if (!port)
|
||||||
|
return 0;
|
||||||
|
|
||||||
virObjectLock(pa);
|
virObjectLock(pa);
|
||||||
|
|
||||||
if (port < pa->start ||
|
if (port < pa->start ||
|
||||||
|
Loading…
Reference in New Issue
Block a user