From nobody Sun Apr 28 08:31:12 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1503613813544451.95801526013645; Thu, 24 Aug 2017 15:30:13 -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 8832D7E44A; Thu, 24 Aug 2017 22:30:11 +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 1F1B439C1; Thu, 24 Aug 2017 22:30:11 +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 9B7C54EBDD; Thu, 24 Aug 2017 22:29:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7OMSWTG014553 for ; Thu, 24 Aug 2017 18:28:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id F0EC4189AA; Thu, 24 Aug 2017 22:28:32 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-123-165.rdu2.redhat.com [10.10.123.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC3BD61348 for ; Thu, 24 Aug 2017 22:28:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8832D7E44A Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 24 Aug 2017 18:28:28 -0400 Message-Id: <20170824222829.22398-2-jferlan@redhat.com> In-Reply-To: <20170824222829.22398-1-jferlan@redhat.com> References: <20170824222829.22398-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] storage: Introduce virStorageBackendRefreshVolTargetUpdate 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 24 Aug 2017 22:30:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Create a separate function to handle the volume target update via probe processing. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 82 ++++++++++++++++++++++++++++++------------= ---- src/storage/storage_util.h | 3 ++ 2 files changed, 57 insertions(+), 28 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index e1fe162..b0a698a 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -3517,6 +3517,58 @@ storageBackendProbeTarget(virStorageSourcePtr target, =20 =20 /** + * virStorageBackendRefreshVolTargetUpdate: + * @vol: Volume def that needs updating + * + * Attempt to probe the volume in order to get more details. + * + * Returns 0 on success, -2 to ignore failure, -1 on failure + */ +int +virStorageBackendRefreshVolTargetUpdate(virStorageVolDefPtr vol) +{ + int err; + + /* Real value is filled in during probe */ + vol->target.format =3D VIR_STORAGE_FILE_RAW; + + if ((err =3D storageBackendProbeTarget(&vol->target, + &vol->target.encryption)) < 0) { + if (err =3D=3D -2) { + return -2; + } else if (err =3D=3D -3) { + /* The backing file is currently unavailable, its format is not + * explicitly specified, the probe to auto detect the format + * failed: continue with faked RAW format, since AUTO will + * break virStorageVolTargetDefFormat() generating the line + * . */ + } else { + return -1; + } + } + + /* directory based volume */ + if (vol->target.format =3D=3D VIR_STORAGE_FILE_DIR) + vol->type =3D VIR_STORAGE_VOL_DIR; + + if (vol->target.format =3D=3D VIR_STORAGE_FILE_PLOOP) + vol->type =3D VIR_STORAGE_VOL_PLOOP; + + if (vol->target.backingStore) { + ignore_value(storageBackendUpdateVolTargetInfo(VIR_STORAGE_VOL_FIL= E, + vol->target.backing= Store, + false, + VIR_STORAGE_VOL_OPE= N_DEFAULT, 0)); + /* If this failed, the backing file is currently unavailable, + * the capacity, allocation, owner, group and mode are unknown. + * An error message was raised, but we just continue. */ + } + + return 0; +} + + +/** * Iterate over the pool's directory and enumerate all disk images * within it. This is non-recursive. */ @@ -3552,7 +3604,6 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, goto cleanup; =20 vol->type =3D VIR_STORAGE_VOL_FILE; - vol->target.format =3D VIR_STORAGE_FILE_RAW; /* Real value is fill= ed in during probe */ if (virAsprintf(&vol->target.path, "%s/%s", pool->def->target.path, vol->name) < 0) @@ -3561,40 +3612,15 @@ virStorageBackendRefreshLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, if (VIR_STRDUP(vol->key, vol->target.path) < 0) goto cleanup; =20 - if ((err =3D storageBackendProbeTarget(&vol->target, - &vol->target.encryption)) < 0= ) { + if ((err =3D virStorageBackendRefreshVolTargetUpdate(vol)) < 0) { if (err =3D=3D -2) { /* Silently ignore non-regular files, * eg 'lost+found', dangling symbolic link */ virStorageVolDefFree(vol); vol =3D NULL; continue; - } else if (err =3D=3D -3) { - /* The backing file is currently unavailable, its format i= s not - * explicitly specified, the probe to auto detect the form= at - * failed: continue with faked RAW format, since AUTO will - * break virStorageVolTargetDefFormat() generating the line - * . */ - } else { - goto cleanup; } - } - - /* directory based volume */ - if (vol->target.format =3D=3D VIR_STORAGE_FILE_DIR) - vol->type =3D VIR_STORAGE_VOL_DIR; - - if (vol->target.format =3D=3D VIR_STORAGE_FILE_PLOOP) - vol->type =3D VIR_STORAGE_VOL_PLOOP; - - if (vol->target.backingStore) { - ignore_value(storageBackendUpdateVolTargetInfo(VIR_STORAGE_VOL= _FILE, - vol->target.bac= kingStore, - false, - VIR_STORAGE_VOL= _OPEN_DEFAULT, 0)); - /* If this failed, the backing file is currently unavailable, - * the capacity, allocation, owner, group and mode are unknown. - * An error message was raised, but we just continue. */ + goto cleanup; } =20 if (VIR_APPEND_ELEMENT(pool->volumes.objs, pool->volumes.count, vo= l) < 0) diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index 6f2a1b1..00793ff 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -90,6 +90,9 @@ int virStorageBackendDeleteLocal(virConnectPtr conn, virStoragePoolObjPtr pool, unsigned int flags); =20 +int +virStorageBackendRefreshVolTargetUpdate(virStorageVolDefPtr vol); + int virStorageBackendRefreshLocal(virConnectPtr conn, virStoragePoolObjPtr pool); =20 --=20 2.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 08:31:12 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1503613834830483.5905795126964; Thu, 24 Aug 2017 15:30:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78766C04B958; Thu, 24 Aug 2017 22:30:32 +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 5904174453; Thu, 24 Aug 2017 22:30:32 +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 1AD2F3FC71; Thu, 24 Aug 2017 22:30:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7OMSXpj014560 for ; Thu, 24 Aug 2017 18:28:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 50A9C189AA; Thu, 24 Aug 2017 22:28:33 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-123-165.rdu2.redhat.com [10.10.123.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C27118A4E for ; Thu, 24 Aug 2017 22:28:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 78766C04B958 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 24 Aug 2017 18:28:29 -0400 Message-Id: <20170824222829.22398-3-jferlan@redhat.com> In-Reply-To: <20170824222829.22398-1-jferlan@redhat.com> References: <20170824222829.22398-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] storage: Use virStorageBackendRefreshVolTargetUpdate after wipeVol 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 24 Aug 2017 22:30:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1437797 Rather than using refreshVol which essentially only updates the allocation, capacity, and permissions for the volume, but not the format which does get updated in a pool refresh - let's use the same helper that pool refresh uses in order to update the volume target. Signed-off-by: John Ferlan --- src/storage/storage_driver.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 8552120..7cf5943 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2496,8 +2496,11 @@ storageVolWipePattern(virStorageVolPtr vol, if (backend->wipeVol(vol->conn, obj, voldef, algorithm, flags) < 0) goto cleanup; =20 - if (backend->refreshVol && - backend->refreshVol(vol->conn, obj, voldef) < 0) + /* Instead of using the refreshVol, since much changes on the target + * volume, let's update using the same function as refreshPool would + * use when it discovers a volume. The only failure to capture is -1, + * we can ignore -2. */ + if (virStorageBackendRefreshVolTargetUpdate(voldef) =3D=3D -1) goto cleanup; =20 ret =3D 0; --=20 2.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list