From nobody Mon Dec 15 03:21:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501156066533825.843088174188; Thu, 27 Jul 2017 04:47:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A776E6E78F; Thu, 27 Jul 2017 11:47:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8206060A99; Thu, 27 Jul 2017 11:47:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 35D364A469; Thu, 27 Jul 2017 11:47:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6RBlXHG028553 for ; Thu, 27 Jul 2017 07:47:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7B76D5D72E; Thu, 27 Jul 2017 11:47:33 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id D18E55D72D for ; Thu, 27 Jul 2017 11:47:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A776E6E78F Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 27 Jul 2017 13:47:22 +0200 Message-Id: <2144b14146facc35fdb9254095b864fb0bab6958.1501155886.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/7] Report error if virMutexInit fails X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 27 Jul 2017 11:47:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 --- 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; =20 if (virMutexInit(&bhyve_driver->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init bhyve driver l= ock")); 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 loc= k")); 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) =20 fuse->def =3D def; =20 - if (virMutexInit(&fuse->lock) < 0) + if (virMutexInit(&fuse->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init fuse lock")); goto cleanup2; + } =20 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; =20 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_devic= e_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; =20 if (virMutexInit(&driver->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init node driver lo= ck")); VIR_FREE(driver); return -1; } diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.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) =20 req->threadStatus =3D THREAD_STATUS_NONE; =20 - if (virStrcpyStatic(req->ifkey, ifkey) =3D=3D NULL || - virMutexInitRecursive(&req->lock) < 0) + if (virStrcpyStatic(req->ifkey, ifkey) =3D=3D NULL) goto err_free_req; =20 + 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; =20 @@ -2085,8 +2089,10 @@ virNWFilterDHCPSnoopInit(void) VIR_DEBUG("Initializing DHCP snooping"); =20 if (virMutexInitRecursive(&virNWFilterSnoopState.snoopLock) < 0 || - virMutexInit(&virNWFilterSnoopState.activeLock) < 0) + virMutexInit(&virNWFilterSnoopState.activeLock) < 0) { + virReportSystemError(errno, "%s", _("unable to init nwfilter lock"= )); return -1; + } =20 virNWFilterSnoopState.ifnameToKey =3D virHashCreate(0, NULL); virNWFilterSnoopState.active =3D 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; =20 - if (virMutexInit(&driver->lock) < 0) + if (virMutexInit(&driver->lock) < 0) { + virReportSystemError(errno, "%s", + _("unable to init nwfilter driver lock")); goto err_free_driverstate; + } =20 /* remember that we are going to use firewalld */ driver->watchingFirewallD =3D (sysbus !=3D 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 =3D 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; + } =20 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; =20 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; =20 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 =3D opaque; =20 if (virMutexInit(¨_driver->lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init uml driver loc= k")); 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, unsi= gned int groups) return -1; =20 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 =3D funcName; pool->jobOpaque =3D opaque; =20 - if (virMutexInit(&pool->mutex) < 0) + if (virMutexInit(&pool->mutex) < 0) { + virReportSystemError(errno, "%s", _("unable to init thread pool lo= ck")); 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; } =20 - if (virMutexInit(&driver->lock) < 0) + if (virMutexInit(&driver->lock) < 0) { + virReportSystemError(errno, "%s", + _("unable to init vmware driver lock")); goto cleanup; + } =20 if ((tmp =3D STRSKIP(conn->uri->scheme, "vmware")) =3D=3D 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; } =20 - if (virMutexInit(&vz_driver_lock) < 0) + if (virMutexInit(&vz_driver_lock) < 0) { + virReportSystemError(errno, "%s", _("unable to init vz driver lock= ")); goto error; + } =20 /* 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; =20 - 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; + } =20 virMutexLock(&con->lock); =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list