From nobody Sun Feb 8 12:37:47 2026 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 1505828573124360.17873586019755; Tue, 19 Sep 2017 06:42:53 -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 1DF5E80C06; Tue, 19 Sep 2017 13:42:52 +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 EA7F260466; Tue, 19 Sep 2017 13:42:51 +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 A9F1C410AD; Tue, 19 Sep 2017 13:42:51 +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 v8JDQ304012659 for ; Tue, 19 Sep 2017 09:26:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 10C9B6134A; Tue, 19 Sep 2017 13:26:02 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7D4D1981E for ; Tue, 19 Sep 2017 13:26:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1DF5E80C06 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Tue, 19 Sep 2017 09:25:07 -0400 Message-Id: <20170919132518.28151-9-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/19] storage: Use virStoragePoolObjGetDef accessor for Logical backend 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 19 Sep 2017 13:42:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In preparation for privatizing the object, use the accessor. Signed-off-by: John Ferlan --- src/storage/storage_backend_logical.c | 63 ++++++++++++++++++++-----------= ---- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 7bfe211c2..0ad357729 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -53,10 +53,11 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr = pool, int on) { int ret; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D virCommandNewArgList(VGCHANGE, on ? "-aly" : "-aln", - pool->def->source.name, + def->source.name, NULL); =20 ret =3D virCommandRun(cmd, NULL); @@ -266,6 +267,7 @@ virStorageBackendLogicalMakeVol(char **const groups, { struct virStorageBackendLogicalPoolVolData *data =3D opaque; virStoragePoolObjPtr pool =3D data->pool; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStorageVolDefPtr vol =3D NULL; bool is_new_vol =3D false; int ret =3D -1; @@ -309,7 +311,7 @@ virStorageBackendLogicalMakeVol(char **const groups, =20 if (vol->target.path =3D=3D NULL) { if (virAsprintf(&vol->target.path, "%s/%s", - pool->def->target.path, vol->name) < 0) + def->target.path, vol->name) < 0) goto cleanup; } =20 @@ -334,7 +336,7 @@ virStorageBackendLogicalMakeVol(char **const groups, goto cleanup; =20 if (virAsprintf(&vol->target.backingStore->path, "%s/%s", - pool->def->target.path, groups[1]) < 0) + def->target.path, groups[1]) < 0) goto cleanup; =20 vol->target.backingStore->format =3D VIR_STORAGE_POOL_LOGICAL_LVM2; @@ -433,6 +435,7 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr po= ol, }; int ret =3D -1; virCommandPtr cmd; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); struct virStorageBackendLogicalPoolVolData cbdata =3D { .pool =3D pool, .vol =3D vol, @@ -446,7 +449,7 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr po= ol, "--nosuffix", "--options", "lv_name,origin,uuid,devices,segtype,stripe= s,seg_size,vg_extent_size,size,lv_attr", - pool->def->source.name, + def->source.name, NULL); if (virCommandRunRegex(cmd, 1, @@ -469,11 +472,13 @@ virStorageBackendLogicalRefreshPoolFunc(char **const = groups, void *data) { virStoragePoolObjPtr pool =3D data; - if (virStrToLong_ull(groups[0], NULL, 10, &pool->def->capacity) < 0) + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + + if (virStrToLong_ull(groups[0], NULL, 10, &def->capacity) < 0) return -1; - if (virStrToLong_ull(groups[1], NULL, 10, &pool->def->available) < 0) + if (virStrToLong_ull(groups[1], NULL, 10, &def->available) < 0) return -1; - pool->def->allocation =3D pool->def->capacity - pool->def->available; + def->allocation =3D def->capacity - def->available; =20 return 0; } @@ -631,6 +636,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr c= onn ATTRIBUTE_UNUSED, static bool virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStoragePoolSourceList sourceList; virStoragePoolSource *thisSource =3D NULL; size_t i, j; @@ -646,14 +652,14 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoo= lObjPtr pool) /* Search the pvs output for this pool's source.name */ for (i =3D 0; i < sourceList.nsources; i++) { thisSource =3D &sourceList.sources[i]; - if (STREQ(thisSource->name, pool->def->source.name)) + if (STREQ(thisSource->name, def->source.name)) break; } =20 if (i =3D=3D sourceList.nsources) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot find logical volume group name '%s'"), - pool->def->source.name); + def->source.name); goto cleanup; } =20 @@ -661,7 +667,7 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolO= bjPtr pool) * they match as well; otherwise, matching can only occur on the * pool's name. */ - if (!pool->def->source.ndevice) { + if (!def->source.ndevice) { ret =3D true; goto cleanup; } @@ -669,9 +675,9 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolO= bjPtr pool) /* Let's make sure the pool's device(s) match what the pvs output has * for volume group devices. */ - for (i =3D 0; i < pool->def->source.ndevice; i++) { + for (i =3D 0; i < def->source.ndevice; i++) { for (j =3D 0; j < thisSource->ndevice; j++) { - if (STREQ(pool->def->source.devices[i].path, + if (STREQ(def->source.devices[i].path, thisSource->devices[j].path)) matchcount++; } @@ -683,7 +689,7 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolO= bjPtr pool) if (matchcount =3D=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot find any matching source devices for logi= cal " - "volume group '%s'"), pool->def->source.name); + "volume group '%s'"), def->source.name); goto cleanup; } =20 @@ -692,7 +698,7 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolO= bjPtr pool) * to 'add' to or 'remove' from the volume group outside of libvirt's * knowledge. Rather than fail on that, provide a warning and move on. */ - if (matchcount !=3D pool->def->source.ndevice) + if (matchcount !=3D def->source.ndevice) VIR_WARN("pool device list count doesn't match pvs device list cou= nt"); =20 ret =3D true; @@ -710,10 +716,12 @@ static int virStorageBackendLogicalCheckPool(virStoragePoolObjPtr pool, bool *isActive) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + /* If we can find the target.path as well as ensure that the * pool's def source */ - *isActive =3D virFileExists(pool->def->target.path) && + *isActive =3D virFileExists(def->target.path) && virStorageBackendLogicalMatchPoolSource(pool); return 0; } @@ -738,6 +746,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn AT= TRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr vgcmd =3D NULL; int ret =3D -1; size_t i =3D 0; @@ -749,10 +758,10 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn = ATTRIBUTE_UNUSED, VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, cleanup); =20 - vgcmd =3D virCommandNewArgList(VGCREATE, pool->def->source.name, NULL); + vgcmd =3D virCommandNewArgList(VGCREATE, def->source.name, NULL); =20 - for (i =3D 0; i < pool->def->source.ndevice; i++) { - const char *path =3D pool->def->source.devices[i].path; + for (i =3D 0; i < def->source.ndevice; i++) { + const char *path =3D def->source.devices[i].path; =20 /* The blkid FS and Part probing code doesn't know "lvm2" (this * pool's only format type), but it does know "LVM2_member", so @@ -782,7 +791,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn AT= TRIBUTE_UNUSED, if (ret < 0) { size_t j; for (j =3D 0; j < i; j++) - virStorageBackendLogicalRemoveDevice(pool->def->source.devices= [j].path); + virStorageBackendLogicalRemoveDevice(def->source.devices[j].pa= th); } return ret; } @@ -806,6 +815,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn = ATTRIBUTE_UNUSED, int vars[] =3D { 2 }; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; int ret =3D -1; =20 @@ -822,7 +832,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn = ATTRIBUTE_UNUSED, "--unbuffered", "--nosuffix", "--options", "vg_size,vg_free", - pool->def->source.name, + def->source.name, NULL); =20 /* Now get basic volgrp metadata */ @@ -865,6 +875,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn A= TTRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; size_t i; int ret =3D -1; @@ -873,14 +884,14 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn= ATTRIBUTE_UNUSED, =20 /* first remove the volume group */ cmd =3D virCommandNewArgList(VGREMOVE, - "-f", pool->def->source.name, + "-f", def->source.name, NULL); if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 /* now remove the pv devices and clear them out */ - for (i =3D 0; i < pool->def->source.ndevice; i++) - virStorageBackendLogicalRemoveDevice(pool->def->source.devices[i].= path); + for (i =3D 0; i < def->source.ndevice; i++) + virStorageBackendLogicalRemoveDevice(def->source.devices[i].path); =20 ret =3D 0; =20 @@ -931,6 +942,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, virStorageVolDefPtr vol) { int fd =3D -1; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; virErrorPtr err; struct stat sb; @@ -947,8 +959,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, =20 VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", - pool->def->target.path, - vol->name) < 0) + def->target.path, vol->name) < 0) return -1; =20 cmd =3D virCommandNewArgList(LVCREATE, @@ -968,7 +979,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, if (vol->target.backingStore) virCommandAddArgList(cmd, "-s", vol->target.backingStore->path, NU= LL); else - virCommandAddArg(cmd, pool->def->source.name); + virCommandAddArg(cmd, def->source.name); =20 if (virCommandRun(cmd, NULL) < 0) goto error; --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list