From nobody Mon Apr 29 05:39:06 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 1507290364877440.3312610435479; Fri, 6 Oct 2017 04:46:04 -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 7344C8124A; Fri, 6 Oct 2017 11:46:03 +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 4A4206682A; Fri, 6 Oct 2017 11:46:03 +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 E14C2410B4; Fri, 6 Oct 2017 11:46:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v96BNM5n028149 for ; Fri, 6 Oct 2017 07:23:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5E12260603; Fri, 6 Oct 2017 11:23:22 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-17.phx2.redhat.com [10.3.116.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2573760605 for ; Fri, 6 Oct 2017 11:23:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7344C8124A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Fri, 6 Oct 2017 07:23:12 -0400 Message-Id: <20171006112317.29715-2-jferlan@redhat.com> In-Reply-To: <20171006112317.29715-1-jferlan@redhat.com> References: <20171006112317.29715-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 1/6] storage: Use virStoragePoolObjGetDef accessor for storage_util 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.25]); Fri, 06 Oct 2017 11:46:04 +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_util.c | 116 ++++++++++++++++++++++++-----------------= ---- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index b23b6dd1d1..a10e4590f3 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -396,6 +396,7 @@ storageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UN= USED, virStorageVolDefPtr inputvol, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); int ret =3D -1; int fd =3D -1; int operation_flags; @@ -431,7 +432,7 @@ storageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UN= USED, } =20 operation_flags =3D VIR_FILE_OPEN_FORCE_MODE | VIR_FILE_OPEN_FORCE_OWN= ER; - if (pool->def->type =3D=3D VIR_STORAGE_POOL_NETFS) + if (def->type =3D=3D VIR_STORAGE_POOL_NETFS) operation_flags |=3D VIR_FILE_OPEN_FORK; =20 if (vol->target.perms->mode !=3D (mode_t) -1) @@ -597,6 +598,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr= pool, virStorageVolDefPtr vol, virCommandPtr cmd) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); struct stat st; gid_t gid; uid_t uid; @@ -606,7 +608,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr= pool, bool filecreated =3D false; int ret =3D -1; =20 - if ((pool->def->type =3D=3D VIR_STORAGE_POOL_NETFS) + if ((def->type =3D=3D VIR_STORAGE_POOL_NETFS) && (((geteuid() =3D=3D 0) && (vol->target.perms->uid !=3D (uid_t) -1) && (vol->target.perms->uid !=3D 0)) @@ -1029,6 +1031,7 @@ storageBackendCreateQemuImgSetBacking(virStoragePoolO= bjPtr pool, virStorageVolDefPtr inputvol, struct _virStorageBackendQemuImgInfo= *info) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); int accessRetCode =3D -1; char *absolutePath =3D NULL; =20 @@ -1071,7 +1074,7 @@ storageBackendCreateQemuImgSetBacking(virStoragePoolO= bjPtr pool, * validation. */ if ('/' !=3D *(info->backingPath) && - virAsprintf(&absolutePath, "%s/%s", pool->def->target.path, + virAsprintf(&absolutePath, "%s/%s", def->target.path, info->backingPath) < 0) return -1; accessRetCode =3D access(absolutePath ? absolutePath : @@ -1921,7 +1924,7 @@ virStorageBackendPoolPathIsStable(const char *path) =20 /* * Given a volume path directly in /dev/XXX, iterate over the - * entries in the directory pool->def->target.path and find the + * entries in the directory def->target.path and find the * first symlink pointing to the volume path. * * If, the target.path is /dev/, then return the original volume @@ -1940,6 +1943,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, const char *devpath, bool loop) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); DIR *dh; struct dirent *dent; char *stablepath; @@ -1948,8 +1952,8 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, int direrr; =20 /* Logical pools are under /dev but already have stable paths */ - if (pool->def->type =3D=3D VIR_STORAGE_POOL_LOGICAL || - !virStorageBackendPoolPathIsStable(pool->def->target.path)) + if (def->type =3D=3D VIR_STORAGE_POOL_LOGICAL || + !virStorageBackendPoolPathIsStable(def->target.path)) goto ret_strdup; =20 /* We loop here because /dev/disk/by-{id,path} may not have existed @@ -1957,7 +1961,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, * get created. */ reopen: - if (virDirOpenQuiet(&dh, pool->def->target.path) < 0) { + if (virDirOpenQuiet(&dh, def->target.path) < 0) { opentries++; if (loop && errno =3D=3D ENOENT && opentries < 50) { usleep(100 * 1000); @@ -1965,7 +1969,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, } virReportSystemError(errno, _("cannot read dir '%s'"), - pool->def->target.path); + def->target.path); return NULL; } =20 @@ -1981,8 +1985,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, retry: while ((direrr =3D virDirRead(dh, &dent, NULL)) > 0) { if (virAsprintf(&stablepath, "%s/%s", - pool->def->target.path, - dent->d_name) < 0) { + def->target.path, dent->d_name) < 0) { VIR_DIR_CLOSE(dh); return NULL; } @@ -2020,6 +2023,7 @@ createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED, virStorageVolDefPtr inputvol, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); int err; =20 virCheckFlags(0, -1); @@ -2044,7 +2048,7 @@ createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED, vol->target.perms->mode), vol->target.perms->uid, vol->target.perms->gid, - (pool->def->type =3D=3D VIR_STORAGE_POOL_NETFS + (def->type =3D=3D VIR_STORAGE_POOL_NETFS ? VIR_DIR_CREATE_AS_UID : 0))) < 0) { return -1; } @@ -2064,6 +2068,8 @@ virStorageBackendVolCreateLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + if (vol->target.format =3D=3D VIR_STORAGE_FILE_DIR) vol->type =3D VIR_STORAGE_VOL_DIR; else if (vol->target.format =3D=3D VIR_STORAGE_FILE_PLOOP) @@ -2081,8 +2087,7 @@ virStorageBackendVolCreateLocal(virConnectPtr conn AT= TRIBUTE_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 (virFileExists(vol->target.path)) { @@ -2768,6 +2773,7 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, int virStorageBackendBuildLocal(virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); int ret =3D -1; char *parent =3D NULL; char *p =3D NULL; @@ -2775,12 +2781,12 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr po= ol) bool needs_create_as_uid; unsigned int dir_create_flags; =20 - if (VIR_STRDUP(parent, pool->def->target.path) < 0) + if (VIR_STRDUP(parent, def->target.path) < 0) goto cleanup; if (!(p =3D strrchr(parent, '/'))) { virReportError(VIR_ERR_INVALID_ARG, _("path '%s' is not absolute"), - pool->def->target.path); + def->target.path); goto cleanup; } =20 @@ -2796,11 +2802,11 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr po= ol) } =20 dir_create_flags =3D VIR_DIR_CREATE_ALLOW_EXIST; - needs_create_as_uid =3D (pool->def->type =3D=3D VIR_STORAGE_POOL_NETFS= ); - mode =3D pool->def->target.perms.mode; + needs_create_as_uid =3D (def->type =3D=3D VIR_STORAGE_POOL_NETFS); + mode =3D def->target.perms.mode; =20 if (mode =3D=3D (mode_t) -1 && - (needs_create_as_uid || !virFileExists(pool->def->target.path))) + (needs_create_as_uid || !virFileExists(def->target.path))) mode =3D VIR_STORAGE_DEFAULT_POOL_PERM_MODE; if (needs_create_as_uid) dir_create_flags |=3D VIR_DIR_CREATE_AS_UID; @@ -2808,10 +2814,10 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr po= ol) /* Now create the final dir in the path with the uid/gid/mode * requested in the config. If the dir already exists, just set * the perms. */ - if (virDirCreate(pool->def->target.path, + if (virDirCreate(def->target.path, mode, - pool->def->target.perms.uid, - pool->def->target.perms.gid, + def->target.perms.uid, + def->target.perms.gid, dir_create_flags) < 0) goto cleanup; =20 @@ -2836,14 +2842,16 @@ virStorageBackendDeleteLocal(virConnectPtr conn ATT= RIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virCheckFlags(0, -1); =20 /* XXX delete all vols first ? */ =20 - if (rmdir(pool->def->target.path) < 0) { + if (rmdir(def->target.path) < 0) { virReportSystemError(errno, _("failed to remove pool '%s'"), - pool->def->target.path); + def->target.path); return -1; } =20 @@ -3575,6 +3583,7 @@ int virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); DIR *dir; struct dirent *ent; struct statvfs sb; @@ -3584,15 +3593,15 @@ virStorageBackendRefreshLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, int direrr; int fd =3D -1, ret =3D -1; =20 - if (virDirOpen(&dir, pool->def->target.path) < 0) + if (virDirOpen(&dir, def->target.path) < 0) goto cleanup; =20 - while ((direrr =3D virDirRead(dir, &ent, pool->def->target.path)) > 0)= { + while ((direrr =3D virDirRead(dir, &ent, def->target.path)) > 0) { int err; =20 if (virStringHasControlChars(ent->d_name)) { VIR_WARN("Ignoring file with control characters under '%s'", - pool->def->target.path); + def->target.path); continue; } =20 @@ -3604,8 +3613,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, =20 vol->type =3D VIR_STORAGE_VOL_FILE; if (virAsprintf(&vol->target.path, "%s/%s", - pool->def->target.path, - vol->name) < 0) + def->target.path, vol->name) < 0) goto cleanup; =20 if (VIR_STRDUP(vol->key, vol->target.path) < 0) @@ -3633,17 +3641,17 @@ virStorageBackendRefreshLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, if (VIR_ALLOC(target)) goto cleanup; =20 - if ((fd =3D open(pool->def->target.path, O_RDONLY)) < 0) { + if ((fd =3D open(def->target.path, O_RDONLY)) < 0) { virReportSystemError(errno, _("cannot open path '%s'"), - pool->def->target.path); + def->target.path); goto cleanup; } =20 if (fstat(fd, &statbuf) < 0) { virReportSystemError(errno, _("cannot stat path '%s'"), - pool->def->target.path); + def->target.path); goto cleanup; } =20 @@ -3651,24 +3659,24 @@ virStorageBackendRefreshLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, goto cleanup; =20 /* VolTargetInfoFD doesn't update capacity correctly for the pool case= */ - if (statvfs(pool->def->target.path, &sb) < 0) { + if (statvfs(def->target.path, &sb) < 0) { virReportSystemError(errno, _("cannot statvfs path '%s'"), - pool->def->target.path); + def->target.path); goto cleanup; } =20 - pool->def->capacity =3D ((unsigned long long)sb.f_frsize * - (unsigned long long)sb.f_blocks); - pool->def->available =3D ((unsigned long long)sb.f_bfree * - (unsigned long long)sb.f_frsize); - pool->def->allocation =3D pool->def->capacity - pool->def->available; + def->capacity =3D ((unsigned long long)sb.f_frsize * + (unsigned long long)sb.f_blocks); + def->available =3D ((unsigned long long)sb.f_bfree * + (unsigned long long)sb.f_frsize); + def->allocation =3D def->capacity - def->available; =20 - pool->def->target.perms.mode =3D target->perms->mode; - pool->def->target.perms.uid =3D target->perms->uid; - pool->def->target.perms.gid =3D target->perms->gid; - VIR_FREE(pool->def->target.perms.label); - if (VIR_STRDUP(pool->def->target.perms.label, target->perms->label) < = 0) + def->target.perms.mode =3D target->perms->mode; + def->target.perms.uid =3D target->perms->uid; + def->target.perms.gid =3D target->perms->gid; + VIR_FREE(def->target.perms.label); + if (VIR_STRDUP(def->target.perms.label, target->perms->label) < 0) goto cleanup; =20 ret =3D 0; @@ -3738,6 +3746,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, uint32_t lun, const char *dev) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStorageVolDefPtr vol =3D NULL; char *devpath =3D NULL; int retval =3D -1; @@ -3749,12 +3758,12 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr po= ol, * path to the device if the virDirRead loop to search the * target pool path for our devpath had failed. */ - if (!virStorageBackendPoolPathIsStable(pool->def->target.path) && - !(STREQ(pool->def->target.path, "/dev") || - STREQ(pool->def->target.path, "/dev/"))) { + if (!virStorageBackendPoolPathIsStable(def->target.path) && + !(STREQ(def->target.path, "/dev") || + STREQ(def->target.path, "/dev/"))) { virReportError(VIR_ERR_INVALID_ARG, _("unable to use target path '%s' for dev '%s'"), - NULLSTR(pool->def->target.path), dev); + NULLSTR(def->target.path), dev); goto cleanup; } =20 @@ -3788,11 +3797,11 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr po= ol, goto cleanup; =20 if (STREQ(devpath, vol->target.path) && - !(STREQ(pool->def->target.path, "/dev") || - STREQ(pool->def->target.path, "/dev/"))) { + !(STREQ(def->target.path, "/dev") || + STREQ(def->target.path, "/dev/"))) { =20 VIR_DEBUG("No stable path found for '%s' in '%s'", - devpath, pool->def->target.path); + devpath, def->target.path); =20 retval =3D -2; goto cleanup; @@ -3807,8 +3816,8 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, if (!(vol->key =3D virStorageBackendSCSISerial(vol->target.path))) goto cleanup; =20 - pool->def->capacity +=3D vol->target.capacity; - pool->def->allocation +=3D vol->target.allocation; + def->capacity +=3D vol->target.capacity; + def->allocation +=3D vol->target.allocation; =20 if (virStoragePoolObjAddVol(pool, vol) < 0) goto cleanup; @@ -4085,6 +4094,7 @@ int virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, uint32_t scanhost) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); int retval =3D 0; uint32_t bus, target, lun; const char *device_path =3D "/sys/bus/scsi/devices"; @@ -4126,7 +4136,7 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr poo= l, if (retval < 0) return -1; =20 - VIR_DEBUG("Found %d LUs for pool %s", found, pool->def->name); + VIR_DEBUG("Found %d LUs for pool %s", found, def->name); =20 return found; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:39:06 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 1507292850158106.25453329415257; Fri, 6 Oct 2017 05:27:30 -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 1F7C2C059B61; Fri, 6 Oct 2017 12:27: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 E99836683B; Fri, 6 Oct 2017 12:27:28 +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 B236B18355C6; Fri, 6 Oct 2017 12:27:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v96BNMAU028159 for ; Fri, 6 Oct 2017 07:23:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id C75A26061E; Fri, 6 Oct 2017 11:23:22 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-17.phx2.redhat.com [10.3.116.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F8A660603 for ; Fri, 6 Oct 2017 11:23:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1F7C2C059B61 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Fri, 6 Oct 2017 07:23:13 -0400 Message-Id: <20171006112317.29715-3-jferlan@redhat.com> In-Reply-To: <20171006112317.29715-1-jferlan@redhat.com> References: <20171006112317.29715-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 2/6] storage: Use virStoragePoolObjGetDef accessor for Disk 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.32]); Fri, 06 Oct 2017 12:27:29 +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_disk.c | 98 +++++++++++++++++++++-------------= ---- 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index a0f94512e3..44c135d807 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -59,6 +59,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr poo= l, char **const groups, virStorageVolDefPtr vol) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *tmp, *devpath, *partname; =20 /* Prepended path will be same for all partitions, so we can @@ -114,8 +115,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr p= ool, * our deletion will fail because the name we generated is wrong. * Check for our conditions and see if the generated name is the * same as StablePath returns and has the 'p' in it */ - if (pool->def->source.devices[0].part_separator =3D=3D - VIR_TRISTATE_BOOL_YES && + if (def->source.devices[0].part_separator =3D=3D VIR_TRISTATE_BOOL= _YES && !virIsDevMapperDevice(vol->target.path) && STREQ(groups[0], vol->target.path) && (tmp =3D strrchr(groups[0], 'p'))) { @@ -158,7 +158,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr p= ool, } =20 if (VIR_STRDUP(vol->source.extents[0].path, - pool->def->source.devices[0].path) < 0) + def->source.devices[0].path) < 0) return -1; } =20 @@ -212,9 +212,9 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr p= ool, } =20 if (STRNEQ(groups[2], "metadata")) - pool->def->allocation +=3D vol->target.allocation; - if (vol->source.extents[0].end > pool->def->capacity) - pool->def->capacity =3D vol->source.extents[0].end; + def->allocation +=3D vol->target.allocation; + if (vol->source.extents[0].end > def->capacity) + def->capacity =3D vol->source.extents[0].end; =20 return 0; } @@ -223,7 +223,8 @@ static int virStorageBackendDiskMakeFreeExtent(virStoragePoolObjPtr pool, char **const groups) { - virStoragePoolSourceDevicePtr dev =3D &pool->def->source.devices[0]; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolSourceDevicePtr dev =3D &def->source.devices[0]; =20 if (VIR_REALLOC_N(dev->freeExtents, dev->nfreeExtent + 1) < 0) @@ -253,11 +254,10 @@ virStorageBackendDiskMakeFreeExtent(virStoragePoolObj= Ptr pool, if (dev->freeExtents[dev->nfreeExtent].start =3D=3D 0) dev->freeExtents[dev->nfreeExtent].start =3D SECTOR_SIZE; =20 - pool->def->available +=3D - (dev->freeExtents[dev->nfreeExtent].end - - dev->freeExtents[dev->nfreeExtent].start); - if (dev->freeExtents[dev->nfreeExtent].end > pool->def->capacity) - pool->def->capacity =3D dev->freeExtents[dev->nfreeExtent].end; + def->available +=3D (dev->freeExtents[dev->nfreeExtent].end - + dev->freeExtents[dev->nfreeExtent].start); + if (dev->freeExtents[dev->nfreeExtent].end > def->capacity) + def->capacity =3D dev->freeExtents[dev->nfreeExtent].end; =20 dev->nfreeExtent++; =20 @@ -339,6 +339,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPt= r pool, * */ =20 + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *parthelper_path; virCommandPtr cmd; struct virStorageBackendDiskPoolVolData cbdata =3D { @@ -353,7 +354,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPt= r pool, return -1; =20 cmd =3D virCommandNewArgList(parthelper_path, - pool->def->source.devices[0].path, + def->source.devices[0].path, NULL); =20 /* Check for the presence of the part_separator=3D'yes'. Pass this @@ -362,16 +363,15 @@ virStorageBackendDiskReadPartitions(virStoragePoolObj= Ptr pool, * the generated device name for a source device which ends with * a non-numeric value (e.g. mpatha would generate mpathap#). */ - if (pool->def->source.devices[0].part_separator =3D=3D - VIR_TRISTATE_BOOL_YES) + if (def->source.devices[0].part_separator =3D=3D VIR_TRISTATE_BOOL_YES) virCommandAddArg(cmd, "-p"); =20 /* If a volume is passed, virStorageBackendDiskMakeVol only updates the * pool allocation for that single volume. */ if (!vol) - pool->def->allocation =3D 0; - pool->def->capacity =3D pool->def->available =3D 0; + def->allocation =3D 0; + def->capacity =3D def->available =3D 0; =20 ret =3D virCommandRunNul(cmd, 6, @@ -388,7 +388,8 @@ virStorageBackendDiskMakePoolGeometry(size_t ntok ATTRI= BUTE_UNUSED, void *data) { virStoragePoolObjPtr pool =3D data; - virStoragePoolSourceDevicePtr device =3D &(pool->def->source.devices[0= ]); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolSourceDevicePtr device =3D &(def->source.devices[0]); if (virStrToLong_i(groups[0], NULL, 0, &device->geometry.cylinders) < = 0 || virStrToLong_i(groups[1], NULL, 0, &device->geometry.heads) < 0 || virStrToLong_i(groups[2], NULL, 0, &device->geometry.sectors) < 0)= { @@ -403,6 +404,7 @@ virStorageBackendDiskMakePoolGeometry(size_t ntok ATTRI= BUTE_UNUSED, static int virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *parthelper_path; virCommandPtr cmd; int ret; @@ -413,9 +415,9 @@ virStorageBackendDiskReadGeometry(virStoragePoolObjPtr = pool) return -1; =20 cmd =3D virCommandNewArgList(parthelper_path, - pool->def->source.devices[0].= path, - "-g", - NULL); + def->source.devices[0].path, + "-g", + NULL); =20 ret =3D virCommandRunNul(cmd, 3, @@ -430,15 +432,17 @@ static int virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { - VIR_FREE(pool->def->source.devices[0].freeExtents); - pool->def->source.devices[0].nfreeExtent =3D 0; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + + VIR_FREE(def->source.devices[0].freeExtents); + def->source.devices[0].nfreeExtent =3D 0; =20 virWaitForDevices(); =20 - if (!virFileExists(pool->def->source.devices[0].path)) { + if (!virFileExists(def->source.devices[0].path)) { virReportError(VIR_ERR_INVALID_ARG, _("device path '%s' doesn't exist"), - pool->def->source.devices[0].path); + def->source.devices[0].path); return -1; } =20 @@ -453,8 +457,9 @@ static int virStorageBackendDiskStartPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); const char *format; - const char *path =3D pool->def->source.devices[0].path; + const char *path =3D def->source.devices[0].path; =20 virWaitForDevices(); =20 @@ -464,9 +469,9 @@ virStorageBackendDiskStartPool(virConnectPtr conn ATTRI= BUTE_UNUSED, return -1; } =20 - if (pool->def->source.format =3D=3D VIR_STORAGE_POOL_DISK_UNKNOWN) - pool->def->source.format =3D VIR_STORAGE_POOL_DISK_DOS; - format =3D virStoragePoolFormatDiskTypeToString(pool->def->source.form= at); + if (def->source.format =3D=3D VIR_STORAGE_POOL_DISK_UNKNOWN) + def->source.format =3D VIR_STORAGE_POOL_DISK_DOS; + format =3D virStoragePoolFormatDiskTypeToString(def->source.format); if (!virStorageBackendDeviceIsEmpty(path, format, false)) return -1; =20 @@ -482,7 +487,8 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRI= BUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags) { - int format =3D pool->def->source.format; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + int format =3D def->source.format; const char *fmt; bool ok_to_mklabel =3D false; int ret =3D -1; @@ -499,26 +505,26 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATT= RIBUTE_UNUSED, if (flags & VIR_STORAGE_POOL_BUILD_OVERWRITE) { ok_to_mklabel =3D true; } else { - if (virStorageBackendDeviceIsEmpty(pool->def->source.devices[0].pa= th, + if (virStorageBackendDeviceIsEmpty(def->source.devices[0].path, fmt, true)) ok_to_mklabel =3D true; } =20 if (ok_to_mklabel) { - if (virStorageBackendZeroPartitionTable(pool->def->source.devices[= 0].path, + if (virStorageBackendZeroPartitionTable(def->source.devices[0].pat= h, 1024 * 1024) < 0) goto error; =20 /* eg parted /dev/sda mklabel --script msdos */ if (format =3D=3D VIR_STORAGE_POOL_DISK_UNKNOWN) - format =3D pool->def->source.format =3D VIR_STORAGE_POOL_DISK_= DOS; + format =3D def->source.format =3D VIR_STORAGE_POOL_DISK_DOS; if (format =3D=3D VIR_STORAGE_POOL_DISK_DOS) fmt =3D "msdos"; else fmt =3D virStoragePoolFormatDiskTypeToString(format); =20 cmd =3D virCommandNewArgList(PARTED, - pool->def->source.devices[0].path, + def->source.devices[0].path, "mklabel", "--script", fmt, @@ -557,9 +563,10 @@ virStorageVolNumOfPartTypes(virStorageVolDefPtr def, static int virStorageBackendDiskPartTypeToCreate(virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); struct virStorageVolNumData data =3D { .count =3D 0 }; =20 - if (pool->def->source.format =3D=3D VIR_STORAGE_POOL_DISK_DOS) { + if (def->source.format =3D=3D VIR_STORAGE_POOL_DISK_DOS) { /* count primary and extended partitions, can't be more than 3 to create a new primary partition */ if (virStoragePoolObjForEachVolume(pool, virStorageVolNumOfPartTyp= es, @@ -578,7 +585,9 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr po= ol, virStorageVolDefPtr vol, char** partFormat) { - if (pool->def->source.format =3D=3D VIR_STORAGE_POOL_DISK_DOS) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + + if (def->source.format =3D=3D VIR_STORAGE_POOL_DISK_DOS) { const char *partedFormat; partedFormat =3D virStoragePartedFsTypeToString(vol->target.format= ); if (partedFormat =3D=3D NULL) { @@ -652,7 +661,8 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPt= r pool, unsigned long long smallestSize =3D 0; unsigned long long extraBytes =3D 0; unsigned long long alignedAllocation =3D allocation; - virStoragePoolSourceDevicePtr dev =3D &pool->def->source.devices[0]; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolSourceDevicePtr dev =3D &def->source.devices[0]; unsigned long long cylinderSize =3D (unsigned long long)dev->geometry.= heads * dev->geometry.sectors * SECTOR_SIZE; =20 @@ -670,7 +680,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPt= r pool, dev->freeExtents[i].start; unsigned long long neededSize =3D allocation; =20 - if (pool->def->source.format =3D=3D VIR_STORAGE_POOL_DISK_DOS) { + if (def->source.format =3D=3D VIR_STORAGE_POOL_DISK_DOS) { /* align to cylinder boundary */ neededSize +=3D extraBytes; if ((*start % cylinderSize) > extraBytes) { @@ -718,7 +728,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPt= r pool, } =20 *end =3D *start + alignedAllocation; - if (pool->def->source.format =3D=3D VIR_STORAGE_POOL_DISK_DOS) { + if (def->source.format =3D=3D VIR_STORAGE_POOL_DISK_DOS) { /* adjust our allocation if start is not at a cylinder boundary */ *end -=3D (*start % cylinderSize); } @@ -764,7 +774,8 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn, char *part_num =3D NULL; char *devpath =3D NULL; char *dev_name; - char *src_path =3D pool->def->source.devices[0].path; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + char *src_path =3D def->source.devices[0].path; char *srcname =3D last_component(src_path); virCommandPtr cmd =3D NULL; bool isDevMapperDevice; @@ -854,8 +865,9 @@ virStorageBackendDiskCreateVol(virConnectPtr conn, int res =3D -1; char *partFormat =3D NULL; unsigned long long startOffset =3D 0, endOffset =3D 0; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D virCommandNewArgList(PARTED, - pool->def->source.devices[0].= path, + def->source.devices[0].path, "mkpart", "--script", NULL); @@ -887,8 +899,8 @@ virStorageBackendDiskCreateVol(virConnectPtr conn, virWaitForDevices(); =20 /* Blow away free extent info, as we're about to re-populate it */ - VIR_FREE(pool->def->source.devices[0].freeExtents); - pool->def->source.devices[0].nfreeExtent =3D 0; + VIR_FREE(def->source.devices[0].freeExtents); + def->source.devices[0].nfreeExtent =3D 0; =20 /* Specifying a target path is meaningless */ VIR_FREE(vol->target.path); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:39:06 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 1507290462177479.61606015852556; Fri, 6 Oct 2017 04:47:42 -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 1930B83A; Fri, 6 Oct 2017 11:47:41 +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 F0B5C60C44; Fri, 6 Oct 2017 11:47: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 B9D94410B4; Fri, 6 Oct 2017 11:47:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v96BNNmV028164 for ; Fri, 6 Oct 2017 07:23:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C17660603; Fri, 6 Oct 2017 11:23:23 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-17.phx2.redhat.com [10.3.116.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id E934C1824C for ; Fri, 6 Oct 2017 11:23:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1930B83A Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Fri, 6 Oct 2017 07:23:14 -0400 Message-Id: <20171006112317.29715-4-jferlan@redhat.com> In-Reply-To: <20171006112317.29715-1-jferlan@redhat.com> References: <20171006112317.29715-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 3/6] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 06 Oct 2017 11:47:41 +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 7bfe211c2d..0ad357729b 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.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:39:06 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 1507292871538892.6229046554589; Fri, 6 Oct 2017 05:27:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0422C80472; Fri, 6 Oct 2017 12:27:50 +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 CE8996E731; Fri, 6 Oct 2017 12:27:49 +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 8A89562CEB; Fri, 6 Oct 2017 12:27:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v96BNN7m028169 for ; Fri, 6 Oct 2017 07:23:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 89EE560605; Fri, 6 Oct 2017 11:23:23 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-17.phx2.redhat.com [10.3.116.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 525E660603 for ; Fri, 6 Oct 2017 11:23:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0422C80472 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Fri, 6 Oct 2017 07:23:15 -0400 Message-Id: <20171006112317.29715-5-jferlan@redhat.com> In-Reply-To: <20171006112317.29715-1-jferlan@redhat.com> References: <20171006112317.29715-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 4/6] storage: Use virStoragePoolObjGetDef accessor for Sheepdog 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 06 Oct 2017 12:27:50 +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_sheepdog.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_b= ackend_sheepdog.c index e72dcda9c8..3d9c341a11 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -96,13 +96,14 @@ void virStorageBackendSheepdogAddHostArg(virCommandPtr cmd, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); const char *address =3D "localhost"; int port =3D 7000; - if (pool->def->source.nhost > 0) { - if (pool->def->source.hosts[0].name !=3D NULL) - address =3D pool->def->source.hosts[0].name; - if (pool->def->source.hosts[0].port) - port =3D pool->def->source.hosts[0].port; + if (def->source.nhost > 0) { + if (def->source.hosts[0].name !=3D NULL) + address =3D def->source.hosts[0].name; + if (def->source.hosts[0].port) + port =3D def->source.hosts[0].port; } virCommandAddArg(cmd, "-a"); virCommandAddArgFormat(cmd, "%s", address); @@ -202,7 +203,8 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn= ATTRIBUTE_UNUSED, if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 - if (virStorageBackendSheepdogParseNodeInfo(pool->def, output) < 0) + if (virStorageBackendSheepdogParseNodeInfo(virStoragePoolObjGetDef(poo= l), + output) < 0) goto cleanup; =20 ret =3D virStorageBackendSheepdogRefreshAllVol(conn, pool); @@ -236,6 +238,8 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn A= TTRIBUTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + if (vol->target.encryption !=3D NULL) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("storage pool does not support encrypted " @@ -247,7 +251,7 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn A= TTRIBUTE_UNUSED, =20 VIR_FREE(vol->key); if (virAsprintf(&vol->key, "%s/%s", - pool->def->source.name, vol->name) < 0) + def->source.name, vol->name) < 0) return -1; =20 VIR_FREE(vol->target.path); @@ -356,8 +360,9 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn = ATTRIBUTE_UNUSED, { int ret; char *output =3D NULL; - + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D virCommandNewArgList(SHEEPDOGCLI, "vdi", "list",= vol->name, "-r", NULL); + virStorageBackendSheepdogAddHostArg(cmd, pool); virCommandSetOutputBuffer(cmd, &output); ret =3D virCommandRun(cmd, NULL); @@ -372,7 +377,7 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn = ATTRIBUTE_UNUSED, =20 VIR_FREE(vol->key); if (virAsprintf(&vol->key, "%s/%s", - pool->def->source.name, vol->name) < 0) + def->source.name, vol->name) < 0) goto cleanup; =20 VIR_FREE(vol->target.path); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:39:06 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 1507290384602872.6812778999719; Fri, 6 Oct 2017 04:46:24 -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 EA0207EAB1; Fri, 6 Oct 2017 11:46:22 +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 C5F9066842; Fri, 6 Oct 2017 11:46:22 +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 842D81806104; Fri, 6 Oct 2017 11:46:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v96BNN1q028177 for ; Fri, 6 Oct 2017 07:23:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id E35E860605; Fri, 6 Oct 2017 11:23:23 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-17.phx2.redhat.com [10.3.116.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACB5560603 for ; Fri, 6 Oct 2017 11:23:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EA0207EAB1 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Fri, 6 Oct 2017 07:23:16 -0400 Message-Id: <20171006112317.29715-6-jferlan@redhat.com> In-Reply-To: <20171006112317.29715-1-jferlan@redhat.com> References: <20171006112317.29715-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 5/6] storage: Use virStoragePoolObjGetDef accessor for FS 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.28]); Fri, 06 Oct 2017 11:46:23 +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_fs.c | 90 ++++++++++++++++++++++--------------= ---- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 847dbc9e02..f54759983c 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -222,25 +222,27 @@ virStorageBackendFileSystemNetFindPoolSources(virConn= ectPtr conn ATTRIBUTE_UNUSE static int virStorageBackendFileSystemIsValid(virStoragePoolObjPtr pool) { - if (pool->def->type =3D=3D VIR_STORAGE_POOL_NETFS) { - if (pool->def->source.nhost !=3D 1) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + + if (def->type =3D=3D VIR_STORAGE_POOL_NETFS) { + if (def->source.nhost !=3D 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("expected exactly 1 host for the storage pool= ")); return -1; } - if (pool->def->source.hosts[0].name =3D=3D NULL) { + if (def->source.hosts[0].name =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing source host")); return -1; } - if (pool->def->source.dir =3D=3D NULL) { + if (def->source.dir =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing source path")); return -1; } } else { - if (pool->def->source.ndevice !=3D 1) { - if (pool->def->source.ndevice =3D=3D 0) + if (def->source.ndevice !=3D 1) { + if (def->source.ndevice =3D=3D 0) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing source device")); else @@ -264,22 +266,23 @@ virStorageBackendFileSystemIsValid(virStoragePoolObjP= tr pool) static char * virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *src =3D NULL; =20 - if (pool->def->type =3D=3D VIR_STORAGE_POOL_NETFS) { - if (pool->def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_CIFS) { + if (def->type =3D=3D VIR_STORAGE_POOL_NETFS) { + if (def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_CIFS) { if (virAsprintf(&src, "//%s/%s", - pool->def->source.hosts[0].name, - pool->def->source.dir) < 0) + def->source.hosts[0].name, + def->source.dir) < 0) return NULL; } else { if (virAsprintf(&src, "%s:%s", - pool->def->source.hosts[0].name, - pool->def->source.dir) < 0) + def->source.hosts[0].name, + def->source.dir) < 0) return NULL; } } else { - if (VIR_STRDUP(src, pool->def->source.devices[0].path) < 0) + if (VIR_STRDUP(src, def->source.devices[0].path) < 0) return NULL; } return src; @@ -297,6 +300,7 @@ static int virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool) { int ret =3D -1; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *src =3D NULL; FILE *mtab; struct mntent ent; @@ -317,8 +321,7 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjP= tr pool) /* compare both mount destinations and sources to be sure the moun= ted * FS pool is really the one we're looking for */ - if ((rc1 =3D virFileComparePaths(ent.mnt_dir, - pool->def->target.path)) < 0 || + if ((rc1 =3D virFileComparePaths(ent.mnt_dir, def->target.path)) <= 0 || (rc2 =3D virFileComparePaths(ent.mnt_fsname, src)) < 0) goto cleanup; =20 @@ -349,16 +352,17 @@ virStorageBackendFileSystemIsMounted(virStoragePoolOb= jPtr pool) static int virStorageBackendFileSystemMount(virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *src =3D NULL; /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs), * while plain 'mount' does. We have to craft separate argvs to * accommodate this */ - bool netauto =3D (pool->def->type =3D=3D VIR_STORAGE_POOL_NETFS && - pool->def->source.format =3D=3D VIR_STORAGE_POOL_NETFS= _AUTO); - bool glusterfs =3D (pool->def->type =3D=3D VIR_STORAGE_POOL_NETFS && - pool->def->source.format =3D=3D VIR_STORAGE_POOL_NET= FS_GLUSTERFS); - bool cifsfs =3D (pool->def->type =3D=3D VIR_STORAGE_POOL_NETFS && - pool->def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_= CIFS); + bool netauto =3D (def->type =3D=3D VIR_STORAGE_POOL_NETFS && + def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_AUTO); + bool glusterfs =3D (def->type =3D=3D VIR_STORAGE_POOL_NETFS && + def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_GLU= STERFS); + bool cifsfs =3D (def->type =3D=3D VIR_STORAGE_POOL_NETFS && + def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_CIFS); virCommandPtr cmd =3D NULL; int ret =3D -1; int rc; @@ -371,7 +375,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr p= ool) =20 /* Short-circuit if already mounted */ if (rc =3D=3D 1) { - VIR_INFO("Target '%s' is already mounted", pool->def->target.path); + VIR_INFO("Target '%s' is already mounted", def->target.path); return 0; } =20 @@ -381,34 +385,34 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr= pool) if (netauto) cmd =3D virCommandNewArgList(MOUNT, src, - pool->def->target.path, + def->target.path, NULL); else if (glusterfs) cmd =3D virCommandNewArgList(MOUNT, "-t", - virStoragePoolFormatFileSystemNetTypeTo= String(pool->def->source.format), + virStoragePoolFormatFileSystemNetTypeTo= String(def->source.format), src, "-o", "direct-io-mode=3D1", - pool->def->target.path, + def->target.path, NULL); else if (cifsfs) cmd =3D virCommandNewArgList(MOUNT, "-t", - virStoragePoolFormatFileSystemNetTypeTo= String(pool->def->source.format), + virStoragePoolFormatFileSystemNetTypeTo= String(def->source.format), src, - pool->def->target.path, + def->target.path, "-o", "guest", NULL); else cmd =3D virCommandNewArgList(MOUNT, "-t", - (pool->def->type =3D=3D VIR_STORAGE_POO= L_FS ? - virStoragePoolFormatFileSystemTypeToSt= ring(pool->def->source.format) : - virStoragePoolFormatFileSystemNetTypeT= oString(pool->def->source.format)), + (def->type =3D=3D VIR_STORAGE_POOL_FS ? + virStoragePoolFormatFileSystemTypeToSt= ring(def->source.format) : + virStoragePoolFormatFileSystemNetTypeT= oString(def->source.format)), src, - pool->def->target.path, + def->target.path, NULL); =20 if (virCommandRun(cmd, NULL) < 0) @@ -435,7 +439,9 @@ static int virStorageBackendFileSystemStart(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { - if (pool->def->type !=3D VIR_STORAGE_POOL_DIR && + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + + if (def->type !=3D VIR_STORAGE_POOL_DIR && virStorageBackendFileSystemMount(pool) < 0) return -1; =20 @@ -459,6 +465,7 @@ static int virStorageBackendFileSystemStop(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; int ret =3D -1; int rc; @@ -470,7 +477,7 @@ virStorageBackendFileSystemStop(virConnectPtr conn ATTR= IBUTE_UNUSED, if ((rc =3D virStorageBackendFileSystemIsMounted(pool)) !=3D 1) return rc; =20 - cmd =3D virCommandNewArgList(UMOUNT, pool->def->target.path, NULL); + cmd =3D virCommandNewArgList(UMOUNT, def->target.path, NULL); if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 @@ -486,8 +493,10 @@ static int virStorageBackendFileSystemCheck(virStoragePoolObjPtr pool, bool *isActive) { - if (pool->def->type =3D=3D VIR_STORAGE_POOL_DIR) { - *isActive =3D virFileExists(pool->def->target.path); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + + if (def->type =3D=3D VIR_STORAGE_POOL_DIR) { + *isActive =3D virFileExists(def->target.path); #if WITH_STORAGE_FS } else { int ret; @@ -561,25 +570,26 @@ static int virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); const char *device =3D NULL, *format =3D NULL; bool ok_to_mkfs =3D false; int ret =3D -1; =20 - if (pool->def->source.devices =3D=3D NULL) { + if (def->source.devices =3D=3D NULL) { virReportError(VIR_ERR_OPERATION_INVALID, _("No source device specified when formatting pool = '%s'"), - pool->def->name); + def->name); goto error; } =20 - device =3D pool->def->source.devices[0].path; - format =3D virStoragePoolFormatFileSystemTypeToString(pool->def->sourc= e.format); + device =3D def->source.devices[0].path; + format =3D virStoragePoolFormatFileSystemTypeToString(def->source.form= at); VIR_DEBUG("source device: '%s' format: '%s'", device, format); =20 if (!virFileExists(device)) { virReportError(VIR_ERR_OPERATION_INVALID, _("Source device does not exist when formatting poo= l '%s'"), - pool->def->name); + def->name); goto error; } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:39:06 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 1507290483161415.9972193941222; Fri, 6 Oct 2017 04:48:03 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E5E4EC04B954; Fri, 6 Oct 2017 11:48:01 +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 B1C356E732; Fri, 6 Oct 2017 11:48:01 +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 6DC38410A9; Fri, 6 Oct 2017 11:48:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v96BNOWq028190 for ; Fri, 6 Oct 2017 07:23:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C15B60603; Fri, 6 Oct 2017 11:23:24 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-17.phx2.redhat.com [10.3.116.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36B9B6061E for ; Fri, 6 Oct 2017 11:23:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E5E4EC04B954 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: Fri, 6 Oct 2017 07:23:17 -0400 Message-Id: <20171006112317.29715-7-jferlan@redhat.com> In-Reply-To: <20171006112317.29715-1-jferlan@redhat.com> References: <20171006112317.29715-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 6/6] storage: Use virStoragePoolObjGetDef accessor for Gluster 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 06 Oct 2017 11:48:02 +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_gluster.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 05e7bff638..eac771b42f 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -74,8 +74,9 @@ static virStorageBackendGlusterStatePtr virStorageBackendGlusterOpen(virStoragePoolObjPtr pool) { virStorageBackendGlusterStatePtr ret =3D NULL; - const char *name =3D pool->def->source.name; - const char *dir =3D pool->def->source.dir; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + const char *name =3D def->source.name; + const char *dir =3D def->source.dir; bool trailing_slash =3D true; =20 /* Volume name must not contain '/'; optional path allows use of a @@ -112,11 +113,11 @@ virStorageBackendGlusterOpen(virStoragePoolObjPtr poo= l) goto error; if (VIR_STRDUP(ret->uri->scheme, "gluster") < 0) goto error; - if (VIR_STRDUP(ret->uri->server, pool->def->source.hosts[0].name) < 0) + if (VIR_STRDUP(ret->uri->server, def->source.hosts[0].name) < 0) goto error; if (virAsprintf(&ret->uri->path, "/%s%s", ret->volname, ret->dir) < 0) goto error; - ret->uri->port =3D pool->def->source.hosts[0].port; + ret->uri->port =3D def->source.hosts[0].port; =20 /* Actually connect to glfs */ if (!(ret->vol =3D glfs_new(ret->volname))) { @@ -343,6 +344,7 @@ virStorageBackendGlusterRefreshPool(virConnectPtr conn = ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { int ret =3D -1; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStorageBackendGlusterStatePtr state =3D NULL; struct { struct dirent ent; @@ -401,11 +403,11 @@ virStorageBackendGlusterRefreshPool(virConnectPtr con= n ATTRIBUTE_UNUSED, goto cleanup; } =20 - pool->def->capacity =3D ((unsigned long long)sb.f_frsize * - (unsigned long long)sb.f_blocks); - pool->def->available =3D ((unsigned long long)sb.f_bfree * - (unsigned long long)sb.f_frsize); - pool->def->allocation =3D pool->def->capacity - pool->def->available; + def->capacity =3D ((unsigned long long)sb.f_frsize * + (unsigned long long)sb.f_blocks); + def->available =3D ((unsigned long long)sb.f_bfree * + (unsigned long long)sb.f_frsize); + def->allocation =3D def->capacity - def->available; =20 ret =3D 0; cleanup: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list