From nobody Sun Feb 8 16:31:03 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 1505829727109648.4980017953756; Tue, 19 Sep 2017 07:02:07 -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 CDBDC806CB; Tue, 19 Sep 2017 14:02:05 +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 0D6C8679F1; Tue, 19 Sep 2017 14:02:05 +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 9B8921806104; Tue, 19 Sep 2017 14:02:04 +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 v8JDQCJG013081 for ; Tue, 19 Sep 2017 09:26:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F9E1197F5; Tue, 19 Sep 2017 13:26:12 +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 04F616017B for ; Tue, 19 Sep 2017 13:26:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CDBDC806CB 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:16 -0400 Message-Id: <20170919132518.28151-18-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 17/19] storage: Use virStoragePoolObjGetDef accessor for ZFS 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 19 Sep 2017 14:02:06 +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_zfs.c | 39 +++++++++++++++++++++++------------= ---- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index c2662815a..198c788ac 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -86,10 +86,11 @@ static int virStorageBackendZFSCheckPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, bool *isActive) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *devpath; =20 if (virAsprintf(&devpath, "/dev/zvol/%s", - pool->def->source.name) < 0) + def->source.name) < 0) return -1; *isActive =3D virFileIsDir(devpath); VIR_FREE(devpath); @@ -109,6 +110,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, char *vol_name; bool is_new_vol =3D false; virStorageVolDefPtr volume =3D NULL; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 if (!(tokens =3D virStringSplitCount(volume_string, "\t", 0, &count))) return -1; @@ -142,7 +144,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, =20 if (volume->target.path =3D=3D NULL) { if (virAsprintf(&volume->target.path, "%s/%s", - pool->def->target.path, volume->name) < 0) + def->target.path, volume->name) < 0) goto cleanup; } =20 @@ -178,6 +180,7 @@ static int virStorageBackendZFSFindVols(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; char *volumes_list =3D NULL; char **lines =3D NULL; @@ -199,7 +202,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool, "list", "-Hp", "-t", "volume", "-r", "-o", "name,volsize,refreservation", - pool->def->source.name, + def->source.name, NULL); virCommandSetOutputBuffer(cmd, &volumes_list); if (virCommandRun(cmd, NULL) < 0) @@ -228,6 +231,7 @@ static int virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool ATTRIBUTE_UNUSED) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; char *zpool_props =3D NULL; char **lines =3D NULL; @@ -247,7 +251,7 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn ATTR= IBUTE_UNUSED, cmd =3D virCommandNewArgList(ZPOOL, "get", "-Hp", "health,size,free,allocated", - pool->def->source.name, + def->source.name, NULL); virCommandSetOutputBuffer(cmd, &zpool_props); if (virCommandRun(cmd, NULL) < 0) @@ -279,11 +283,11 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn AT= TRIBUTE_UNUSED, goto cleanup; =20 if (STREQ(prop_name, "free")) - pool->def->available =3D value; + def->available =3D value; else if (STREQ(prop_name, "size")) - pool->def->capacity =3D value; + def->capacity =3D value; else if (STREQ(prop_name, "allocated")) - pool->def->allocation =3D value; + def->allocation =3D value; } } =20 @@ -305,6 +309,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIB= UTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; int ret =3D -1; int volmode_needed =3D -1; @@ -320,7 +325,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIB= UTE_UNUSED, =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 if (VIR_STRDUP(vol->key, vol->target.path) < 0) @@ -356,8 +361,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIB= UTE_UNUSED, virCommandAddArg(cmd, "-V"); virCommandAddArgFormat(cmd, "%lluK", VIR_DIV_UP(vol->target.capacity, 1024)); - virCommandAddArgFormat(cmd, "%s/%s", - pool->def->source.name, vol->name); + virCommandAddArgFormat(cmd, "%s/%s", def->source.name, vol->name); =20 if (virCommandRun(cmd, NULL) < 0) goto cleanup; @@ -379,6 +383,7 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIB= UTE_UNUSED, unsigned int flags) { int ret =3D -1; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr destroy_cmd =3D NULL; =20 virCheckFlags(0, -1); @@ -386,7 +391,7 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIB= UTE_UNUSED, destroy_cmd =3D virCommandNewArgList(ZFS, "destroy", NULL); =20 virCommandAddArgFormat(destroy_cmd, "%s/%s", - pool->def->source.name, vol->name); + def->source.name, vol->name); =20 if (virCommandRun(destroy_cmd, NULL) < 0) goto cleanup; @@ -402,23 +407,24 @@ virStorageBackendZFSBuildPool(virConnectPtr conn ATTR= IBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; size_t i; int ret =3D -1; =20 virCheckFlags(0, -1); =20 - if (pool->def->source.ndevice =3D=3D 0) { + if (def->source.ndevice =3D=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("missing source devices")); return -1; } =20 cmd =3D virCommandNewArgList(ZPOOL, "create", - pool->def->source.name, NULL); + def->source.name, NULL); =20 - for (i =3D 0; i < pool->def->source.ndevice; i++) - virCommandAddArg(cmd, pool->def->source.devices[i].path); + for (i =3D 0; i < def->source.ndevice; i++) + virCommandAddArg(cmd, def->source.devices[i].path); =20 if (virCommandRun(cmd, NULL) < 0) goto cleanup; @@ -435,13 +441,14 @@ virStorageBackendZFSDeletePool(virConnectPtr conn ATT= RIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; int ret =3D -1; =20 virCheckFlags(0, -1); =20 cmd =3D virCommandNewArgList(ZPOOL, "destroy", - pool->def->source.name, NULL); + def->source.name, NULL); =20 if (virCommandRun(cmd, NULL) < 0) goto cleanup; --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list