From nobody Wed May 14 08:09:32 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524158060601884.4473375801346; Thu, 19 Apr 2018 10:14:20 -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 5AA733134ED2; Thu, 19 Apr 2018 17:14:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3129089FA4; Thu, 19 Apr 2018 17:14:19 +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 DBA64180BAD4; Thu, 19 Apr 2018 17:14:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3JHAC2k015114 for ; Thu, 19 Apr 2018 13:10:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4F8332026DFD; Thu, 19 Apr 2018 17:10:12 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D50A2023238; Thu, 19 Apr 2018 17:10:11 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 19 Apr 2018 18:09:53 +0100 Message-Id: <20180419171002.17117-6-berrange@redhat.com> In-Reply-To: <20180419171002.17117-1-berrange@redhat.com> References: <20180419171002.17117-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/14] driver: fix handling of error return from finding resource 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: , Content-Type: text/plain; charset="utf-8" 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.45]); Thu, 19 Apr 2018 17:14:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The virFileFindResource method merely builds up the expected fully qualified path to the resource. It does not actually check if it exists on disk. The loadable module callers were mistakenly thinking a NULL indicates the file doesn't exist on disk, whereas it in fact indicates an out of memory error. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/driver.c | 2 +- src/storage/storage_backend.c | 2 +- src/util/virfile.c | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/driver.c b/src/driver.c index 4d314b3870..ddda1e71f7 100644 --- a/src/driver.c +++ b/src/driver.c @@ -153,7 +153,7 @@ virDriverLoadModule(const char *name, abs_topbuilddir "/src/.libs", DEFAULT_DRIVER_DIR, "LIBVIRT_DRIVER_DIR"))) - return 1; + return -1; =20 ret =3D virDriverLoadModuleFull(modfile, regfunc); =20 diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index aac2f53b01..8c1dcf31b1 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -95,7 +95,7 @@ virStorageDriverLoadBackendModule(const char *name, abs_topbuilddir "/src/.libs", STORAGE_BACKEND_MODULE_DIR, "LIBVIRT_STORAGE_BACKEND_DIR")= )) - return 1; + return -1; =20 if ((ret =3D virDriverLoadModuleFull(modfile, regfunc)) !=3D 0) { if (forceload) { diff --git a/src/util/virfile.c b/src/util/virfile.c index 5e9bd2007a..e12a584ca1 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1736,6 +1736,10 @@ static bool useDirOverride; * run from the source tree. Otherwise it will return the * path in the installed location. * + * Note that this function does not actually check whether + * the file exists on disk, it merely builds the fully + * qualified path where it is supposed to exist. + * * If @envname is non-NULL it will override all other * directory lookup. * --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list