From nobody Sat Apr 27 07:21:19 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 1507301580047422.6329572012271; Fri, 6 Oct 2017 07:53:00 -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 771077E390; Fri, 6 Oct 2017 14:52:58 +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 09BD8649A3; Fri, 6 Oct 2017 14:52:58 +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 322D118355C7; Fri, 6 Oct 2017 14:52:57 +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 v96EhC8l027972 for ; Fri, 6 Oct 2017 10:43:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D7536A908; Fri, 6 Oct 2017 14:43:12 +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 46F7F6A917 for ; Fri, 6 Oct 2017 14:43:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 771077E390 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 10:42:55 -0400 Message-Id: <20171006144302.9892-2-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 1/8] storage: Use virStoragePoolObjGetDef accessor for iSCSI 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.28]); Fri, 06 Oct 2017 14:52:59 +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 Reviewed-by: Erik Skultety --- src/storage/storage_backend_iscsi.c | 41 +++++++++++++++++++++------------= ---- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_back= end_iscsi.c index 14f3e09a8f..b0c5096adb 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -83,7 +83,8 @@ static char * virStorageBackendISCSISession(virStoragePoolObjPtr pool, bool probe) { - return virISCSIGetSession(pool->def->source.devices[0].path, probe); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + return virISCSIGetSession(def->source.devices[0].path, probe); } =20 =20 @@ -235,25 +236,26 @@ static int virStorageBackendISCSICheckPool(virStoragePoolObjPtr pool, bool *isActive) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *session =3D NULL; int ret =3D -1; =20 *isActive =3D false; =20 - if (pool->def->source.nhost !=3D 1) { + if (def->source.nhost !=3D 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Expected exactly 1 host for the storage pool")); return -1; } =20 - 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; } =20 - if (pool->def->source.ndevice !=3D 1 || - pool->def->source.devices[0].path =3D=3D NULL) { + if (def->source.ndevice !=3D 1 || + def->source.devices[0].path =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing source device")); return -1; @@ -327,44 +329,45 @@ static int virStorageBackendISCSIStartPool(virConnectPtr conn, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *portal =3D NULL; char *session =3D NULL; int ret =3D -1; =20 - if (pool->def->source.nhost !=3D 1) { + if (def->source.nhost !=3D 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Expected exactly 1 host for the storage pool")); return -1; } =20 - 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; } =20 - if (pool->def->source.ndevice !=3D 1 || - pool->def->source.devices[0].path =3D=3D NULL) { + if (def->source.ndevice !=3D 1 || + def->source.devices[0].path =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing source device")); return -1; } =20 if ((session =3D virStorageBackendISCSISession(pool, true)) =3D=3D NUL= L) { - if ((portal =3D virStorageBackendISCSIPortal(&pool->def->source)) = =3D=3D NULL) + if ((portal =3D virStorageBackendISCSIPortal(&def->source)) =3D=3D= NULL) goto cleanup; =20 /* Create a static node record for the IQN target. Must be done * in order for login to the target */ - if (virISCSINodeNew(portal, pool->def->source.devices[0].path) < 0) + if (virISCSINodeNew(portal, def->source.devices[0].path) < 0) goto cleanup; =20 - if (virStorageBackendISCSISetAuth(portal, conn, &pool->def->source= ) < 0) + if (virStorageBackendISCSISetAuth(portal, conn, &def->source) < 0) goto cleanup; =20 if (virISCSIConnectionLogin(portal, - pool->def->source.initiator.iqn, - pool->def->source.devices[0].path) < 0) + def->source.initiator.iqn, + def->source.devices[0].path) < 0) goto cleanup; } ret =3D 0; @@ -379,9 +382,10 @@ static int virStorageBackendISCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *session =3D NULL; =20 - pool->def->allocation =3D pool->def->capacity =3D pool->def->available= =3D 0; + def->allocation =3D def->capacity =3D def->available =3D 0; =20 if ((session =3D virStorageBackendISCSISession(pool, false)) =3D=3D NU= LL) goto cleanup; @@ -403,6 +407,7 @@ static int virStorageBackendISCSIStopPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *portal; char *session; int ret =3D -1; @@ -411,12 +416,12 @@ virStorageBackendISCSIStopPool(virConnectPtr conn ATT= RIBUTE_UNUSED, return 0; VIR_FREE(session); =20 - if ((portal =3D virStorageBackendISCSIPortal(&pool->def->source)) =3D= =3D NULL) + if ((portal =3D virStorageBackendISCSIPortal(&def->source)) =3D=3D NUL= L) return -1; =20 if (virISCSIConnectionLogout(portal, - pool->def->source.initiator.iqn, - pool->def->source.devices[0].path) < 0) + def->source.initiator.iqn, + def->source.devices[0].path) < 0) goto cleanup; ret =3D 0; =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 07:21:19 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 1507303794976899.5347590206311; Fri, 6 Oct 2017 08:29:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DBF8C047B74; Fri, 6 Oct 2017 15:29:53 +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 6E330675A1; Fri, 6 Oct 2017 15:29:53 +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 2DAA918355C5; Fri, 6 Oct 2017 15:29:53 +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 v96EhDFF027982 for ; Fri, 6 Oct 2017 10:43:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id C60356A912; Fri, 6 Oct 2017 14:43:13 +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 8CEDE6A908 for ; Fri, 6 Oct 2017 14:43:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9DBF8C047B74 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 10:42:56 -0400 Message-Id: <20171006144302.9892-3-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 2/8] storage: Use virStoragePoolObjGetDef accessor for MPATH 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 06 Oct 2017 15:29:54 +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 Reviewed-by: Erik Skultety --- src/storage/storage_backend_mpath.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_back= end_mpath.c index 46818ef2cc..4bc39c24eb 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -48,6 +48,7 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool, const int devnum, const char *dev) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStorageVolDefPtr vol; int ret =3D -1; =20 @@ -74,8 +75,8 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool, if (virStoragePoolObjAddVol(pool, vol) < 0) 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; ret =3D 0; =20 cleanup: @@ -259,10 +260,11 @@ virStorageBackendMpathRefreshPool(virConnectPtr conn = ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { int retval =3D 0; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 VIR_DEBUG("conn=3D%p, pool=3D%p", conn, pool); =20 - pool->def->allocation =3D pool->def->capacity =3D pool->def->available= =3D 0; + def->allocation =3D def->capacity =3D def->available =3D 0; =20 virWaitForDevices(); =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 07:21:19 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 1507303970591500.40036403319993; Fri, 6 Oct 2017 08:32:50 -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 A2166FECB; Fri, 6 Oct 2017 15:32:49 +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 808D56EE2F; Fri, 6 Oct 2017 15:32: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 4AEC33FC73; Fri, 6 Oct 2017 15:32:49 +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 v96EhMMI027998 for ; Fri, 6 Oct 2017 10:43:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 69A5E6B55A; Fri, 6 Oct 2017 14:43: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 BF58A6A909 for ; Fri, 6 Oct 2017 14:43:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A2166FECB 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 10:42:57 -0400 Message-Id: <20171006144302.9892-4-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 3/8] storage: Use virStoragePoolObjGetDef accessor for RBD 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.29]); Fri, 06 Oct 2017 15:32: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 Reviewed-by: Erik Skultety --- src/storage/storage_backend_rbd.c | 64 +++++++++++++++++++++--------------= ---- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 6731677851..7f9597cabe 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -210,10 +210,11 @@ static int virStorageBackendRBDOpenIoCTX(virStorageBackendRBDStatePtr ptr, virStoragePoolObjPtr pool) { - int r =3D rados_ioctx_create(ptr->cluster, pool->def->source.name, &pt= r->ioctx); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + int r =3D rados_ioctx_create(ptr->cluster, def->source.name, &ptr->ioc= tx); if (r < 0) { virReportSystemError(-r, _("failed to create the RBD IoCTX. Does t= he pool '%s' exist?"), - pool->def->source.name); + def->source.name); } return r; } @@ -255,11 +256,12 @@ virStorageBackendRBDNewState(virConnectPtr conn, virStoragePoolObjPtr pool) { virStorageBackendRBDStatePtr ptr; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 if (VIR_ALLOC(ptr) < 0) return NULL; =20 - if (virStorageBackendRBDOpenRADOSConn(ptr, conn, &pool->def->source) <= 0) + if (virStorageBackendRBDOpenRADOSConn(ptr, conn, &def->source) < 0) goto error; =20 if (virStorageBackendRBDOpenIoCTX(ptr, pool) < 0) @@ -359,6 +361,7 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr = vol, virStorageBackendRBDStatePtr ptr) { int ret =3D -1; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); int r =3D 0; rbd_image_t image =3D NULL; rbd_image_info_t info; @@ -388,7 +391,7 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr = vol, if (volStorageBackendRBDUseFastDiff(features)) { VIR_DEBUG("RBD image %s/%s has fast-diff feature enabled. " "Querying for actual allocation", - pool->def->source.name, vol->name); + def->source.name, vol->name); =20 if (virStorageBackendRBDSetAllocation(vol, image, &info) < 0) goto cleanup; @@ -398,19 +401,17 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPt= r vol, =20 VIR_DEBUG("Refreshed RBD image %s/%s (capacity: %llu allocation: %llu " "obj_size: %"PRIu64" num_objs: %"PRIu64")", - pool->def->source.name, vol->name, vol->target.capacity, + def->source.name, vol->name, vol->target.capacity, vol->target.allocation, info.obj_size, info.num_objs); =20 VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", - pool->def->source.name, - vol->name) < 0) + def->source.name, vol->name) < 0) goto cleanup; =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 ret =3D 0; @@ -430,6 +431,7 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn, int len =3D -1; int r =3D 0; char *name, *names =3D NULL; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStorageBackendRBDStatePtr ptr =3D NULL; struct rados_cluster_stat_t clusterstat; struct rados_pool_stat_t poolstat; @@ -444,17 +446,17 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn, =20 if ((r =3D rados_ioctx_pool_stat(ptr->ioctx, &poolstat)) < 0) { virReportSystemError(-r, _("failed to stat the RADOS pool '%s'"), - pool->def->source.name); + def->source.name); goto cleanup; } =20 - pool->def->capacity =3D clusterstat.kb * 1024; - pool->def->available =3D clusterstat.kb_avail * 1024; - pool->def->allocation =3D poolstat.num_bytes; + def->capacity =3D clusterstat.kb * 1024; + def->available =3D clusterstat.kb_avail * 1024; + def->allocation =3D poolstat.num_bytes; =20 VIR_DEBUG("Utilization of RBD pool %s: (kb: %"PRIu64" kb_avail: %"PRIu= 64 " num_bytes: %"PRIu64")", - pool->def->source.name, clusterstat.kb, clusterstat.kb_avail, + def->source.name, clusterstat.kb, clusterstat.kb_avail, poolstat.num_bytes); =20 while (true) { @@ -514,7 +516,7 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn, } =20 VIR_DEBUG("Found %zu images in RBD pool %s", - virStoragePoolObjGetVolumesCount(pool), pool->def->source.na= me); + virStoragePoolObjGetVolumesCount(pool), def->source.name); =20 ret =3D 0; =20 @@ -610,12 +612,13 @@ virStorageBackendRBDDeleteVol(virConnectPtr conn, { int ret =3D -1; int r =3D 0; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStorageBackendRBDStatePtr ptr =3D NULL; =20 virCheckFlags(VIR_STORAGE_VOL_DELETE_ZEROED | VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS, -1); =20 - VIR_DEBUG("Removing RBD image %s/%s", pool->def->source.name, vol->nam= e); + VIR_DEBUG("Removing RBD image %s/%s", def->source.name, vol->name); =20 if (flags & VIR_STORAGE_VOL_DELETE_ZEROED) VIR_WARN("%s", "This storage backend does not support zeroed remov= al of volumes"); @@ -624,17 +627,17 @@ virStorageBackendRBDDeleteVol(virConnectPtr conn, goto cleanup; =20 if (flags & VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS) { - if (virStorageBackendRBDCleanupSnapshots(ptr->ioctx, &pool->def->s= ource, + if (virStorageBackendRBDCleanupSnapshots(ptr->ioctx, &def->source, vol) < 0) goto cleanup; } =20 - VIR_DEBUG("Removing volume %s/%s", pool->def->source.name, vol->name); + VIR_DEBUG("Removing volume %s/%s", def->source.name, vol->name); =20 r =3D rbd_remove(ptr->ioctx, vol->name); if (r < 0 && (-r) !=3D ENOENT) { virReportSystemError(-r, _("failed to remove volume '%s/%s'"), - pool->def->source.name, vol->name); + def->source.name, vol->name); goto cleanup; } =20 @@ -651,6 +654,8 @@ virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIB= UTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + vol->type =3D VIR_STORAGE_VOL_NETWORK; =20 if (vol->target.format !=3D VIR_STORAGE_FILE_RAW) { @@ -661,14 +666,12 @@ virStorageBackendRBDCreateVol(virConnectPtr conn ATTR= IBUTE_UNUSED, =20 VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", - pool->def->source.name, - vol->name) < 0) + def->source.name, vol->name) < 0) return -1; =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 return 0; @@ -687,13 +690,13 @@ virStorageBackendRBDBuildVol(virConnectPtr conn, virStorageVolDefPtr vol, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStorageBackendRBDStatePtr ptr =3D NULL; int ret =3D -1; int r =3D 0; =20 VIR_DEBUG("Creating RBD image %s/%s with size %llu", - pool->def->source.name, - vol->name, vol->target.capacity); + def->source.name, vol->name, vol->target.capacity); =20 virCheckFlags(0, -1); =20 @@ -721,8 +724,7 @@ virStorageBackendRBDBuildVol(virConnectPtr conn, if ((r =3D virStorageBackendRBDCreateImage(ptr->ioctx, vol->name, vol->target.capacity)) < 0) { virReportSystemError(-r, _("failed to create volume '%s/%s'"), - pool->def->source.name, - vol->name); + def->source.name, vol->name); goto cleanup; } =20 @@ -1045,11 +1047,12 @@ virStorageBackendRBDBuildVolFrom(virConnectPtr conn, virStorageVolDefPtr origvol, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStorageBackendRBDStatePtr ptr =3D NULL; int ret =3D -1; =20 VIR_DEBUG("Creating clone of RBD image %s/%s with name %s", - pool->def->source.name, origvol->name, newvol->name); + def->source.name, origvol->name, newvol->name); =20 virCheckFlags(0, -1); =20 @@ -1208,6 +1211,7 @@ virStorageBackendRBDVolWipe(virConnectPtr conn, unsigned int flags) { virStorageBackendRBDStatePtr ptr =3D NULL; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); rbd_image_t image =3D NULL; rbd_image_info_t info; uint64_t stripe_count; @@ -1216,7 +1220,7 @@ virStorageBackendRBDVolWipe(virConnectPtr conn, =20 virCheckFlags(0, -1); =20 - VIR_DEBUG("Wiping RBD image %s/%s", pool->def->source.name, vol->name); + VIR_DEBUG("Wiping RBD image %s/%s", def->source.name, vol->name); =20 if (!(ptr =3D virStorageBackendRBDNewState(conn, pool))) goto cleanup; @@ -1240,7 +1244,7 @@ virStorageBackendRBDVolWipe(virConnectPtr conn, } =20 VIR_DEBUG("Need to wipe %"PRIu64" bytes from RBD image %s/%s", - info.size, pool->def->source.name, vol->name); + info.size, def->source.name, vol->name); =20 switch ((virStorageVolWipeAlgorithm) algorithm) { case VIR_STORAGE_VOL_WIPE_ALG_ZERO: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 07:21:19 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 1507303815043378.19567787057906; Fri, 6 Oct 2017 08:30:15 -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 906104DD7C; Fri, 6 Oct 2017 15:30:13 +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 6A03564430; Fri, 6 Oct 2017 15:30:13 +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 0774018355C9; Fri, 6 Oct 2017 15:30:13 +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 v96EhPl3028013 for ; Fri, 6 Oct 2017 10:43:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id BD42A6A917; Fri, 6 Oct 2017 14:43:25 +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 85D0F6A908 for ; Fri, 6 Oct 2017 14:43:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 906104DD7C 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:58 -0400 Message-Id: <20171006144302.9892-5-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 4/8] storage: Use virStoragePoolObjGetDef accessor for SCSI 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.38]); Fri, 06 Oct 2017 15:30:14 +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 Reviewed-by: Erik Skultety --- src/storage/storage_backend_scsi.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index 02fd4b643c..ee79ad72f5 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -139,6 +139,7 @@ virStoragePoolFCRefreshThread(void *opaque) const char *fchost_name =3D cbdata->fchost_name; const unsigned char *pool_uuid =3D cbdata->pool_uuid; virStoragePoolObjPtr pool =3D NULL; + virStoragePoolDefPtr def; unsigned int host; int found =3D 0; int tries =3D 2; @@ -149,14 +150,15 @@ virStoragePoolFCRefreshThread(void *opaque) /* Let's see if the pool still exists - */ if (!(pool =3D virStoragePoolObjFindPoolByUUID(pool_uuid))) break; + def =3D virStoragePoolObjGetDef(pool); =20 /* Return with pool lock, if active, we can get the host number, * successfully, rescan, and find LUN's, then we are happy */ VIR_DEBUG("Attempt FC Refresh for pool=3D'%s' name=3D'%s' tries=3D= '%d'", - pool->def->name, fchost_name, tries); + def->name, fchost_name, tries); =20 - pool->def->allocation =3D pool->def->capacity =3D pool->def->avail= able =3D 0; + def->allocation =3D def->capacity =3D def->available =3D 0; =20 if (virStoragePoolObjIsActive(pool) && virSCSIHostGetNumber(fchost_name, &host) =3D=3D 0 && @@ -371,6 +373,7 @@ static int virStorageBackendSCSICheckPool(virStoragePoolObjPtr pool, bool *isActive) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *path =3D NULL; char *name =3D NULL; unsigned int host; @@ -378,13 +381,12 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr p= ool, =20 *isActive =3D false; =20 - if (!(name =3D getAdapterName(&pool->def->source.adapter))) { + if (!(name =3D getAdapterName(&def->source.adapter))) { /* It's normal for the pool with "fc_host" type source * adapter fails to get the adapter name, since the vHBA * the adapter based on might be not created yet. */ - if (pool->def->source.adapter.type =3D=3D - VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { + if (def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HO= ST) { virResetLastError(); return 0; } else { @@ -412,13 +414,14 @@ static int virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *name =3D NULL; unsigned int host; int ret =3D -1; =20 - pool->def->allocation =3D pool->def->capacity =3D pool->def->available= =3D 0; + def->allocation =3D def->capacity =3D def->available =3D 0; =20 - if (!(name =3D getAdapterName(&pool->def->source.adapter))) + if (!(name =3D getAdapterName(&def->source.adapter))) return -1; =20 if (virSCSIHostGetNumber(name, &host) < 0) @@ -443,11 +446,12 @@ static int virStorageBackendSCSIStartPool(virConnectPtr conn, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); const char *configFile =3D virStoragePoolObjGetConfigFile(pool); =20 - if (pool->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_= HOST) - return createVport(conn, pool->def, configFile, - &pool->def->source.adapter.data.fchost); + if (def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) + return createVport(conn, def, configFile, + &def->source.adapter.data.fchost); =20 return 0; } @@ -457,9 +461,11 @@ static int virStorageBackendSCSIStopPool(virConnectPtr conn, virStoragePoolObjPtr pool) { - if (pool->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_= HOST) + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + + if (def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) return virNodeDeviceDeleteVport(conn, - &pool->def->source.adapter.data.fc= host); + &def->source.adapter.data.fchost); =20 return 0; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 07:21:19 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 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 Reviewed-by: Erik Skultety --- 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 From nobody Sat Apr 27 07:21:19 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 1507301623507820.1572870926392; Fri, 6 Oct 2017 07:53:43 -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 546803680F; Fri, 6 Oct 2017 14:53:42 +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 30ED163F78; Fri, 6 Oct 2017 14:53:42 +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 F114418355C7; Fri, 6 Oct 2017 14:53:41 +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 v96EhWD2028044 for ; Fri, 6 Oct 2017 10:43:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9097769ADE; Fri, 6 Oct 2017 14:43:32 +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 55B9C6A915 for ; Fri, 6 Oct 2017 14:43:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 546803680F Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.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:43:00 -0400 Message-Id: <20171006144302.9892-7-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 6/8] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 06 Oct 2017 14:53:42 +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 Reviewed-by: Erik Skultety --- 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 c2662815a1..198c788aca 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.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 07:21:19 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 1507303850179798.715190619717; Fri, 6 Oct 2017 08:30:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 22D14CAA9E; Fri, 6 Oct 2017 15:30:49 +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 F0BC76F114; Fri, 6 Oct 2017 15:30:48 +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 BB192410B2; Fri, 6 Oct 2017 15:30:48 +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 v96EhZSt028064 for ; Fri, 6 Oct 2017 10:43:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C73F6A907; Fri, 6 Oct 2017 14:43:35 +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 257F869ADE for ; Fri, 6 Oct 2017 14:43:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 22D14CAA9E 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:43:01 -0400 Message-Id: <20171006144302.9892-8-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 7/8] storage: Use virStoragePoolObjGetDef accessor for new driver events 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 06 Oct 2017 15:30:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Missed from merge from commit id 'b0652192' into commit id 'bfcd8fc92' were a couple of obj->def-> references. Signed-off-by: John Ferlan Reviewed-by: Erik Skultety --- src/storage/storage_driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index b0edf9f885..2b7a299706 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -994,8 +994,8 @@ storagePoolBuild(virStoragePoolPtr pool, backend->buildPool(pool->conn, obj, flags) < 0) goto cleanup; =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_CREATED, 0); =20 @@ -1128,8 +1128,8 @@ storagePoolDelete(virStoragePoolPtr pool, if (backend->deletePool(pool->conn, obj, flags) < 0) goto cleanup; =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_DELETED, 0); =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 07:21:19 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 1507303869879831.1401968037795; Fri, 6 Oct 2017 08:31:09 -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 DF102C0035D0; Fri, 6 Oct 2017 15:31:08 +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 BB3DD63F78; Fri, 6 Oct 2017 15:31:08 +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 85FA018355C8; Fri, 6 Oct 2017 15:31:08 +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 v96Ehj6j028106 for ; Fri, 6 Oct 2017 10:43:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id A8AE26A902; Fri, 6 Oct 2017 14:43:45 +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 723316A912 for ; Fri, 6 Oct 2017 14:43:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DF102C0035D0 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 10:43:02 -0400 Message-Id: <20171006144302.9892-9-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 8/8] storage: Privatize virStoragePoolObj and virStorageVolDefList 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.32]); Fri, 06 Oct 2017 15:31:09 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the structures into virstorageobj so that both are known within virstorageobj.c. Signed-off-by: John Ferlan Reviewed-by: Erik Skultety --- src/conf/storage_conf.h | 4 ---- src/conf/virstorageobj.c | 20 ++++++++++++++++++++ src/conf/virstorageobj.h | 15 --------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index 8ac6796a61..b349783d26 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -75,10 +75,6 @@ struct _virStorageVolDef { =20 typedef struct _virStorageVolDefList virStorageVolDefList; typedef virStorageVolDefList *virStorageVolDefListPtr; -struct _virStorageVolDefList { - size_t count; - virStorageVolDefPtr *objs; -}; =20 VIR_ENUM_DECL(virStorageVol) =20 diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index ff04c9efe4..50dbd7bf4d 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -37,6 +37,26 @@ VIR_LOG_INIT("conf.virstorageobj"); =20 =20 +struct _virStorageVolDefList { + size_t count; + virStorageVolDefPtr *objs; +}; + +struct _virStoragePoolObj { + virMutex lock; + + char *configFile; + char *autostartLink; + bool active; + bool autostart; + unsigned int asyncjobs; + + virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; + + virStorageVolDefList volumes; +}; + virStoragePoolObjPtr virStoragePoolObjNew(void) { diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index cf7ee06cd1..69e737226b 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -27,21 +27,6 @@ typedef struct _virStoragePoolObj virStoragePoolObj; typedef virStoragePoolObj *virStoragePoolObjPtr; =20 -struct _virStoragePoolObj { - virMutex lock; - - char *configFile; - char *autostartLink; - bool active; - bool autostart; - unsigned int asyncjobs; - - virStoragePoolDefPtr def; - virStoragePoolDefPtr newDef; - - virStorageVolDefList volumes; -}; - typedef struct _virStoragePoolObjList virStoragePoolObjList; typedef virStoragePoolObjList *virStoragePoolObjListPtr; struct _virStoragePoolObjList { --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list