From nobody Wed May 8 18:57:23 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1565801971; cv=none; d=zoho.com; s=zohoarc; b=BpfBsoS92RwOcway8LWbLyx+1+6XwZNJcBhYQpaNnUeAZRnkKKlmBEsZjzTFkHz4vj9zsJ1W6sivpDwjRjW4iwBkiSPvRjveNKW+sd8rn99zr4eIeGh33sy+FIe259OdDbfARDW+LIDbq2uRM8F9uwY1JiFX7y/nnu2wvIW8EXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565801971; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=icXi3dkyQrWc+OCGDbuNvnfBqmeXYoa2RIa4lZtjyy4=; b=iQ409bTUffEMJsKrvoCujcs+VJwqeK5hI6LVkYCyakWCdY1K+2uqcYEvyatDjJXmCVoTjBl5MkOfG6zmS52YihW2MXUv4YTEnj9vnkJ/Hi29LMg4kLlohZE5lUIscKi0FjzsOqHgUFO9y15/VLQNImdPdMMkDScmEsGtawwBV+k= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565801971187357.837548830229; Wed, 14 Aug 2019 09:59:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F00757E424; Wed, 14 Aug 2019 16:59:29 +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 CDA0280A3F; Wed, 14 Aug 2019 16:59:29 +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 7BC9D1806B00; Wed, 14 Aug 2019 16:59:29 +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 x7EGxQAt028577 for ; Wed, 14 Aug 2019 12:59:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9494D8B161; Wed, 14 Aug 2019 16:59:26 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E1D88BE32 for ; Wed, 14 Aug 2019 16:59:25 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 14 Aug 2019 18:59:16 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/6] util: Export virStorageFileSupportsBackingChainTraversal 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-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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 14 Aug 2019 16:59:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function will be reused in the qemu snapshot code. The argument is turned into const similarly to the other virStorageFileSupports* functions. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virstoragefile.c | 4 ++-- src/util/virstoragefile.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 83f40cefe6..9db4ac7933 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2994,6 +2994,7 @@ virStorageFileReportBrokenChain; virStorageFileResize; virStorageFileStat; virStorageFileSupportsAccess; +virStorageFileSupportsBackingChainTraversal; virStorageFileSupportsCreate; virStorageFileSupportsSecurityDriver; virStorageFileUnlink; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index ba56f452e9..4011187a7e 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4448,8 +4448,8 @@ virStorageFileGetBackendForSupportCheck(const virStor= ageSource *src, } -static int -virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src) +int +virStorageFileSupportsBackingChainTraversal(const virStorageSource *src) { virStorageFileBackendPtr backend; int rv; diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 2882bacf3e..b65cd4c382 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -533,6 +533,7 @@ int virStorageFileChown(const virStorageSource *src, ui= d_t uid, gid_t gid); int virStorageFileSupportsSecurityDriver(const virStorageSource *src); int virStorageFileSupportsAccess(const virStorageSource *src); int virStorageFileSupportsCreate(const virStorageSource *src); +int virStorageFileSupportsBackingChainTraversal(const virStorageSource *sr= c); int virStorageFileGetMetadata(virStorageSourcePtr src, uid_t uid, gid_t gid, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 18:57:23 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1565801971; cv=none; d=zoho.com; s=zohoarc; b=H5VUMpC3y6THveLkttuYCP5VQcbKJez4VWjdpGywJ4ZTutthzB5iHykocB3ggkmO6cUO23sIs/ACM1s0h+k/4hM08wcrBJ+MN1yMk7oid9yuQh65QG/yFPhv+5HFPIkDtCXM7Dr4Wh83T+NkyW1YNtxDAdQFLOnh0Q4VGi2t9g8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565801971; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Yn1C+5zPf3UNnbZbj8DzFw06q409y8daAwijyr5UYoQ=; b=WsqybM10HGzSaC5NnqEdREa0rpaWb+ZMkffOMQkfMCQVfbuqwFfi4tcz2rpd2o+IFt9y2JHlP6h+aMqQn8qe+LviriR+0JeIjntJAGKRiS0nm3iaCwNpM5IMNvCNfwnQvJXoFWuN2DK41wkLRrteok6yupjaCC8yu/FCGB1dB3g= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565801971284508.60370761830654; Wed, 14 Aug 2019 09:59:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08DEC923AD; Wed, 14 Aug 2019 16:59:30 +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 D77FD83780; Wed, 14 Aug 2019 16:59:29 +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 9F66D3CBF; Wed, 14 Aug 2019 16:59:29 +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 x7EGxROl028585 for ; Wed, 14 Aug 2019 12:59:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5F8436762C; Wed, 14 Aug 2019 16:59:27 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE8F88B161 for ; Wed, 14 Aug 2019 16:59:26 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 14 Aug 2019 18:59:17 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] qemu: Allow skipping some errors in qemuDomainStorageOpenStat 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-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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 14 Aug 2019 16:59:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Some callers of this function actually don't care about errors and reset it. The message is still logged which might irritate users in this case. Add a boolean flag which will do few checks whether it actually makes sense to even try opening the storage file. For local files we check whether it exists and for remote files we at first see whether we even have a storage driver backend for it in the first place before trying to open it. Other problems will still report errors but these are the most common scenarios which can happen here. This patch changes the return value of the function so that the caller is able to differentiate the possibilities. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 48c7b5628b..cc296c1fe3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12247,6 +12247,7 @@ qemuDomainMemoryPeek(virDomainPtr dom, * @src: storage source data * @ret_fd: pointer to return open'd file descriptor * @ret_sb: pointer to return stat buffer (local or remote) + * @skipInaccessible: Don't report error if files are not accessible * * For local storage, open the file using qemuOpenFile and then use * fstat() to grab the stat struct data for the caller. @@ -12254,7 +12255,9 @@ qemuDomainMemoryPeek(virDomainPtr dom, * For remote storage, attempt to access the file and grab the stat * struct data if the remote connection supports it. * - * Returns 0 on success with @ret_fd and @ret_sb populated, -1 on failure + * Returns 1 if @src was successfully opened (@ret_fd and @ret_sb is popul= ated), + * 0 if @src can't be opened and @skipInaccessible is true (no errors are + * reported) or -1 otherwise (errors are reported). */ static int qemuDomainStorageOpenStat(virQEMUDriverPtr driver, @@ -12262,9 +12265,13 @@ qemuDomainStorageOpenStat(virQEMUDriverPtr driver, virDomainObjPtr vm, virStorageSourcePtr src, int *ret_fd, - struct stat *ret_sb) + struct stat *ret_sb, + bool skipInaccessible) { if (virStorageSourceIsLocalStorage(src)) { + if (skipInaccessible && !virFileExists(src->path)) + return 0; + if ((*ret_fd =3D qemuOpenFile(driver, vm, src->path, O_RDONLY, NULL)) < 0) return -1; @@ -12275,6 +12282,9 @@ qemuDomainStorageOpenStat(virQEMUDriverPtr driver, return -1; } } else { + if (skipInaccessible && virStorageFileSupportsBackingChainTraversa= l(src) <=3D 0) + return 0; + if (virStorageFileInitAs(src, cfg->user, cfg->group) < 0) return -1; @@ -12286,7 +12296,7 @@ qemuDomainStorageOpenStat(virQEMUDriverPtr driver, } } - return 0; + return 1; } @@ -12321,7 +12331,7 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr dr= iver, if (virStorageSourceIsEmpty(src)) return 0; - if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb) < 0) + if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) <= 0) return -1; ret =3D virStorageSourceUpdatePhysicalSize(src, fd, &sb); @@ -12372,7 +12382,7 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver, char *buf =3D NULL; ssize_t len; - if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb) < 0) + if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) <= 0) goto cleanup; if (virStorageSourceIsLocalStorage(src)) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 18:57:23 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1565801981; cv=none; d=zoho.com; s=zohoarc; b=D0aw2c1N781dI37RcPGiwxArRSSrOKBcg2VkA5KeL2UXM8jYt/lj+CCTeXvaBxmNRzQQHAROcCvlE4DwlxISQ8NfUUK1fD2I+BRU4yCksbyd1l8PxxJ4Bxuym70F67vkWNtoD3Rku0hBJvULBPkHoT+3shr0xUV+cK1y90eSIWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565801981; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=c7yTNH5Qir+MmQwLUYuqbOAYkU66U4vrSCdK28wM8Is=; b=WbNqgs3eZbYGlCYsmgcdx7WhmOpp/d6Pl4uaw26DeiU9M0EWAGkpN9H7Z3xRtwJyeeFDDALD0IgBrA2f0gdFZU1MPPfFYCcmz1ljL25g4YcBX47+MXRuC3n4Q90mGBaQ/eYDMW0FWUbhw2qmh82mDB+PDjozn0ke/chpRn7bpZo= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565801981040626.4590531519884; Wed, 14 Aug 2019 09:59:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF4CF31752BE; Wed, 14 Aug 2019 16:59:37 +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 85FC06762D; Wed, 14 Aug 2019 16:59:37 +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 44E9F180BA98; Wed, 14 Aug 2019 16:59:37 +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 x7EGxSf1028592 for ; Wed, 14 Aug 2019 12:59:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2DE9C6762C; Wed, 14 Aug 2019 16:59:28 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAD358BE2F for ; Wed, 14 Aug 2019 16:59:27 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 14 Aug 2019 18:59:18 +0200 Message-Id: <5d2ca4905527fcf62300c62210d14ab98e135b75.1565801782.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/6] util: storagefile: Don't report errors from virStorageSourceUpdatePhysicalSize 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-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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 14 Aug 2019 16:59:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virStorageSourceUpdatePhysicalSize is called only from qemuDomainStorageUpdatePhysical and all callers of it reset the libvirt error if -1 is returned. Don't bother setting the error in the first place. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 4011187a7e..21bd1f00c9 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3746,7 +3746,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr pa= rent) * To be called for domain storage source reporting as the volume code does * not set/use the 'type' field for the voldef->source.target * - * Returns 0 on success, -1 on error. + * Returns 0 on success, -1 on error. No libvirt errors are reported. */ int virStorageSourceUpdatePhysicalSize(virStorageSourcePtr src, @@ -3763,11 +3763,8 @@ virStorageSourceUpdatePhysicalSize(virStorageSourceP= tr src, break; case VIR_STORAGE_TYPE_BLOCK: - if ((end =3D lseek(fd, 0, SEEK_END)) =3D=3D (off_t) -1) { - virReportSystemError(errno, _("failed to seek to end of '%s'"), - src->path); + if ((end =3D lseek(fd, 0, SEEK_END)) =3D=3D (off_t) -1) return -1; - } src->physical =3D end; break; @@ -3780,12 +3777,7 @@ virStorageSourceUpdatePhysicalSize(virStorageSourceP= tr src, case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot retrieve physical for path '%s' type '%s'= "), - NULLSTR(src->path), - virStorageTypeToString(actual_type)); return -1; - break; } return 0; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 18:57:23 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1565801982; cv=none; d=zoho.com; s=zohoarc; b=DgSfWG4jU/KENoQ4/zCj/vVAjwch/UQSflce41mTTLoM9GtrHVWVQyJxzaDt73UUBResbbWsnrCamqfOoOEmtjOGuZLJLY8A+Ihgk/XM97dVpFqaiOcZPHGsAc5BTSdPpEIznODwK5RMQycXt98zScExGwsHSMdlmhFDbDlqzT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565801982; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gOZXRsFAIPuSPGq/PN+PAHa/Anb1baq5qm8EDztlpy0=; b=GmI+XdmjEdG2UdmitstGbAgFhmhafK+3sEySlOXN4VDb1uWEavAEtCC9BSZSsdtxPvWD7JfvyRmE+SSZr8vSKvlmHKDU2YBX4iJ1A4hHiUi6OGr+81S4BCLuEJFCCw2hQcgHFOINgw7PGugFW8OJ39YcQDOhLbZX195s7aaMhpc= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156580198289669.43342101213148; Wed, 14 Aug 2019 09:59:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B60C2C065123; Wed, 14 Aug 2019 16:59:40 +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 8FD1080A5E; Wed, 14 Aug 2019 16:59:40 +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 5AEAE180BA9E; Wed, 14 Aug 2019 16:59:40 +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 x7EGxTEH028597 for ; Wed, 14 Aug 2019 12:59:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2CBF5D9DC; Wed, 14 Aug 2019 16:59:28 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 781A06762C for ; Wed, 14 Aug 2019 16:59:28 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 14 Aug 2019 18:59:19 +0200 Message-Id: <59427712009e50f7779262e8d52a9a6157f8bf59.1565801782.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/6] qemu: driver: Improve error suppression in qemuDomainStorageUpdatePhysical 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-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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 14 Aug 2019 16:59:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" None of the callers of qemuDomainStorageUpdatePhysical care about errors. Use the new flag for qemuDomainStorageOpenStat which suppresses some errors and move the reset of the rest of the uncommon errors into this function. Document what is happening in a comment for the function. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cc296c1fe3..2dffef9642 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12318,6 +12318,19 @@ qemuDomainStorageCloseStat(virStorageSourcePtr src, } +/** + * qemuDomainStorageUpdatePhysical: + * @driver: qemu driver + * @cfg: qemu driver configuration object + * @vm: domain object + * @src: storage source to update + * + * Update the physical size of the disk by reading the actual size of the = image + * on disk. + * + * Returns 0 on successful update and -1 otherwise (some uncommon errors m= ay be + * reported but are reset (thus only logged)). + */ static int qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg, @@ -12331,8 +12344,11 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr d= river, if (virStorageSourceIsEmpty(src)) return 0; - if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) <= 0) + if ((ret =3D qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb,= true)) <=3D 0) { + if (ret < 0) + virResetLastError(); return -1; + } ret =3D virStorageSourceUpdatePhysicalSize(src, fd, &sb); @@ -12504,7 +12520,6 @@ qemuDomainGetBlockInfo(virDomainPtr dom, if (qemuDomainStorageUpdatePhysical(driver, cfg, vm, disk->src) = =3D=3D 0) { info->physical =3D disk->src->physical; } else { - virResetLastError(); info->physical =3D entry->physical; } } else { @@ -21376,12 +21391,9 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver, QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, "physical", entry->physical); } else { - if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) =3D=3D = 0) { + if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) =3D=3D = 0) QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, "physical", src->physical); - } else { - virResetLastError(); - } } ret =3D 0; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 18:57:23 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1565801981; cv=none; d=zoho.com; s=zohoarc; b=UOHCTIfZ/EWGqxToKE9jqpWhqGCfC0i38coW1a16MLV7q4EYN9q5dWmC2Ehx+GO3SeelkBCgBJyx8h4rtOwvUfhyYlA/J9LVcNU0NVh5eqQ1lfWf0L0QaW5TuesGCYwnBUWpPCnPt0MRA3/50A3NDr3DbGXDhRYfknBByqUg0CE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565801981; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4BXovlf+7EzW3R8MmesFvpsW7777lwZ0BdEGN1aAp7Y=; b=IQ8o2z4QByfvvOXLT4jou5ZuABFc98NIH88a1EfGKSvDv9QgBUagT4lC5jTUDgNknM4VEzy8DemE7gJLyr6u3NsCUBm2JmLUYImkXbWFTQOj9zCTaWxhlFav5nGL5hpGxg0vgi+ycricGFW8bV9e8xVFiqj8g3UJ00NTQR1OLl4= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565801981366547.4503508330723; Wed, 14 Aug 2019 09:59:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E8B664127; Wed, 14 Aug 2019 16:59:39 +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 ECDBF80A3F; Wed, 14 Aug 2019 16:59:38 +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 AC5E4180BA9B; Wed, 14 Aug 2019 16:59:38 +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 x7EGxTjV028606 for ; Wed, 14 Aug 2019 12:59:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB3208B161; Wed, 14 Aug 2019 16:59:29 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 458105D9DC for ; Wed, 14 Aug 2019 16:59:29 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 14 Aug 2019 18:59:20 +0200 Message-Id: <716c05679ceb2c0bca5cc637e40900421bb37dfb.1565801782.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/6] qemu: Allow suppressing errors from qemuStorageLimitsRefresh 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-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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 14 Aug 2019 16:59:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" qemuStorageLimitsRefresh uses qemuDomainStorageOpenStat internally and there are callers which don't care about the error. Propagate the skipInaccessible flag so that we can log less errors. Callers currently don't care about the return value change. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2dffef9642..243a8ac4cf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12363,6 +12363,7 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr dr= iver, * @cfg: driver configuration data * @vm: domain object * @src: storage source data + * @skipInaccessible: Suppress reporting of common errors when accessing @= src * * Refresh the capacity and allocation limits of a given storage source. * @@ -12384,22 +12385,27 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr = driver, * is sparse, but the amount of sparseness changes due to writes or * punching holes), and physical size of a non-raw file can change. * - * Returns 0 on success, -1 on failure + * Returns 1 if @src was successfully updated, 0 if @src can't be opened a= nd + * @skipInaccessible is true (no errors are reported) or -1 otherwise (err= ors + * are reported). */ static int qemuStorageLimitsRefresh(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg, virDomainObjPtr vm, - virStorageSourcePtr src) + virStorageSourcePtr src, + bool skipInaccessible) { + int rc; int ret =3D -1; int fd =3D -1; struct stat sb; char *buf =3D NULL; ssize_t len; - if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) <= 0) - goto cleanup; + if ((rc =3D qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, + skipInaccessible)) <=3D 0) + return rc; if (virStorageSourceIsLocalStorage(src)) { if ((len =3D virFileReadHeaderFD(fd, VIR_STORAGE_MAX_HEADER, &buf)= ) < 0) { @@ -12427,7 +12433,7 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver, S_ISBLK(sb.st_mode)) src->allocation =3D 0; - ret =3D 0; + ret =3D 1; cleanup: VIR_FREE(buf); @@ -12477,7 +12483,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom, /* for inactive domains we have to peek into the files */ if (!virDomainObjIsActive(vm)) { - if ((qemuStorageLimitsRefresh(driver, cfg, vm, disk->src)) < 0) + if ((qemuStorageLimitsRefresh(driver, cfg, vm, disk->src, false)) = < 0) goto endjob; info->capacity =3D disk->src->capacity; @@ -21295,7 +21301,7 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr= driver, if (virStorageSourceIsEmpty(src)) return 0; - if (qemuStorageLimitsRefresh(driver, cfg, dom, src) < 0) { + if (qemuStorageLimitsRefresh(driver, cfg, dom, src, false) < 0) { virResetLastError(); return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 18:57:23 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1565801985; cv=none; d=zoho.com; s=zohoarc; b=n+4GOL7y+UFxGIfeetIhaM4VfZSoHFWx+M2V2hsVWYdPkj+9uPIghV6E7ti0CgzhLJr0MMMsEYy3HSsj/RQfEiwgty/a/Y3guyFNPGqUJ/ljQwnljUG0DGsck68eMPnZdNIdfpNhybTwuuSEWqXzPzoBXegv9CN18UcZGYFoQCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565801985; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=HF5+1C1ewEe6or3wRluQp/u1tE6PXtPVfHEwtdJTEmE=; b=QMdmdGERMsvU5LND7aZ18ETCCWwSJWXaMU/HW16a66pjrlqnEuyXsZcv8l+RM2OI6shAF8JD9OghAJtz3AdTn2W1s+MC+lqXHWEzRELjkHMts/fNfFz3MbqBZMaqwxNcJTa8+9t/zzoWuoHhcyGkDa1G8p+mmXjqKboh0+azl+0= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565801985048831.4811973331867; Wed, 14 Aug 2019 09:59:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7947923B3; Wed, 14 Aug 2019 16:59:43 +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 C0D3B8049A; Wed, 14 Aug 2019 16:59:43 +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 86A952551D; Wed, 14 Aug 2019 16:59:43 +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 x7EGxUZl028621 for ; Wed, 14 Aug 2019 12:59:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 882236762C; Wed, 14 Aug 2019 16:59:30 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 126E588B26 for ; Wed, 14 Aug 2019 16:59:29 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 14 Aug 2019 18:59:21 +0200 Message-Id: <5f14709b5d64a430dcb99934fc8d2a8032b0c766.1565801782.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/6] qemu: Don't report some ignored errors in qemuDomainGetStatsOneBlockFallback 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-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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 14 Aug 2019 16:59:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function ignores all errors from qemuStorageLimitsRefresh by calling virResetLastError. This still logs them. Since qemuStorageLimitsRefresh allows suppressing some, do so. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 243a8ac4cf..f44d134b92 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -21301,7 +21301,7 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr= driver, if (virStorageSourceIsEmpty(src)) return 0; - if (qemuStorageLimitsRefresh(driver, cfg, dom, src, false) < 0) { + if (qemuStorageLimitsRefresh(driver, cfg, dom, src, true) <=3D 0) { virResetLastError(); return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list