From nobody Thu May 15 11:33:34 2025 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 1507301603512815.6328668120991; Fri, 6 Oct 2017 07:53:23 -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 282835BECD; Fri, 6 Oct 2017 14:53: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 0AD5C6683F; Fri, 6 Oct 2017 14:53: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 C2E1418355C5; Fri, 6 Oct 2017 14:53:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v96EhUu4028023 for ; Fri, 6 Oct 2017 10:43:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 729CD69ADE; Fri, 6 Oct 2017 14:43:30 +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 3A45C6B54C for ; Fri, 6 Oct 2017 14:43:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 282835BECD Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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 10:42:59 -0400 Message-Id: <20171006144302.9892-6-jferlan@redhat.com> In-Reply-To: <20171006144302.9892-1-jferlan@redhat.com> References: <20171006144302.9892-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 5/8] storage: Use virStoragePoolObjGetDef accessor for VSTORAGE 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.38]); Fri, 06 Oct 2017 14:53:22 +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_vstorage.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_b= ackend_vstorage.c index fb06138538..2dc26af387 100644 --- a/src/storage/storage_backend_vstorage.c +++ b/src/storage/storage_backend_vstorage.c @@ -41,33 +41,34 @@ virStorageBackendVzPoolStart(virConnectPtr conn ATTRIBU= TE_UNUSED, virStoragePoolObjPtr pool) { int ret =3D -1; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; char *grp_name =3D NULL; char *usr_name =3D NULL; char *mode =3D NULL; =20 /* Check the permissions */ - if (pool->def->target.perms.mode =3D=3D (mode_t) - 1) - pool->def->target.perms.mode =3D VIR_STORAGE_DEFAULT_POOL_PERM_MOD= E; - if (pool->def->target.perms.uid =3D=3D (uid_t) -1) - pool->def->target.perms.uid =3D geteuid(); - if (pool->def->target.perms.gid =3D=3D (gid_t) -1) - pool->def->target.perms.gid =3D getegid(); + if (def->target.perms.mode =3D=3D (mode_t) - 1) + def->target.perms.mode =3D VIR_STORAGE_DEFAULT_POOL_PERM_MODE; + if (def->target.perms.uid =3D=3D (uid_t) -1) + def->target.perms.uid =3D geteuid(); + if (def->target.perms.gid =3D=3D (gid_t) -1) + def->target.perms.gid =3D getegid(); =20 /* Convert ids to names because vstorage uses names */ =20 - if (!(grp_name =3D virGetGroupName(pool->def->target.perms.gid))) + if (!(grp_name =3D virGetGroupName(def->target.perms.gid))) goto cleanup; =20 - if (!(usr_name =3D virGetUserName(pool->def->target.perms.uid))) + if (!(usr_name =3D virGetUserName(def->target.perms.uid))) goto cleanup; =20 - if (virAsprintf(&mode, "%o", pool->def->target.perms.mode) < 0) + if (virAsprintf(&mode, "%o", def->target.perms.mode) < 0) goto cleanup; =20 cmd =3D virCommandNewArgList(VSTORAGE_MOUNT, - "-c", pool->def->source.name, - pool->def->target.path, + "-c", def->source.name, + def->target.path, "-m", mode, "-g", grp_name, "-u", usr_name, NULL); @@ -89,12 +90,13 @@ static int virStorageBackendVzIsMounted(virStoragePoolObjPtr pool) { int ret =3D -1; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); FILE *mtab; struct mntent ent; char buf[1024]; char *cluster =3D NULL; =20 - if (virAsprintf(&cluster, "vstorage://%s", pool->def->source.name) < 0) + if (virAsprintf(&cluster, "vstorage://%s", def->source.name) < 0) return -1; =20 if ((mtab =3D fopen(_PATH_MOUNTED, "r")) =3D=3D NULL) { @@ -106,7 +108,7 @@ virStorageBackendVzIsMounted(virStoragePoolObjPtr pool) =20 while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) !=3D NULL) { =20 - if (STREQ(ent.mnt_dir, pool->def->target.path) && + if (STREQ(ent.mnt_dir, def->target.path) && STREQ(ent.mnt_fsname, cluster)) { ret =3D 1; goto cleanup; @@ -126,6 +128,7 @@ static int virStorageBackendVzPoolStop(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; int ret =3D -1; int rc; @@ -134,7 +137,7 @@ virStorageBackendVzPoolStop(virConnectPtr conn ATTRIBUT= E_UNUSED, if ((rc =3D virStorageBackendVzIsMounted(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 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list