The virMutexInit() function is not reporting any error on failure rather than returning -1 and setting errno. It's up to the caller to report the error. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/bhyve/bhyve_driver.c | 1 + src/lxc/lxc_driver.c | 1 + src/lxc/lxc_fuse.c | 4 +++- src/network/bridge_driver.c | 1 + src/node_device/node_device_hal.c | 1 + src/nwfilter/nwfilter_dhcpsnoop.c | 12 +++++++++--- src/nwfilter/nwfilter_driver.c | 5 ++++- src/nwfilter/nwfilter_gentech_driver.c | 4 +++- src/secret/secret_driver.c | 2 ++ src/storage/storage_driver.c | 2 ++ src/uml/uml_driver.c | 1 + src/util/virnetlink.c | 1 + src/util/virthreadpool.c | 4 +++- src/vmware/vmware_driver.c | 5 ++++- src/vz/vz_driver.c | 4 +++- tools/virsh-console.c | 4 +++- 16 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 550b257cd..cb22842f5 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1240,6 +1240,7 @@ bhyveStateInitialize(bool privileged, return -1; if (virMutexInit(&bhyve_driver->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init bhyve driver lock")); VIR_FREE(bhyve_driver); return -1; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 6eb88b0ba..6cd818a08 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1631,6 +1631,7 @@ static int lxcStateInitialize(bool privileged, if (VIR_ALLOC(lxc_driver) < 0) return -1; if (virMutexInit(&lxc_driver->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init lxc driver lock")); VIR_FREE(lxc_driver); return -1; } diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c index 60d41243a..dca381152 100644 --- a/src/lxc/lxc_fuse.c +++ b/src/lxc/lxc_fuse.c @@ -309,8 +309,10 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def) fuse->def = def; - if (virMutexInit(&fuse->lock) < 0) + if (virMutexInit(&fuse->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init fuse lock")); goto cleanup2; + } if (virAsprintf(&fuse->mountpoint, "%s/%s.fuse/", LXC_STATE_DIR, def->name) < 0) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index d05e08fc9..c26ee6dcc 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -729,6 +729,7 @@ networkStateInitialize(bool privileged, goto error; if (virMutexInit(&network_driver->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init network driver lock")); VIR_FREE(network_driver); goto error; } diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c index c19e327c9..fcbbb4e6d 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -612,6 +612,7 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED, return -1; if (virMutexInit(&driver->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init node driver lock")); VIR_FREE(driver); return -1; } diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index 4436e396f..b7bf913c9 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -592,10 +592,14 @@ virNWFilterSnoopReqNew(const char *ifkey) req->threadStatus = THREAD_STATUS_NONE; - if (virStrcpyStatic(req->ifkey, ifkey) == NULL || - virMutexInitRecursive(&req->lock) < 0) + if (virStrcpyStatic(req->ifkey, ifkey) == NULL) goto err_free_req; + if (virMutexInitRecursive(&req->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init nwfilter lock")); + goto err_free_req; + } + if (virCondInit(&req->threadStatusCond) < 0) goto err_destroy_mutex; @@ -2085,8 +2089,10 @@ virNWFilterDHCPSnoopInit(void) VIR_DEBUG("Initializing DHCP snooping"); if (virMutexInitRecursive(&virNWFilterSnoopState.snoopLock) < 0 || - virMutexInit(&virNWFilterSnoopState.activeLock) < 0) + virMutexInit(&virNWFilterSnoopState.activeLock) < 0) { + virReportSystemError(errno, "%s", _("unable to init nwfilter lock")); return -1; + } virNWFilterSnoopState.ifnameToKey = virHashCreate(0, NULL); virNWFilterSnoopState.active = virHashCreate(0, NULL); diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 2f9a51c40..12e11a1c8 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -183,8 +183,11 @@ nwfilterStateInitialize(bool privileged, if (VIR_ALLOC(driver) < 0) return -1; - if (virMutexInit(&driver->lock) < 0) + if (virMutexInit(&driver->lock) < 0) { + virReportSystemError(errno, "%s", + _("unable to init nwfilter driver lock")); goto err_free_driverstate; + } /* remember that we are going to use firewalld */ driver->watchingFirewallD = (sysbus != NULL); diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c index 6758200b5..c0b07cff2 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -77,8 +77,10 @@ int virNWFilterTechDriversInit(bool privileged) { size_t i = 0; VIR_DEBUG("Initializing NWFilter technology drivers"); - if (virMutexInitRecursive(&updateMutex) < 0) + if (virMutexInitRecursive(&updateMutex) < 0) { + virReportSystemError(errno, "%s", _("unable to init nwfilter lock")); return -1; + } while (filter_tech_drivers[i]) { if (!(filter_tech_drivers[i]->flags & TECHDRV_FLAG_INITIALIZED)) diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index d833a863f..3848cfb81 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -458,6 +458,8 @@ secretStateInitialize(bool privileged, return -1; if (virMutexInit(&driver->lock) < 0) { + virReportSystemError(errno, "%s", + _("unable to init secret driver lock")); VIR_FREE(driver); return -1; } diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 855212063..f162f2e5a 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -254,6 +254,8 @@ storageStateInitialize(bool privileged, return ret; if (virMutexInit(&driver->lock) < 0) { + virReportSystemError(errno, "%s", + _("cannot initialize storage driver lock")); VIR_FREE(driver); return ret; } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 1846835cc..62d78a3ee 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -473,6 +473,7 @@ umlStateInitialize(bool privileged, uml_driver->inhibitOpaque = opaque; if (virMutexInit(¨_driver->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init uml driver lock")); VIR_FREE(uml_driver); return -1; } diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index d732fe8cf..f297207a3 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -862,6 +862,7 @@ virNetlinkEventServiceStart(unsigned int protocol, unsigned int groups) return -1; if (virMutexInit(&srv->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init netlink lock")); VIR_FREE(srv); return -1; } diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c index 10f2bd2c3..d9e17346f 100644 --- a/src/util/virthreadpool.c +++ b/src/util/virthreadpool.c @@ -239,8 +239,10 @@ virThreadPoolNewFull(size_t minWorkers, pool->jobFuncName = funcName; pool->jobOpaque = opaque; - if (virMutexInit(&pool->mutex) < 0) + if (virMutexInit(&pool->mutex) < 0) { + virReportSystemError(errno, "%s", _("unable to init thread pool lock")); goto error; + } if (virCondInit(&pool->cond) < 0) goto error; if (virCondInit(&pool->quit_cond) < 0) diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 8b487c4a7..eed6c865b 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -176,8 +176,11 @@ vmwareConnectOpen(virConnectPtr conn, goto cleanup; } - if (virMutexInit(&driver->lock) < 0) + if (virMutexInit(&driver->lock) < 0) { + virReportSystemError(errno, "%s", + _("unable to init vmware driver lock")); goto cleanup; + } if ((tmp = STRSKIP(conn->uri->scheme, "vmware")) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to parse URI " diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 6f4aee365..fab01e1c3 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -4133,8 +4133,10 @@ vzStateInitialize(bool privileged ATTRIBUTE_UNUSED, return -1; } - if (virMutexInit(&vz_driver_lock) < 0) + if (virMutexInit(&vz_driver_lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init vz driver lock")); goto error; + } /* Failing to create driver here is not fatal and only means * that next driver client will try once more when connecting */ diff --git a/tools/virsh-console.c b/tools/virsh-console.c index c1927c28a..ab3339ec7 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -351,8 +351,10 @@ virshRunConsole(vshControl *ctl, if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0) goto cleanup; - if (virCondInit(&con->cond) < 0 || virMutexInit(&con->lock) < 0) + if (virCondInit(&con->cond) < 0 || virMutexInit(&con->lock) < 0) { + VIR_ERROR(_("unable to init console lock or condition")); goto cleanup; + } virMutexLock(&con->lock); -- 2.13.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list