From nobody Wed Apr 24 15:45:15 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 1505829607079521.2156524642909; Tue, 19 Sep 2017 07:00:07 -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 CFA7E806B3; Tue, 19 Sep 2017 14:00:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A68375D986; Tue, 19 Sep 2017 14:00:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 60BCB1855944; Tue, 19 Sep 2017 14:00:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDPTus012557 for ; Tue, 19 Sep 2017 09:25:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 090AA19C8D; Tue, 19 Sep 2017 13:25:29 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1DE561360 for ; Tue, 19 Sep 2017 13:25:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CFA7E806B3 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Tue, 19 Sep 2017 09:25:00 -0400 Message-Id: <20170919132518.28151-2-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/19] conf: Fix prototype/definition for virStoragePoolObj get functions 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.26]); Tue, 19 Sep 2017 14:00:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Modify virStoragePoolObjGetAutostartLink and virStoragePoolObjGetConfigFile to return "const char *" since that's how both are used and to ensure no one tries to VIR_FREE the result. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 4 ++-- src/conf/virstorageobj.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 1364bddd1..ff04c9efe 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -89,7 +89,7 @@ virStoragePoolObjDefUseNewDef(virStoragePoolObjPtr obj) } =20 =20 -char * +const char * virStoragePoolObjGetConfigFile(virStoragePoolObjPtr obj) { return obj->configFile; @@ -105,7 +105,7 @@ virStoragePoolObjSetConfigFile(virStoragePoolObjPtr obj, } =20 =20 -char * +const char * virStoragePoolObjGetAutostartLink(virStoragePoolObjPtr obj) { return obj->autostartLink; diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index b65b16019..cf7ee06cd 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -86,14 +86,14 @@ virStoragePoolObjGetNewDef(virStoragePoolObjPtr obj); void virStoragePoolObjDefUseNewDef(virStoragePoolObjPtr obj); =20 -char * +const char * virStoragePoolObjGetConfigFile(virStoragePoolObjPtr obj); =20 void virStoragePoolObjSetConfigFile(virStoragePoolObjPtr obj, char *configFile); =20 -char * +const char * virStoragePoolObjGetAutostartLink(virStoragePoolObjPtr obj); =20 bool --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505828233519464.26761209012886; Tue, 19 Sep 2017 06:37:13 -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 13F38267C8; Tue, 19 Sep 2017 13:37:12 +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 DAE6660637; Tue, 19 Sep 2017 13:37:11 +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 75A29410B2; Tue, 19 Sep 2017 13:37:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDPqEs012593 for ; Tue, 19 Sep 2017 09:25:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0900961346; Tue, 19 Sep 2017 13:25:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5252261361 for ; Tue, 19 Sep 2017 13:25:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 13F38267C8 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: Tue, 19 Sep 2017 09:25:01 -0400 Message-Id: <20170919132518.28151-3-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/19] storage: Use virStoragePoolObjGetDef accessor for driver 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.30]); Tue, 19 Sep 2017 13:37:12 +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 to fetch the obj->def instead of the direct reference. Signed-off-by: John Ferlan --- src/storage/storage_driver.c | 411 ++++++++++++++++++++++++---------------= ---- 1 file changed, 234 insertions(+), 177 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 7db1f5463..22f7333e0 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -103,17 +103,17 @@ virStoragePoolUpdateInactive(virStoragePoolObjPtr *ob= jptr) static void storagePoolUpdateState(virStoragePoolObjPtr obj) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); bool active =3D false; virStorageBackendPtr backend; char *stateFile; =20 - if (!(stateFile =3D virFileBuildPath(driver->stateDir, - obj->def->name, ".xml"))) + if (!(stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xm= l"))) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL= ) { + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing backend %d"), obj->def->type); + _("Missing backend %d"), def->type); goto cleanup; } =20 @@ -123,7 +123,7 @@ storagePoolUpdateState(virStoragePoolObjPtr obj) backend->checkPool(obj, &active) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to initialize storage pool '%s': %s"), - obj->def->name, virGetLastErrorMessage()); + def->name, virGetLastErrorMessage()); active =3D false; } =20 @@ -138,7 +138,7 @@ storagePoolUpdateState(virStoragePoolObjPtr obj) backend->stopPool(NULL, obj); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to restart storage pool '%s': %s"), - obj->def->name, virGetLastErrorMessage()); + def->name, virGetLastErrorMessage()); active =3D false; } } @@ -185,11 +185,12 @@ storageDriverAutostart(void) =20 for (i =3D 0; i < driver->pools.count; i++) { virStoragePoolObjPtr obj =3D driver->pools.objs[i]; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); virStorageBackendPtr backend; bool started =3D false; =20 virStoragePoolObjLock(obj); - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D = NULL) { + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL)= { virStoragePoolObjUnlock(obj); continue; } @@ -200,7 +201,7 @@ storageDriverAutostart(void) backend->startPool(conn, obj) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart storage pool '%s': %= s"), - obj->def->name, virGetLastErrorMessage()); + def->name, virGetLastErrorMessage()); virStoragePoolObjUnlock(obj); continue; } @@ -211,10 +212,9 @@ storageDriverAutostart(void) char *stateFile; =20 virStoragePoolObjClearVols(obj); - stateFile =3D virFileBuildPath(driver->stateDir, - obj->def->name, ".xml"); + stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".= xml"); if (!stateFile || - virStoragePoolSaveState(stateFile, obj->def) < 0 || + virStoragePoolSaveState(stateFile, def) < 0 || backend->refreshPool(conn, obj) < 0) { if (stateFile) unlink(stateFile); @@ -222,7 +222,7 @@ storageDriverAutostart(void) backend->stopPool(conn, obj); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart storage pool '%s': %= s"), - obj->def->name, virGetLastErrorMessage()); + def->name, virGetLastErrorMessage()); } else { virStoragePoolObjSetActive(obj, true); } @@ -441,6 +441,7 @@ storagePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; =20 storageDriverLock(); @@ -448,11 +449,12 @@ storagePoolLookupByUUID(virConnectPtr conn, storageDriverUnlock(); if (!obj) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolLookupByUUIDEnsureACL(conn, obj->def) < 0) + if (virStoragePoolLookupByUUIDEnsureACL(conn, def) < 0) goto cleanup; =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: virStoragePoolObjUnlock(obj); @@ -464,15 +466,17 @@ storagePoolLookupByName(virConnectPtr conn, const char *name) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; =20 if (!(obj =3D storagePoolObjFindByName(name))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolLookupByNameEnsureACL(conn, obj->def) < 0) + if (virStoragePoolLookupByNameEnsureACL(conn, def) < 0) goto cleanup; =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: virStoragePoolObjUnlock(obj); @@ -483,16 +487,17 @@ static virStoragePoolPtr storagePoolLookupByVolume(virStorageVolPtr vol) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; =20 if (!(obj =3D storagePoolObjFindByName(vol->pool))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, obj->def) < 0) + if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, def) < 0) goto cleanup; =20 - pool =3D virGetStoragePool(vol->conn, obj->def->name, obj->def->uuid, - NULL, NULL); + pool =3D virGetStoragePool(vol->conn, def->name, def->uuid, NULL, NULL= ); =20 cleanup: virStoragePoolObjUnlock(obj); @@ -613,12 +618,14 @@ static int storagePoolIsActive(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; int ret =3D -1; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolIsActiveEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolIsActiveEnsureACL(pool->conn, def) < 0) goto cleanup; =20 ret =3D virStoragePoolObjIsActive(obj); @@ -633,12 +640,14 @@ static int storagePoolIsPersistent(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; int ret =3D -1; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolIsPersistentEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolIsPersistentEnsureACL(pool->conn, def) < 0) goto cleanup; =20 ret =3D virStoragePoolObjGetConfigFile(obj) ? 1 : 0; @@ -654,8 +663,9 @@ storagePoolCreateXML(virConnectPtr conn, const char *xml, unsigned int flags) { - virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; @@ -670,24 +680,25 @@ storagePoolCreateXML(virConnectPtr conn, VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, NULL); =20 storageDriverLock(); - if (!(def =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - if (virStoragePoolCreateXMLEnsureACL(conn, def) < 0) + if (virStoragePoolCreateXMLEnsureACL(conn, newDef) < 0) goto cleanup; =20 - if (virStoragePoolObjIsDuplicate(&driver->pools, def, 1) < 0) + if (virStoragePoolObjIsDuplicate(&driver->pools, newDef, 1) < 0) goto cleanup; =20 - if (virStoragePoolObjSourceFindDuplicate(conn, &driver->pools, def) < = 0) + if (virStoragePoolObjSourceFindDuplicate(conn, &driver->pools, newDef)= < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(newDef->type)) =3D=3D NULL) goto cleanup; =20 - if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, newDef))) goto cleanup; - def =3D NULL; + newDef =3D NULL; + def =3D virStoragePoolObjGetDef(obj); =20 if (backend->buildPool) { if (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE) @@ -712,11 +723,10 @@ storagePoolCreateXML(virConnectPtr conn, goto cleanup; } =20 - stateFile =3D virFileBuildPath(driver->stateDir, - obj->def->name, ".xml"); + stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xml"); =20 virStoragePoolObjClearVols(obj); - if (!stateFile || virStoragePoolSaveState(stateFile, obj->def) < 0 || + if (!stateFile || virStoragePoolSaveState(stateFile, def) < 0 || backend->refreshPool(conn, obj) < 0) { if (stateFile) unlink(stateFile); @@ -727,19 +737,19 @@ storagePoolCreateXML(virConnectPtr conn, goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 - VIR_INFO("Creating storage pool '%s'", obj->def->name); + VIR_INFO("Creating storage pool '%s'", def->name); virStoragePoolObjSetActive(obj, true); =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: VIR_FREE(stateFile); - virStoragePoolDefFree(def); + virStoragePoolDefFree(newDef); if (event) virObjectEventStateQueue(driver->storageEventState, event); if (obj) @@ -753,38 +763,40 @@ storagePoolDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) { - virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, NULL); =20 storageDriverLock(); - if (!(def =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - if (virXMLCheckIllegalChars("name", def->name, "\n") < 0) + if (virXMLCheckIllegalChars("name", newDef->name, "\n") < 0) goto cleanup; =20 - if (virStoragePoolDefineXMLEnsureACL(conn, def) < 0) + if (virStoragePoolDefineXMLEnsureACL(conn, newDef) < 0) goto cleanup; =20 - if (virStoragePoolObjIsDuplicate(&driver->pools, def, 0) < 0) + if (virStoragePoolObjIsDuplicate(&driver->pools, newDef, 0) < 0) goto cleanup; =20 - if (virStoragePoolObjSourceFindDuplicate(conn, &driver->pools, def) < = 0) + if (virStoragePoolObjSourceFindDuplicate(conn, &driver->pools, newDef)= < 0) goto cleanup; =20 - if (virStorageBackendForType(def->type) =3D=3D NULL) + if (virStorageBackendForType(newDef->type) =3D=3D NULL) goto cleanup; =20 - if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, newDef))) goto cleanup; + newDef =3D NULL; + def =3D virStoragePoolObjGetDef(obj); =20 if (virStoragePoolObjSaveDef(driver, obj, def) < 0) { virStoragePoolObjRemove(&driver->pools, obj); - def =3D NULL; obj =3D NULL; goto cleanup; } @@ -793,15 +805,13 @@ storagePoolDefineXML(virConnectPtr conn, VIR_STORAGE_POOL_EVENT_DEFINED, 0); =20 - def =3D NULL; - - VIR_INFO("Defining storage pool '%s'", obj->def->name); - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + VIR_INFO("Defining storage pool '%s'", def->name); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - virStoragePoolDefFree(def); + virStoragePoolDefFree(newDef); if (obj) virStoragePoolObjUnlock(obj); storageDriverUnlock(); @@ -812,6 +822,7 @@ static int storagePoolUndefine(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; const char *autostartLink; virObjectEventPtr event =3D NULL; int ret =3D -1; @@ -819,21 +830,22 @@ storagePoolUndefine(virStoragePoolPtr pool) storageDriverLock(); if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolUndefineEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolUndefineEnsureACL(pool->conn, def) < 0) goto cleanup; =20 if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is still active"), - obj->def->name); + def->name); goto cleanup; } =20 if (virStoragePoolObjGetAsyncjobs(obj) > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - obj->def->name); + def->name); goto cleanup; } =20 @@ -848,13 +860,12 @@ storagePoolUndefine(virStoragePoolPtr pool) autostartLink, virStrerror(errno, ebuf, sizeof(ebuf))); } =20 - - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_UNDEFIN= ED, 0); =20 - VIR_INFO("Undefining storage pool '%s'", obj->def->name); + VIR_INFO("Undefining storage pool '%s'", def->name); virStoragePoolObjRemove(&driver->pools, obj); obj =3D NULL; ret =3D 0; @@ -873,6 +884,7 @@ storagePoolCreate(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; int ret =3D -1; @@ -888,17 +900,18 @@ storagePoolCreate(virStoragePoolPtr pool, =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolCreateEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolCreateEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is already active"), - obj->def->name); + def->name); goto cleanup; } =20 @@ -915,16 +928,15 @@ storagePoolCreate(virStoragePoolPtr pool, } } =20 - VIR_INFO("Starting up storage pool '%s'", obj->def->name); + VIR_INFO("Starting up storage pool '%s'", def->name); if (backend->startPool && backend->startPool(pool->conn, obj) < 0) goto cleanup; =20 - stateFile =3D virFileBuildPath(driver->stateDir, - obj->def->name, ".xml"); + stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xml"); =20 virStoragePoolObjClearVols(obj); - if (!stateFile || virStoragePoolSaveState(stateFile, obj->def) < 0 || + if (!stateFile || virStoragePoolSaveState(stateFile, def) < 0 || backend->refreshPool(pool->conn, obj) < 0) { if (stateFile) unlink(stateFile); @@ -933,8 +945,8 @@ storagePoolCreate(virStoragePoolPtr pool, goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 @@ -955,22 +967,24 @@ storagePoolBuild(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; int ret =3D -1; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolBuildEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolBuildEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is already active"), - obj->def->name); + def->name); goto cleanup; } =20 @@ -989,6 +1003,7 @@ static int storagePoolDestroy(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; char *stateFile =3D NULL; @@ -997,31 +1012,30 @@ storagePoolDestroy(virStoragePoolPtr pool) storageDriverLock(); if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolDestroyEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolDestroyEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 - VIR_INFO("Destroying storage pool '%s'", obj->def->name); + VIR_INFO("Destroying storage pool '%s'", def->name); =20 if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), obj->def->nam= e); + _("storage pool '%s' is not active"), def->name); goto cleanup; } =20 if (virStoragePoolObjGetAsyncjobs(obj) > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - obj->def->name); + def->name); goto cleanup; } =20 - if (!(stateFile =3D virFileBuildPath(driver->stateDir, - obj->def->name, - ".xml"))) + if (!(stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xm= l"))) goto cleanup; =20 unlink(stateFile); @@ -1033,8 +1047,8 @@ storagePoolDestroy(virStoragePoolPtr pool) =20 virStoragePoolObjClearVols(obj); =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_STOPPED, 0); =20 @@ -1058,38 +1072,38 @@ storagePoolDelete(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; char *stateFile =3D NULL; int ret =3D -1; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolDeleteEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolDeleteEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 - VIR_INFO("Deleting storage pool '%s'", obj->def->name); + VIR_INFO("Deleting storage pool '%s'", def->name); =20 if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is still active"), - obj->def->name); + def->name); goto cleanup; } =20 if (virStoragePoolObjGetAsyncjobs(obj) > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - obj->def->name); + def->name); goto cleanup; } =20 - if (!(stateFile =3D virFileBuildPath(driver->stateDir, - obj->def->name, - ".xml"))) + if (!(stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xm= l"))) goto cleanup; =20 unlink(stateFile); @@ -1116,6 +1130,7 @@ storagePoolRefresh(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; int ret =3D -1; virObjectEventPtr event =3D NULL; @@ -1125,23 +1140,24 @@ storagePoolRefresh(virStoragePoolPtr pool, storageDriverLock(); if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolRefreshEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolRefreshEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), obj->def->nam= e); + _("storage pool '%s' is not active"), def->name); goto cleanup; } =20 if (virStoragePoolObjGetAsyncjobs(obj) > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - obj->def->name); + def->name); goto cleanup; } =20 @@ -1150,8 +1166,8 @@ storagePoolRefresh(virStoragePoolPtr pool, if (backend->stopPool) backend->stopPool(pool->conn, obj); =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_STO= PPED, 0); virStoragePoolObjSetActive(obj, false); @@ -1161,8 +1177,8 @@ storagePoolRefresh(virStoragePoolPtr pool, goto cleanup; } =20 - event =3D virStoragePoolEventRefreshNew(obj->def->name, - obj->def->uuid); + event =3D virStoragePoolEventRefreshNew(def->name, + def->uuid); ret =3D 0; =20 cleanup: @@ -1180,15 +1196,17 @@ storagePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; int ret =3D -1; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolGetInfoEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolGetInfoEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if (virStorageBackendForType(obj->def->type) =3D=3D NULL) + if (virStorageBackendForType(def->type) =3D=3D NULL) goto cleanup; =20 memset(info, 0, sizeof(virStoragePoolInfo)); @@ -1196,9 +1214,9 @@ storagePoolGetInfo(virStoragePoolPtr pool, info->state =3D VIR_STORAGE_POOL_RUNNING; else info->state =3D VIR_STORAGE_POOL_INACTIVE; - info->capacity =3D obj->def->capacity; - info->allocation =3D obj->def->allocation; - info->available =3D obj->def->available; + info->capacity =3D def->capacity; + info->allocation =3D def->allocation; + info->available =3D def->available; ret =3D 0; =20 cleanup: @@ -1212,22 +1230,26 @@ storagePoolGetXMLDesc(virStoragePoolPtr pool, { virStoragePoolObjPtr obj; virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; + virStoragePoolDefPtr curDef; char *ret =3D NULL; =20 virCheckFlags(VIR_STORAGE_XML_INACTIVE, NULL); =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return NULL; + def =3D virStoragePoolObjGetDef(obj); + newDef =3D virStoragePoolObjGetNewDef(obj); =20 - if (virStoragePoolGetXMLDescEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolGetXMLDescEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if ((flags & VIR_STORAGE_XML_INACTIVE) && obj->newDef) - def =3D obj->newDef; + if ((flags & VIR_STORAGE_XML_INACTIVE) && newDef) + curDef =3D newDef; else - def =3D obj->def; + curDef =3D def; =20 - ret =3D virStoragePoolDefFormat(def); + ret =3D virStoragePoolDefFormat(curDef); =20 cleanup: virStoragePoolObjUnlock(obj); @@ -1244,7 +1266,8 @@ storagePoolGetAutostart(virStoragePoolPtr pool, if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; =20 - if (virStoragePoolGetAutostartEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolGetAutostartEnsureACL(pool->conn, + virStoragePoolObjGetDef(obj)) = < 0) goto cleanup; =20 *autostart =3D virStoragePoolObjIsAutostart(obj) ? 1 : 0; @@ -1271,7 +1294,8 @@ storagePoolSetAutostart(virStoragePoolPtr pool, if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; =20 - if (virStoragePoolSetAutostartEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolSetAutostartEnsureACL(pool->conn, + virStoragePoolObjGetDef(obj)) = < 0) goto cleanup; =20 if (!(configFile =3D virStoragePoolObjGetConfigFile(obj))) { @@ -1325,17 +1349,19 @@ static int storagePoolNumOfVolumes(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; int ret =3D -1; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolNumOfVolumesEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolNumOfVolumesEnsureACL(pool->conn, def) < 0) goto cleanup; =20 if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), obj->def->nam= e); + _("storage pool '%s' is not active"), def->name); goto cleanup; } =20 @@ -1354,17 +1380,19 @@ storagePoolListVolumes(virStoragePoolPtr pool, int maxnames) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; int n =3D -1; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolListVolumesEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolListVolumesEnsureACL(pool->conn, def) < 0) goto cleanup; =20 if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), obj->def->nam= e); + _("storage pool '%s' is not active"), def->name); goto cleanup; } =20 @@ -1383,19 +1411,21 @@ storagePoolListAllVolumes(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; int ret =3D -1; =20 virCheckFlags(0, -1); =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolListAllVolumesEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolListAllVolumesEnsureACL(pool->conn, def) < 0) goto cleanup; =20 if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), obj->def->nam= e); + _("storage pool '%s' is not active"), def->name); goto cleanup; } =20 @@ -1414,15 +1444,17 @@ storageVolLookupByName(virStoragePoolPtr pool, const char *name) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageVolDefPtr voldef; virStorageVolPtr vol =3D NULL; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), obj->def->nam= e); + _("storage pool '%s' is not active"), def->name); goto cleanup; } =20 @@ -1435,10 +1467,10 @@ storageVolLookupByName(virStoragePoolPtr pool, goto cleanup; } =20 - if (virStorageVolLookupByNameEnsureACL(pool->conn, obj->def, voldef) <= 0) + if (virStorageVolLookupByNameEnsureACL(pool->conn, def, voldef) < 0) goto cleanup; =20 - vol =3D virGetStorageVol(pool->conn, obj->def->name, voldef->name, + vol =3D virGetStorageVol(pool->conn, def->name, voldef->name, voldef->key, NULL, NULL); =20 cleanup: @@ -1456,26 +1488,26 @@ storageVolLookupByKey(virConnectPtr conn, =20 storageDriverLock(); for (i =3D 0; i < driver->pools.count && !vol; i++) { - virStoragePoolObjLock(driver->pools.objs[i]); - if (virStoragePoolObjIsActive(driver->pools.objs[i])) { - virStorageVolDefPtr voldef =3D - virStorageVolDefFindByKey(driver->pools.objs[i], key); + virStoragePoolObjPtr obj =3D driver->pools.objs[i]; + virStoragePoolDefPtr def; + + virStoragePoolObjLock(obj); + def =3D virStoragePoolObjGetDef(obj); + if (virStoragePoolObjIsActive(obj)) { + virStorageVolDefPtr voldef =3D virStorageVolDefFindByKey(obj, = key); =20 if (voldef) { - virStoragePoolDefPtr def =3D driver->pools.objs[i]->def; if (virStorageVolLookupByKeyEnsureACL(conn, def, voldef) <= 0) { - virStoragePoolObjUnlock(driver->pools.objs[i]); + virStoragePoolObjUnlock(obj); goto cleanup; } =20 - vol =3D virGetStorageVol(conn, - def->name, - voldef->name, - voldef->key, + vol =3D virGetStorageVol(conn, def->name, + voldef->name, voldef->key, NULL, NULL); } } - virStoragePoolObjUnlock(driver->pools.objs[i]); + virStoragePoolObjUnlock(obj); } =20 if (!vol) @@ -1502,17 +1534,19 @@ storageVolLookupByPath(virConnectPtr conn, storageDriverLock(); for (i =3D 0; i < driver->pools.count && !vol; i++) { virStoragePoolObjPtr obj =3D driver->pools.objs[i]; + virStoragePoolDefPtr def; virStorageVolDefPtr voldef; char *stable_path =3D NULL; =20 virStoragePoolObjLock(obj); + def =3D virStoragePoolObjGetDef(obj); =20 if (!virStoragePoolObjIsActive(obj)) { virStoragePoolObjUnlock(obj); continue; } =20 - switch ((virStoragePoolType) obj->def->type) { + switch ((virStoragePoolType) def->type) { case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_FS: case VIR_STORAGE_POOL_NETFS: @@ -1530,7 +1564,7 @@ storageVolLookupByPath(virConnectPtr conn, * getting the stable path for some of the pools. */ VIR_WARN("Failed to get stable path for pool '%s'", - obj->def->name); + def->name); virStoragePoolObjUnlock(obj); continue; } @@ -1552,12 +1586,12 @@ storageVolLookupByPath(virConnectPtr conn, VIR_FREE(stable_path); =20 if (voldef) { - if (virStorageVolLookupByPathEnsureACL(conn, obj->def, voldef)= < 0) { + if (virStorageVolLookupByPathEnsureACL(conn, def, voldef) < 0)= { virStoragePoolObjUnlock(obj); goto cleanup; } =20 - vol =3D virGetStorageVol(conn, obj->def->name, + vol =3D virGetStorageVol(conn, def->name, voldef->name, voldef->key, NULL, NULL); } @@ -1597,18 +1631,18 @@ storagePoolLookupByTargetPath(virConnectPtr conn, storageDriverLock(); for (i =3D 0; i < driver->pools.count && !pool; i++) { virStoragePoolObjPtr obj =3D driver->pools.objs[i]; + virStoragePoolDefPtr def; =20 virStoragePoolObjLock(obj); + def =3D virStoragePoolObjGetDef(obj); =20 if (!virStoragePoolObjIsActive(obj)) { virStoragePoolObjUnlock(obj); continue; } =20 - if (STREQ(path, obj->def->target.path)) { - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uui= d, - NULL, NULL); - } + if (STREQ(path, def->target.path)) + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, N= ULL); =20 virStoragePoolObjUnlock(obj); } @@ -1633,6 +1667,7 @@ storageVolDeleteInternal(virStorageVolPtr vol, unsigned int flags, bool updateMeta) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); int ret =3D -1; =20 if (!backend->deleteVol) { @@ -1650,9 +1685,9 @@ storageVolDeleteInternal(virStorageVolPtr vol, * Ignore the disk backend since it updates the pool values. */ if (updateMeta) { - if (obj->def->type !=3D VIR_STORAGE_POOL_DISK) { - obj->def->allocation -=3D voldef->target.allocation; - obj->def->available +=3D voldef->target.allocation; + if (def->type !=3D VIR_STORAGE_POOL_DISK) { + def->allocation -=3D voldef->target.allocation; + def->available +=3D voldef->target.allocation; } } =20 @@ -1670,14 +1705,16 @@ virStorageVolDefFromVol(virStorageVolPtr vol, virStorageBackendPtr *backend) { virStorageVolDefPtr voldef =3D NULL; + virStoragePoolDefPtr def; =20 if (!(*obj =3D storagePoolObjFindByName(vol->pool))) return NULL; + def =3D virStoragePoolObjGetDef(*obj); =20 if (!virStoragePoolObjIsActive(*obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), - (*obj)->def->name); + def->name); goto error; } =20 @@ -1689,7 +1726,7 @@ virStorageVolDefFromVol(virStorageVolPtr vol, } =20 if (backend) { - if (!(*backend =3D virStorageBackendForType((*obj)->def->type))) + if (!(*backend =3D virStorageBackendForType(def->type))) goto error; } =20 @@ -1715,7 +1752,8 @@ storageVolDelete(virStorageVolPtr vol, if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; =20 - if (virStorageVolDeleteEnsureACL(vol->conn, obj->def, voldef) < 0) + if (virStorageVolDeleteEnsureACL(vol->conn, virStoragePoolObjGetDef(ob= j), + voldef) < 0) goto cleanup; =20 if (voldef->in_use) { @@ -1749,6 +1787,7 @@ storageVolCreateXML(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virStorageVolDefPtr voldef =3D NULL; virStorageVolPtr vol =3D NULL, newvol =3D NULL; @@ -1757,17 +1796,18 @@ storageVolCreateXML(virStoragePoolPtr pool, =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), obj->def->nam= e); + _("storage pool '%s' is not active"), def->name); goto cleanup; } =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 - voldef =3D virStorageVolDefParseString(obj->def, xmldesc, + voldef =3D virStorageVolDefParseString(def, xmldesc, VIR_VOL_XML_PARSE_OPT_CAPACITY); if (voldef =3D=3D NULL) goto cleanup; @@ -1779,7 +1819,7 @@ storageVolCreateXML(virStoragePoolPtr pool, goto cleanup; } =20 - if (virStorageVolCreateXMLEnsureACL(pool->conn, obj->def, voldef) < 0) + if (virStorageVolCreateXMLEnsureACL(pool->conn, def, voldef) < 0) goto cleanup; =20 if (virStorageVolDefFindByName(obj, voldef->name)) { @@ -1801,7 +1841,7 @@ storageVolCreateXML(virStoragePoolPtr pool, if (backend->createVol(pool->conn, obj, voldef) < 0) goto cleanup; =20 - if (!(newvol =3D virGetStorageVol(pool->conn, obj->def->name, voldef->= name, + if (!(newvol =3D virGetStorageVol(pool->conn, def->name, voldef->name, voldef->key, NULL, NULL))) goto cleanup; =20 @@ -1860,13 +1900,13 @@ storageVolCreateXML(virStoragePoolPtr pool, /* Update pool metadata ignoring the disk backend since * it updates the pool values. */ - if (obj->def->type !=3D VIR_STORAGE_POOL_DISK) { - obj->def->allocation +=3D voldef->target.allocation; - obj->def->available -=3D voldef->target.allocation; + if (def->type !=3D VIR_STORAGE_POOL_DISK) { + def->allocation +=3D voldef->target.allocation; + def->available -=3D voldef->target.allocation; } =20 VIR_INFO("Creating volume '%s' in storage pool '%s'", - newvol->name, obj->def->name); + newvol->name, def->name); vol =3D newvol; newvol =3D NULL; voldef =3D NULL; @@ -1886,6 +1926,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolObjPtr objsrc =3D NULL; virStorageBackendPtr backend; virStorageVolDefPtr voldefsrc =3D NULL; @@ -1915,6 +1956,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, uuidstr, pool->name); goto cleanup; } + def =3D virStoragePoolObjGetDef(obj); =20 if (STRNEQ(pool->name, volsrc->pool) && !objsrc) { virReportError(VIR_ERR_NO_STORAGE_POOL, @@ -1925,18 +1967,19 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, =20 if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), obj->def->nam= e); + _("storage pool '%s' is not active"), def->name); goto cleanup; } =20 if (objsrc && !virStoragePoolObjIsActive(objsrc)) { + virStoragePoolDefPtr objsrcdef =3D virStoragePoolObjGetDef(objsrc); virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), - objsrc->def->name); + objsrcdef->name); goto cleanup; } =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 voldefsrc =3D virStorageVolDefFindByName(objsrc ? @@ -1948,12 +1991,12 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, goto cleanup; } =20 - voldef =3D virStorageVolDefParseString(obj->def, xmldesc, + voldef =3D virStorageVolDefParseString(def, xmldesc, VIR_VOL_XML_PARSE_NO_CAPACITY); if (voldef =3D=3D NULL) goto cleanup; =20 - if (virStorageVolCreateXMLFromEnsureACL(pool->conn, obj->def, voldef) = < 0) + if (virStorageVolCreateXMLFromEnsureACL(pool->conn, def, voldef) < 0) goto cleanup; =20 if (virStorageVolDefFindByName(obj, voldef->name)) { @@ -2009,7 +2052,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, =20 memcpy(shadowvol, voldef, sizeof(*voldef)); =20 - if (!(newvol =3D virGetStorageVol(pool->conn, obj->def->name, voldef->= name, + if (!(newvol =3D virGetStorageVol(pool->conn, def->name, voldef->name, voldef->key, NULL, NULL))) goto cleanup; =20 @@ -2057,13 +2100,13 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, /* Updating pool metadata ignoring the disk backend since * it updates the pool values */ - if (obj->def->type !=3D VIR_STORAGE_POOL_DISK) { - obj->def->allocation +=3D voldef->target.allocation; - obj->def->available -=3D voldef->target.allocation; + if (def->type !=3D VIR_STORAGE_POOL_DISK) { + def->allocation +=3D voldef->target.allocation; + def->available -=3D voldef->target.allocation; } =20 VIR_INFO("Creating volume '%s' in storage pool '%s'", - newvol->name, obj->def->name); + newvol->name, def->name); vol =3D newvol; newvol =3D NULL; voldef =3D NULL; @@ -2097,7 +2140,8 @@ storageVolDownload(virStorageVolPtr vol, if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; =20 - if (virStorageVolDownloadEnsureACL(vol->conn, obj->def, voldef) < 0) + if (virStorageVolDownloadEnsureACL(vol->conn, virStoragePoolObjGetDef(= obj), + voldef) < 0) goto cleanup; =20 if (voldef->building) { @@ -2191,6 +2235,7 @@ virStorageVolPoolRefreshThread(void *opaque) =20 virStorageVolStreamInfoPtr cbdata =3D opaque; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; =20 @@ -2202,16 +2247,16 @@ virStorageVolPoolRefreshThread(void *opaque) if (!(obj =3D virStoragePoolObjFindByName(&driver->pools, cbdata->pool_name))) goto cleanup; + def =3D virStoragePoolObjGetDef(obj); =20 - if (!(backend =3D virStorageBackendForType(obj->def->type))) + if (!(backend =3D virStorageBackendForType(def->type))) goto cleanup; =20 virStoragePoolObjClearVols(obj); if (backend->refreshPool(NULL, obj) < 0) VIR_DEBUG("Failed to refresh storage pool"); =20 - event =3D virStoragePoolEventRefreshNew(obj->def->name, - obj->def->uuid); + event =3D virStoragePoolEventRefreshNew(def->name, def->uuid); =20 cleanup: if (event) @@ -2256,6 +2301,7 @@ storageVolUpload(virStorageVolPtr vol, { virStorageBackendPtr backend; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStorageVolDefPtr voldef =3D NULL; virStorageVolStreamInfoPtr cbdata =3D NULL; int ret =3D -1; @@ -2264,8 +2310,9 @@ storageVolUpload(virStorageVolPtr vol, =20 if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStorageVolUploadEnsureACL(vol->conn, obj->def, voldef) < 0) + if (virStorageVolUploadEnsureACL(vol->conn, def, voldef) < 0) goto cleanup; =20 if (voldef->in_use) { @@ -2295,7 +2342,7 @@ storageVolUpload(virStorageVolPtr vol, * routine in order to call the refresh API. */ if (VIR_ALLOC(cbdata) < 0 || - VIR_STRDUP(cbdata->pool_name, obj->def->name) < 0) + VIR_STRDUP(cbdata->pool_name, def->name) < 0) goto cleanup; if (voldef->type =3D=3D VIR_STORAGE_VOL_PLOOP && VIR_STRDUP(cbdata->vol_path, voldef->target.path) < 0) @@ -2328,6 +2375,7 @@ storageVolResize(virStorageVolPtr vol, { virStorageBackendPtr backend; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStorageVolDefPtr voldef =3D NULL; unsigned long long abs_capacity, delta =3D 0; int ret =3D -1; @@ -2338,8 +2386,9 @@ storageVolResize(virStorageVolPtr vol, =20 if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStorageVolResizeEnsureACL(vol->conn, obj->def, voldef) < 0) + if (virStorageVolResizeEnsureACL(vol->conn, def, voldef) < 0) goto cleanup; =20 if (voldef->in_use) { @@ -2384,7 +2433,7 @@ storageVolResize(virStorageVolPtr vol, if (flags & VIR_STORAGE_VOL_RESIZE_ALLOCATE) delta =3D abs_capacity - voldef->target.allocation; =20 - if (delta > obj->def->available) { + if (delta > def->available) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("Not enough space left in storage pool")); goto cleanup; @@ -2407,8 +2456,8 @@ storageVolResize(virStorageVolPtr vol, */ if (flags & VIR_STORAGE_VOL_RESIZE_ALLOCATE) { voldef->target.allocation =3D abs_capacity; - obj->def->allocation +=3D delta; - obj->def->available -=3D delta; + def->allocation +=3D delta; + def->available -=3D delta; } =20 ret =3D 0; @@ -2442,7 +2491,9 @@ storageVolWipePattern(virStorageVolPtr vol, if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; =20 - if (virStorageVolWipePatternEnsureACL(vol->conn, obj->def, voldef) < 0) + if (virStorageVolWipePatternEnsureACL(vol->conn, + virStoragePoolObjGetDef(obj), + voldef) < 0) goto cleanup; =20 if (voldef->in_use) { @@ -2506,7 +2557,9 @@ storageVolGetInfoFlags(virStorageVolPtr vol, if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; =20 - if (virStorageVolGetInfoFlagsEnsureACL(vol->conn, obj->def, voldef) < = 0) + if (virStorageVolGetInfoFlagsEnsureACL(vol->conn, + virStoragePoolObjGetDef(obj), + voldef) < 0) goto cleanup; =20 if (backend->refreshVol && @@ -2541,6 +2594,7 @@ storageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virStorageVolDefPtr voldef; char *ret =3D NULL; @@ -2549,15 +2603,16 @@ storageVolGetXMLDesc(virStorageVolPtr vol, =20 if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStorageVolGetXMLDescEnsureACL(vol->conn, obj->def, voldef) < 0) + if (virStorageVolGetXMLDescEnsureACL(vol->conn, def, voldef) < 0) goto cleanup; =20 if (backend->refreshVol && backend->refreshVol(vol->conn, obj, voldef) < 0) goto cleanup; =20 - ret =3D virStorageVolDefFormat(obj->def, voldef); + ret =3D virStorageVolDefFormat(def, voldef); =20 cleanup: virStoragePoolObjUnlock(obj); @@ -2575,7 +2630,8 @@ storageVolGetPath(virStorageVolPtr vol) if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, NULL))) return NULL; =20 - if (virStorageVolGetPathEnsureACL(vol->conn, obj->def, voldef) < 0) + if (virStorageVolGetPathEnsureACL(vol->conn, virStoragePoolObjGetDef(o= bj), + voldef) < 0) goto cleanup; =20 ignore_value(VIR_STRDUP(ret, voldef->target.path)); @@ -3025,9 +3081,10 @@ virStoragePoolObjBuildTempFilePath(virStoragePoolObj= Ptr obj, virStorageVolDefPtr voldef) =20 { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); char *tmp =3D NULL; =20 ignore_value(virAsprintf(&tmp, "%s/%s.%s.secret.XXXXXX", - driver->stateDir, obj->def->name, voldef->nam= e)); + driver->stateDir, def->name, voldef->name)); return tmp; } --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505828254928423.28304485357205; Tue, 19 Sep 2017 06:37:34 -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 9637D81236; Tue, 19 Sep 2017 13:37:33 +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 77B1460618; Tue, 19 Sep 2017 13:37:33 +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 37C5D1855944; Tue, 19 Sep 2017 13:37:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDPtv2012605 for ; Tue, 19 Sep 2017 09:25:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id E13E56134D; Tue, 19 Sep 2017 13:25:54 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id A47EF19EED for ; Tue, 19 Sep 2017 13:25:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9637D81236 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: Tue, 19 Sep 2017 09:25:02 -0400 Message-Id: <20170919132518.28151-4-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/19] test: Rename @vol to @volDef in testOpenVolumesForPool 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.25]); Tue, 19 Sep 2017 13:37:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make it more obvious as we're about to need to change how obj->def gets referenced. Perform a couple of minor cleanups along the way too. Signed-off-by: John Ferlan --- src/test/test_driver.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index aacb513d6..07eb9d628 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1050,7 +1050,7 @@ testOpenVolumesForPool(const char *file, size_t i; int num, ret =3D -1; xmlNodePtr *nodes =3D NULL; - virStorageVolDefPtr def =3D NULL; + virStorageVolDefPtr volDef =3D NULL; =20 /* Find storage volumes */ if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0) @@ -1067,30 +1067,29 @@ testOpenVolumesForPool(const char *file, if (!node) goto error; =20 - def =3D virStorageVolDefParseNode(obj->def, ctxt->doc, node, 0); - if (!def) + if (!(volDef =3D virStorageVolDefParseNode(obj->def, ctxt->doc, no= de, 0))) goto error; =20 - if (def->target.path =3D=3D NULL) { - if (virAsprintf(&def->target.path, "%s/%s", - obj->def->target.path, def->name) < 0) + if (!volDef->target.path) { + if (virAsprintf(&volDef->target.path, "%s/%s", + obj->def->target.path, volDef->name) < 0) goto error; } =20 - if (!def->key && VIR_STRDUP(def->key, def->target.path) < 0) + if (!volDef->key && VIR_STRDUP(volDef->key, volDef->target.path) <= 0) goto error; =20 - if (virStoragePoolObjAddVol(obj, def) < 0) + if (virStoragePoolObjAddVol(obj, volDef) < 0) goto error; =20 - obj->def->allocation +=3D def->target.allocation; + obj->def->allocation +=3D volDef->target.allocation; obj->def->available =3D (obj->def->capacity - obj->def->allocation= ); - def =3D NULL; + volDef =3D NULL; } =20 ret =3D 0; error: - virStorageVolDefFree(def); + virStorageVolDefFree(volDef); VIR_FREE(nodes); return ret; } --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505829628354723.7258539902425; Tue, 19 Sep 2017 07:00:28 -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 F36727EA9E; Tue, 19 Sep 2017 14:00:26 +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 A3C875D6AE; Tue, 19 Sep 2017 14:00:26 +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 628141855946; Tue, 19 Sep 2017 14:00:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDPwe0012616 for ; Tue, 19 Sep 2017 09:25:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id F35E8197F3; Tue, 19 Sep 2017 13:25:57 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7CBE6134B for ; Tue, 19 Sep 2017 13:25:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F36727EA9E 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: Tue, 19 Sep 2017 09:25:03 -0400 Message-Id: <20170919132518.28151-5-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/19] test: Create local virStoragePoolObjPtr VolLookup APIs 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.28]); Tue, 19 Sep 2017 14:00:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than accessing privconn->pools.objs[i] in the for loop, let's use an @obj variable to make it easier to read the code. Signed-off-by: John Ferlan --- src/test/test_driver.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 07eb9d628..7ddff053b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4907,27 +4907,28 @@ testStorageVolLookupByKey(virConnectPtr conn, const char *key) { testDriverPtr privconn =3D conn->privateData; + virStoragePoolObjPtr obj; size_t i; virStorageVolPtr ret =3D NULL; =20 testDriverLock(privconn); for (i =3D 0; i < privconn->pools.count; i++) { - virStoragePoolObjLock(privconn->pools.objs[i]); - if (virStoragePoolObjIsActive(privconn->pools.objs[i])) { - virStorageVolDefPtr privvol =3D - virStorageVolDefFindByKey(privconn->pools.objs[i], key); + obj =3D privconn->pools.objs[i]; + virStoragePoolObjLock(obj); + if (virStoragePoolObjIsActive(obj)) { + virStorageVolDefPtr privvol =3D virStorageVolDefFindByKey(obj,= key); =20 if (privvol) { ret =3D virGetStorageVol(conn, - privconn->pools.objs[i]->def->name, + obj->def->name, privvol->name, privvol->key, NULL, NULL); - virStoragePoolObjUnlock(privconn->pools.objs[i]); + virStoragePoolObjUnlock(obj); break; } } - virStoragePoolObjUnlock(privconn->pools.objs[i]); + virStoragePoolObjUnlock(obj); } testDriverUnlock(privconn); =20 @@ -4944,27 +4945,28 @@ testStorageVolLookupByPath(virConnectPtr conn, const char *path) { testDriverPtr privconn =3D conn->privateData; + virStoragePoolObjPtr obj; size_t i; virStorageVolPtr ret =3D NULL; =20 testDriverLock(privconn); for (i =3D 0; i < privconn->pools.count; i++) { - virStoragePoolObjLock(privconn->pools.objs[i]); - if (virStoragePoolObjIsActive(privconn->pools.objs[i])) { - virStorageVolDefPtr privvol =3D - virStorageVolDefFindByPath(privconn->pools.objs[i], path); + obj =3D privconn->pools.objs[i]; + virStoragePoolObjLock(obj); + if (virStoragePoolObjIsActive(obj)) { + virStorageVolDefPtr privvol =3D virStorageVolDefFindByPath(obj= , path); =20 if (privvol) { ret =3D virGetStorageVol(conn, - privconn->pools.objs[i]->def->name, + obj->def->name, privvol->name, privvol->key, NULL, NULL); - virStoragePoolObjUnlock(privconn->pools.objs[i]); + virStoragePoolObjUnlock(obj); break; } } - virStoragePoolObjUnlock(privconn->pools.objs[i]); + virStoragePoolObjUnlock(obj); } testDriverUnlock(privconn); =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505829646853512.4037268367938; Tue, 19 Sep 2017 07:00:46 -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 BD94AC052426; Tue, 19 Sep 2017 14:00:45 +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 98FE95D75D; Tue, 19 Sep 2017 14:00:45 +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 552E13FACF; Tue, 19 Sep 2017 14:00:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQ093012627 for ; Tue, 19 Sep 2017 09:26:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 125B3197F3; Tue, 19 Sep 2017 13:26:00 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB25F61346 for ; Tue, 19 Sep 2017 13:25:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BD94AC052426 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: Tue, 19 Sep 2017 09:25:04 -0400 Message-Id: <20170919132518.28151-6-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/19] test: Use virStoragePoolObjGetDef accessor 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.32]); Tue, 19 Sep 2017 14:00:46 +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/test/test_driver.c | 162 +++++++++++++++++++++++++++------------------= ---- 1 file changed, 91 insertions(+), 71 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7ddff053b..5e68b03e5 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1046,6 +1046,7 @@ testOpenVolumesForPool(const char *file, virStoragePoolObjPtr obj, int objidx) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); char *vol_xpath; size_t i; int num, ret =3D -1; @@ -1067,12 +1068,12 @@ testOpenVolumesForPool(const char *file, if (!node) goto error; =20 - if (!(volDef =3D virStorageVolDefParseNode(obj->def, ctxt->doc, no= de, 0))) + if (!(volDef =3D virStorageVolDefParseNode(def, ctxt->doc, node, 0= ))) goto error; =20 if (!volDef->target.path) { if (virAsprintf(&volDef->target.path, "%s/%s", - obj->def->target.path, volDef->name) < 0) + def->target.path, volDef->name) < 0) goto error; } =20 @@ -1082,8 +1083,8 @@ testOpenVolumesForPool(const char *file, if (virStoragePoolObjAddVol(obj, volDef) < 0) goto error; =20 - obj->def->allocation +=3D volDef->target.allocation; - obj->def->available =3D (obj->def->capacity - obj->def->allocation= ); + def->allocation +=3D volDef->target.allocation; + def->available =3D (def->capacity - def->allocation); volDef =3D NULL; } =20 @@ -4072,10 +4073,11 @@ static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj) { char *configFile; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); =20 - obj->def->capacity =3D defaultPoolCap; - obj->def->allocation =3D defaultPoolAlloc; - obj->def->available =3D defaultPoolCap - defaultPoolAlloc; + def->capacity =3D defaultPoolCap; + def->allocation =3D defaultPoolAlloc; + def->available =3D defaultPoolCap - defaultPoolAlloc; =20 if (VIR_STRDUP(configFile, "") < 0) return -1; @@ -4172,13 +4174,14 @@ testStoragePoolLookupByUUID(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindByUUID(privconn, uuid))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, - NULL, NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 virStoragePoolObjUnlock(obj); return pool; @@ -4191,13 +4194,14 @@ testStoragePoolLookupByName(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindByName(privconn, name))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, - NULL, NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 virStoragePoolObjUnlock(obj); return pool; @@ -4442,38 +4446,40 @@ testStoragePoolCreateXML(virConnectPtr conn, unsigned int flags) { testDriverPtr privconn =3D conn->privateData; - virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, NULL); =20 testDriverLock(privconn); - if (!(def =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - obj =3D virStoragePoolObjFindByUUID(&privconn->pools, def->uuid); + obj =3D virStoragePoolObjFindByUUID(&privconn->pools, newDef->uuid); if (!obj) - obj =3D virStoragePoolObjFindByName(&privconn->pools, def->name); + obj =3D virStoragePoolObjFindByName(&privconn->pools, newDef->name= ); if (obj) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("storage pool already exists")); goto cleanup; } =20 - if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, newDef))) goto cleanup; - def =3D NULL; + newDef =3D NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - if (obj->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_H= OST) { + if (def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { /* In the real code, we'd call virVHBAManageVport followed by * find_new_device, but we cannot do that here since we're not * mocking udev. The mock routine will copy an existing vHBA and * rename a few fields to mock that. */ if (testCreateVport(privconn, - obj->def->source.adapter.data.fchost.wwnn, - obj->def->source.adapter.data.fchost.wwpn) < 0= ) { + def->source.adapter.data.fchost.wwnn, + def->source.adapter.data.fchost.wwpn) < 0) { virStoragePoolObjRemove(&privconn->pools, obj); obj =3D NULL; goto cleanup; @@ -4493,14 +4499,14 @@ testStoragePoolCreateXML(virConnectPtr conn, =20 virStoragePoolObjSetActive(obj, true); =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uu= id, + event =3D virStoragePoolEventLifecycleNew(def->name, def->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: - virStoragePoolDefFree(def); + virStoragePoolDefFree(newDef); testObjectEventQueue(privconn, event); if (obj) virStoragePoolObjUnlock(obj); @@ -4515,26 +4521,28 @@ testStoragePoolDefineXML(virConnectPtr conn, unsigned int flags) { testDriverPtr privconn =3D conn->privateData; - virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, NULL); =20 testDriverLock(privconn); - if (!(def =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - def->capacity =3D defaultPoolCap; - def->allocation =3D defaultPoolAlloc; - def->available =3D defaultPoolCap - defaultPoolAlloc; + newDef->capacity =3D defaultPoolCap; + newDef->allocation =3D defaultPoolAlloc; + newDef->available =3D defaultPoolCap - defaultPoolAlloc; =20 - if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, newDef))) goto cleanup; - def =3D NULL; + newDef =3D NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uu= id, + event =3D virStoragePoolEventLifecycleNew(def->name, def->uuid, VIR_STORAGE_POOL_EVENT_DEFINED, 0); =20 @@ -4544,10 +4552,10 @@ testStoragePoolDefineXML(virConnectPtr conn, goto cleanup; } =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: - virStoragePoolDefFree(def); + virStoragePoolDefFree(newDef); testObjectEventQueue(privconn, event); if (obj) virStoragePoolObjUnlock(obj); @@ -4633,24 +4641,25 @@ testStoragePoolDestroy(virStoragePoolPtr pool) { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; int ret =3D -1; virObjectEventPtr event =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 virStoragePoolObjSetActive(obj, false); =20 - if (obj->def->source.adapter.type =3D=3D - VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { + if (def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { if (testDestroyVport(privconn, - obj->def->source.adapter.data.fchost.wwnn, - obj->def->source.adapter.data.fchost.wwpn) < = 0) + def->source.adapter.data.fchost.wwnn, + def->source.adapter.data.fchost.wwpn) < 0) goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_STOPPED, 0); =20 @@ -4712,18 +4721,20 @@ testStoragePoolGetInfo(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; =20 if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 memset(info, 0, sizeof(virStoragePoolInfo)); if (virStoragePoolObjIsActive(obj)) info->state =3D VIR_STORAGE_POOL_RUNNING; else info->state =3D VIR_STORAGE_POOL_INACTIVE; - info->capacity =3D obj->def->capacity; - info->allocation =3D obj->def->allocation; - info->available =3D obj->def->available; + info->capacity =3D def->capacity; + info->allocation =3D def->allocation; + info->available =3D def->available; =20 virStoragePoolObjUnlock(obj); return 0; @@ -4743,7 +4754,7 @@ testStoragePoolGetXMLDesc(virStoragePoolPtr pool, if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) return NULL; =20 - ret =3D virStoragePoolDefFormat(obj->def); + ret =3D virStoragePoolDefFormat(virStoragePoolObjGetDef(obj)); =20 virStoragePoolObjUnlock(obj); return ret; @@ -4883,16 +4894,18 @@ testStorageVolLookupByName(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageVolDefPtr privvol; virStorageVolPtr ret =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 if (!(privvol =3D testStorageVolDefFindByName(obj, name))) goto cleanup; =20 - ret =3D virGetStorageVol(pool->conn, obj->def->name, + ret =3D virGetStorageVol(pool->conn, def->name, privvol->name, privvol->key, NULL, NULL); =20 @@ -4908,6 +4921,7 @@ testStorageVolLookupByKey(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; size_t i; virStorageVolPtr ret =3D NULL; =20 @@ -4915,14 +4929,13 @@ testStorageVolLookupByKey(virConnectPtr conn, for (i =3D 0; i < privconn->pools.count; i++) { obj =3D privconn->pools.objs[i]; virStoragePoolObjLock(obj); + def =3D virStoragePoolObjGetDef(obj); if (virStoragePoolObjIsActive(obj)) { virStorageVolDefPtr privvol =3D virStorageVolDefFindByKey(obj,= key); =20 if (privvol) { - ret =3D virGetStorageVol(conn, - obj->def->name, - privvol->name, - privvol->key, + ret =3D virGetStorageVol(conn, def->name, + privvol->name, privvol->key, NULL, NULL); virStoragePoolObjUnlock(obj); break; @@ -4946,6 +4959,7 @@ testStorageVolLookupByPath(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; size_t i; virStorageVolPtr ret =3D NULL; =20 @@ -4953,14 +4967,13 @@ testStorageVolLookupByPath(virConnectPtr conn, for (i =3D 0; i < privconn->pools.count; i++) { obj =3D privconn->pools.objs[i]; virStoragePoolObjLock(obj); + def =3D virStoragePoolObjGetDef(obj); if (virStoragePoolObjIsActive(obj)) { virStorageVolDefPtr privvol =3D virStorageVolDefFindByPath(obj= , path); =20 if (privvol) { - ret =3D virGetStorageVol(conn, - obj->def->name, - privvol->name, - privvol->key, + ret =3D virGetStorageVol(conn, def->name, + privvol->name, privvol->key, NULL, NULL); virStoragePoolObjUnlock(obj); break; @@ -4985,6 +4998,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageVolDefPtr privvol =3D NULL; virStorageVolPtr ret =3D NULL; =20 @@ -4992,8 +5006,9 @@ testStorageVolCreateXML(virStoragePoolPtr pool, =20 if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - privvol =3D virStorageVolDefParseString(obj->def, xmldesc, 0); + privvol =3D virStorageVolDefParseString(def, xmldesc, 0); if (privvol =3D=3D NULL) goto cleanup; =20 @@ -5004,8 +5019,8 @@ testStorageVolCreateXML(virStoragePoolPtr pool, } =20 /* Make sure enough space */ - if ((obj->def->allocation + privvol->target.allocation) > - obj->def->capacity) { + if ((def->allocation + privvol->target.allocation) > + def->capacity) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Not enough free space in pool for volume '%s'"), privvol->name); @@ -5013,17 +5028,17 @@ testStorageVolCreateXML(virStoragePoolPtr pool, } =20 if (virAsprintf(&privvol->target.path, "%s/%s", - obj->def->target.path, privvol->name) < 0) + def->target.path, privvol->name) < 0) goto cleanup; =20 if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || virStoragePoolObjAddVol(obj, privvol) < 0) goto cleanup; =20 - obj->def->allocation +=3D privvol->target.allocation; - obj->def->available =3D (obj->def->capacity - obj->def->allocation); + def->allocation +=3D privvol->target.allocation; + def->available =3D (def->capacity - def->allocation); =20 - ret =3D virGetStorageVol(pool->conn, obj->def->name, + ret =3D virGetStorageVol(pool->conn, def->name, privvol->name, privvol->key, NULL, NULL); privvol =3D NULL; @@ -5043,6 +5058,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageVolDefPtr privvol =3D NULL, origvol =3D NULL; virStorageVolPtr ret =3D NULL; =20 @@ -5050,8 +5066,9 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, =20 if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - privvol =3D virStorageVolDefParseString(obj->def, xmldesc, 0); + privvol =3D virStorageVolDefParseString(def, xmldesc, 0); if (privvol =3D=3D NULL) goto cleanup; =20 @@ -5070,27 +5087,26 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, } =20 /* Make sure enough space */ - if ((obj->def->allocation + privvol->target.allocation) > - obj->def->capacity) { + if ((def->allocation + privvol->target.allocation) > def->capacity) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Not enough free space in pool for volume '%s'"), privvol->name); goto cleanup; } - obj->def->available =3D (obj->def->capacity - obj->def->allocation); + def->available =3D (def->capacity - def->allocation); =20 if (virAsprintf(&privvol->target.path, "%s/%s", - obj->def->target.path, privvol->name) < 0) + def->target.path, privvol->name) < 0) goto cleanup; =20 if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || virStoragePoolObjAddVol(obj, privvol) < 0) goto cleanup; =20 - obj->def->allocation +=3D privvol->target.allocation; - obj->def->available =3D (obj->def->capacity - obj->def->allocation); + def->allocation +=3D privvol->target.allocation; + def->available =3D (def->capacity - def->allocation); =20 - ret =3D virGetStorageVol(pool->conn, obj->def->name, + ret =3D virGetStorageVol(pool->conn, def->name, privvol->name, privvol->key, NULL, NULL); privvol =3D NULL; @@ -5108,6 +5124,7 @@ testStorageVolDelete(virStorageVolPtr vol, { testDriverPtr privconn =3D vol->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageVolDefPtr privvol; int ret =3D -1; =20 @@ -5115,12 +5132,13 @@ testStorageVolDelete(virStorageVolPtr vol, =20 if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, vol->pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 if (!(privvol =3D testStorageVolDefFindByName(obj, vol->name))) goto cleanup; =20 - obj->def->allocation -=3D privvol->target.allocation; - obj->def->available =3D (obj->def->capacity - obj->def->allocation); + def->allocation -=3D privvol->target.allocation; + def->available =3D (def->capacity - def->allocation); =20 virStoragePoolObjRemoveVol(obj, privvol); =20 @@ -5153,17 +5171,19 @@ testStorageVolGetInfo(virStorageVolPtr vol, { testDriverPtr privconn =3D vol->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageVolDefPtr privvol; int ret =3D -1; =20 if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, vol->pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 if (!(privvol =3D testStorageVolDefFindByName(obj, vol->name))) goto cleanup; =20 memset(info, 0, sizeof(*info)); - info->type =3D testStorageVolumeTypeForPool(obj->def->type); + info->type =3D testStorageVolumeTypeForPool(def->type); info->capacity =3D privvol->target.capacity; info->allocation =3D privvol->target.allocation; ret =3D 0; @@ -5191,7 +5211,7 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, if (!(privvol =3D testStorageVolDefFindByName(obj, vol->name))) goto cleanup; =20 - ret =3D virStorageVolDefFormat(obj->def, privvol); + ret =3D virStorageVolDefFormat(virStoragePoolObjGetDef(obj), privvol); =20 cleanup: virStoragePoolObjUnlock(obj); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505829664348661.6803936895839; Tue, 19 Sep 2017 07:01:04 -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 3227A7C83A; Tue, 19 Sep 2017 14:01:03 +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 F325261F25; Tue, 19 Sep 2017 14:01:02 +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 96C201806104; Tue, 19 Sep 2017 14:01:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQ1u6012642 for ; Tue, 19 Sep 2017 09:26:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id E044550ED8; Tue, 19 Sep 2017 13:26:00 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1358197F9 for ; Tue, 19 Sep 2017 13:26:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3227A7C83A Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Tue, 19 Sep 2017 09:25:05 -0400 Message-Id: <20170919132518.28151-7-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/19] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 19 Sep 2017 14:01:03 +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 07dba2222..adcec36cc 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)) { @@ -2769,6 +2774,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; @@ -2776,12 +2782,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 @@ -2797,11 +2803,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; @@ -2809,10 +2815,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 @@ -2837,14 +2843,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 @@ -3576,6 +3584,7 @@ int virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); DIR *dir; struct dirent *ent; struct statvfs sb; @@ -3585,15 +3594,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 @@ -3605,8 +3614,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) @@ -3634,17 +3642,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 @@ -3652,24 +3660,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; @@ -3739,6 +3747,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; @@ -3750,12 +3759,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 @@ -3789,11 +3798,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; @@ -3808,8 +3817,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; @@ -4086,6 +4095,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"; @@ -4127,7 +4137,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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505828552727444.30979486933745; Tue, 19 Sep 2017 06:42:32 -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 59E9865980; Tue, 19 Sep 2017 13:42:31 +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 0470460618; Tue, 19 Sep 2017 13:42:31 +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 781DC410B2; Tue, 19 Sep 2017 13:42:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQ2dj012651 for ; Tue, 19 Sep 2017 09:26:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79CE660475; Tue, 19 Sep 2017 13:26:01 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FB0061348 for ; Tue, 19 Sep 2017 13:26:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 59E9865980 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: Tue, 19 Sep 2017 09:25:06 -0400 Message-Id: <20170919132518.28151-8-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/19] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 19 Sep 2017 13:42:31 +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 a0f94512e..44c135d80 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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505828573124360.17873586019755; Tue, 19 Sep 2017 06:42:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1DF5E80C06; Tue, 19 Sep 2017 13:42:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA7F260466; Tue, 19 Sep 2017 13:42:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A9F1C410AD; Tue, 19 Sep 2017 13:42:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQ304012659 for ; Tue, 19 Sep 2017 09:26:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 10C9B6134A; Tue, 19 Sep 2017 13:26:02 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7D4D1981E for ; Tue, 19 Sep 2017 13:26:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1DF5E80C06 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Tue, 19 Sep 2017 09:25:07 -0400 Message-Id: <20170919132518.28151-9-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/19] storage: Use virStoragePoolObjGetDef accessor for Logical backend X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 19 Sep 2017 13:42:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In preparation for privatizing the object, use the accessor. Signed-off-by: John Ferlan --- src/storage/storage_backend_logical.c | 63 ++++++++++++++++++++-----------= ---- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 7bfe211c2..0ad357729 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -53,10 +53,11 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr = pool, int on) { int ret; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D virCommandNewArgList(VGCHANGE, on ? "-aly" : "-aln", - pool->def->source.name, + def->source.name, NULL); =20 ret =3D virCommandRun(cmd, NULL); @@ -266,6 +267,7 @@ virStorageBackendLogicalMakeVol(char **const groups, { struct virStorageBackendLogicalPoolVolData *data =3D opaque; virStoragePoolObjPtr pool =3D data->pool; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStorageVolDefPtr vol =3D NULL; bool is_new_vol =3D false; int ret =3D -1; @@ -309,7 +311,7 @@ virStorageBackendLogicalMakeVol(char **const groups, =20 if (vol->target.path =3D=3D NULL) { if (virAsprintf(&vol->target.path, "%s/%s", - pool->def->target.path, vol->name) < 0) + def->target.path, vol->name) < 0) goto cleanup; } =20 @@ -334,7 +336,7 @@ virStorageBackendLogicalMakeVol(char **const groups, goto cleanup; =20 if (virAsprintf(&vol->target.backingStore->path, "%s/%s", - pool->def->target.path, groups[1]) < 0) + def->target.path, groups[1]) < 0) goto cleanup; =20 vol->target.backingStore->format =3D VIR_STORAGE_POOL_LOGICAL_LVM2; @@ -433,6 +435,7 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr po= ol, }; int ret =3D -1; virCommandPtr cmd; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); struct virStorageBackendLogicalPoolVolData cbdata =3D { .pool =3D pool, .vol =3D vol, @@ -446,7 +449,7 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr po= ol, "--nosuffix", "--options", "lv_name,origin,uuid,devices,segtype,stripe= s,seg_size,vg_extent_size,size,lv_attr", - pool->def->source.name, + def->source.name, NULL); if (virCommandRunRegex(cmd, 1, @@ -469,11 +472,13 @@ virStorageBackendLogicalRefreshPoolFunc(char **const = groups, void *data) { virStoragePoolObjPtr pool =3D data; - if (virStrToLong_ull(groups[0], NULL, 10, &pool->def->capacity) < 0) + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + + if (virStrToLong_ull(groups[0], NULL, 10, &def->capacity) < 0) return -1; - if (virStrToLong_ull(groups[1], NULL, 10, &pool->def->available) < 0) + if (virStrToLong_ull(groups[1], NULL, 10, &def->available) < 0) return -1; - pool->def->allocation =3D pool->def->capacity - pool->def->available; + def->allocation =3D def->capacity - def->available; =20 return 0; } @@ -631,6 +636,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr c= onn ATTRIBUTE_UNUSED, static bool virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStoragePoolSourceList sourceList; virStoragePoolSource *thisSource =3D NULL; size_t i, j; @@ -646,14 +652,14 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoo= lObjPtr pool) /* Search the pvs output for this pool's source.name */ for (i =3D 0; i < sourceList.nsources; i++) { thisSource =3D &sourceList.sources[i]; - if (STREQ(thisSource->name, pool->def->source.name)) + if (STREQ(thisSource->name, def->source.name)) break; } =20 if (i =3D=3D sourceList.nsources) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot find logical volume group name '%s'"), - pool->def->source.name); + def->source.name); goto cleanup; } =20 @@ -661,7 +667,7 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolO= bjPtr pool) * they match as well; otherwise, matching can only occur on the * pool's name. */ - if (!pool->def->source.ndevice) { + if (!def->source.ndevice) { ret =3D true; goto cleanup; } @@ -669,9 +675,9 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolO= bjPtr pool) /* Let's make sure the pool's device(s) match what the pvs output has * for volume group devices. */ - for (i =3D 0; i < pool->def->source.ndevice; i++) { + for (i =3D 0; i < def->source.ndevice; i++) { for (j =3D 0; j < thisSource->ndevice; j++) { - if (STREQ(pool->def->source.devices[i].path, + if (STREQ(def->source.devices[i].path, thisSource->devices[j].path)) matchcount++; } @@ -683,7 +689,7 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolO= bjPtr pool) if (matchcount =3D=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot find any matching source devices for logi= cal " - "volume group '%s'"), pool->def->source.name); + "volume group '%s'"), def->source.name); goto cleanup; } =20 @@ -692,7 +698,7 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolO= bjPtr pool) * to 'add' to or 'remove' from the volume group outside of libvirt's * knowledge. Rather than fail on that, provide a warning and move on. */ - if (matchcount !=3D pool->def->source.ndevice) + if (matchcount !=3D def->source.ndevice) VIR_WARN("pool device list count doesn't match pvs device list cou= nt"); =20 ret =3D true; @@ -710,10 +716,12 @@ static int virStorageBackendLogicalCheckPool(virStoragePoolObjPtr pool, bool *isActive) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + /* If we can find the target.path as well as ensure that the * pool's def source */ - *isActive =3D virFileExists(pool->def->target.path) && + *isActive =3D virFileExists(def->target.path) && virStorageBackendLogicalMatchPoolSource(pool); return 0; } @@ -738,6 +746,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn AT= TRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr vgcmd =3D NULL; int ret =3D -1; size_t i =3D 0; @@ -749,10 +758,10 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn = ATTRIBUTE_UNUSED, VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, cleanup); =20 - vgcmd =3D virCommandNewArgList(VGCREATE, pool->def->source.name, NULL); + vgcmd =3D virCommandNewArgList(VGCREATE, def->source.name, NULL); =20 - for (i =3D 0; i < pool->def->source.ndevice; i++) { - const char *path =3D pool->def->source.devices[i].path; + for (i =3D 0; i < def->source.ndevice; i++) { + const char *path =3D def->source.devices[i].path; =20 /* The blkid FS and Part probing code doesn't know "lvm2" (this * pool's only format type), but it does know "LVM2_member", so @@ -782,7 +791,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn AT= TRIBUTE_UNUSED, if (ret < 0) { size_t j; for (j =3D 0; j < i; j++) - virStorageBackendLogicalRemoveDevice(pool->def->source.devices= [j].path); + virStorageBackendLogicalRemoveDevice(def->source.devices[j].pa= th); } return ret; } @@ -806,6 +815,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn = ATTRIBUTE_UNUSED, int vars[] =3D { 2 }; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; int ret =3D -1; =20 @@ -822,7 +832,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn = ATTRIBUTE_UNUSED, "--unbuffered", "--nosuffix", "--options", "vg_size,vg_free", - pool->def->source.name, + def->source.name, NULL); =20 /* Now get basic volgrp metadata */ @@ -865,6 +875,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn A= TTRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; size_t i; int ret =3D -1; @@ -873,14 +884,14 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn= ATTRIBUTE_UNUSED, =20 /* first remove the volume group */ cmd =3D virCommandNewArgList(VGREMOVE, - "-f", pool->def->source.name, + "-f", def->source.name, NULL); if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 /* now remove the pv devices and clear them out */ - for (i =3D 0; i < pool->def->source.ndevice; i++) - virStorageBackendLogicalRemoveDevice(pool->def->source.devices[i].= path); + for (i =3D 0; i < def->source.ndevice; i++) + virStorageBackendLogicalRemoveDevice(def->source.devices[i].path); =20 ret =3D 0; =20 @@ -931,6 +942,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, virStorageVolDefPtr vol) { int fd =3D -1; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; virErrorPtr err; struct stat sb; @@ -947,8 +959,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, =20 VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", - pool->def->target.path, - vol->name) < 0) + def->target.path, vol->name) < 0) return -1; =20 cmd =3D virCommandNewArgList(LVCREATE, @@ -968,7 +979,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, if (vol->target.backingStore) virCommandAddArgList(cmd, "-s", vol->target.backingStore->path, NU= LL); else - virCommandAddArg(cmd, pool->def->source.name); + virCommandAddArg(cmd, def->source.name); =20 if (virCommandRun(cmd, NULL) < 0) goto error; --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505829112823298.47217001203956; Tue, 19 Sep 2017 06:51:52 -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 8A0B24A708; Tue, 19 Sep 2017 13:51:51 +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 3DA5360F89; Tue, 19 Sep 2017 13:51:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4DCCB1806104; Tue, 19 Sep 2017 13:51:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQ306012659 for ; Tue, 19 Sep 2017 09:26:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7614619813; Tue, 19 Sep 2017 13:26:03 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3866F6D77D for ; Tue, 19 Sep 2017 13:26:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8A0B24A708 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: Tue, 19 Sep 2017 09:25:08 -0400 Message-Id: <20170919132518.28151-10-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/19] 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.38]); Tue, 19 Sep 2017 13:51:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In preparation for privatizing the object, use the accessor. Signed-off-by: John Ferlan --- src/storage/storage_backend_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 e72dcda9c..3d9c341a1 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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505829138940564.0533404050793; Tue, 19 Sep 2017 06:52:18 -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 D875C883C1; Tue, 19 Sep 2017 13:52:17 +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 882215D98A; Tue, 19 Sep 2017 13:52:17 +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 6C5EA410B3; Tue, 19 Sep 2017 13:52:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQ308012659 for ; Tue, 19 Sep 2017 09:26:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6186860466; Tue, 19 Sep 2017 13:26:04 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2697050F4E for ; Tue, 19 Sep 2017 13:26:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D875C883C1 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Tue, 19 Sep 2017 09:25:09 -0400 Message-Id: <20170919132518.28151-11-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/19] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 19 Sep 2017 13:52:18 +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 847dbc9e0..f54759983 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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 150582968377281.16520305371955; Tue, 19 Sep 2017 07:01:23 -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 948E7C014161; Tue, 19 Sep 2017 14:01:22 +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 705E660635; Tue, 19 Sep 2017 14:01: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 275703FAD1; Tue, 19 Sep 2017 14:01:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQ30A012659 for ; Tue, 19 Sep 2017 09:26:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id C8DD319813; Tue, 19 Sep 2017 13:26:05 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EAD219811 for ; Tue, 19 Sep 2017 13:26:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 948E7C014161 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: Tue, 19 Sep 2017 09:25:10 -0400 Message-Id: <20170919132518.28151-12-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/19] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 19 Sep 2017 14:01: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_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 05e7bff63..eac771b42 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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505829166739554.4533525994796; Tue, 19 Sep 2017 06:52:46 -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 11E597EAA0; Tue, 19 Sep 2017 13:52:45 +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 94BC65D6A8; Tue, 19 Sep 2017 13:52:44 +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 5457E410B5; Tue, 19 Sep 2017 13:52:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQ7VZ012699 for ; Tue, 19 Sep 2017 09:26:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9020A5C6DE; Tue, 19 Sep 2017 13:26:07 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52ABA197F3 for ; Tue, 19 Sep 2017 13:26:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 11E597EAA0 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: Tue, 19 Sep 2017 09:25:11 -0400 Message-Id: <20170919132518.28151-13-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/19] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 19 Sep 2017 13:52:46 +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_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 14f3e09a8..b0c5096ad 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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 150582859442585.64717690683881; Tue, 19 Sep 2017 06:43:14 -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 E5F707EA94; Tue, 19 Sep 2017 13:43:12 +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 C62406062E; Tue, 19 Sep 2017 13:43:12 +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 89A20180884F; Tue, 19 Sep 2017 13:43:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQ8lV012745 for ; Tue, 19 Sep 2017 09:26:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A63C197F9; Tue, 19 Sep 2017 13:26:08 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id D61116134E for ; Tue, 19 Sep 2017 13:26:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E5F707EA94 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: Tue, 19 Sep 2017 09:25:12 -0400 Message-Id: <20170919132518.28151-14-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/19] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 19 Sep 2017 13:43:13 +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_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 46818ef2c..4bc39c24e 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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505829187789286.355972249605; Tue, 19 Sep 2017 06:53:07 -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 8EEC27C82F; Tue, 19 Sep 2017 13:53:06 +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 6C7095D6AE; Tue, 19 Sep 2017 13:53:06 +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 2B3E11806104; Tue, 19 Sep 2017 13:53:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQ8Cc012783 for ; Tue, 19 Sep 2017 09:26:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 98EA460475; Tue, 19 Sep 2017 13:26:08 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F12261342 for ; Tue, 19 Sep 2017 13:26:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8EEC27C82F Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Tue, 19 Sep 2017 09:25:13 -0400 Message-Id: <20170919132518.28151-15-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/19] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 19 Sep 2017 13:53:07 +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_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 673167785..7f9597cab 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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505828615027891.1461591315189; Tue, 19 Sep 2017 06:43:35 -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 00F6D20B0C; Tue, 19 Sep 2017 13:43:34 +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 D36735D6B7; Tue, 19 Sep 2017 13:43:33 +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 9ABEA1855947; Tue, 19 Sep 2017 13:43:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQAKC012900 for ; Tue, 19 Sep 2017 09:26:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1F3F96017B; Tue, 19 Sep 2017 13:26:10 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id D86B95B806 for ; Tue, 19 Sep 2017 13:26:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 00F6D20B0C 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: Tue, 19 Sep 2017 09:25:14 -0400 Message-Id: <20170919132518.28151-16-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 15/19] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 19 Sep 2017 13:43:34 +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_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 02fd4b643..ee79ad72f 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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505829705820447.8090300106378; Tue, 19 Sep 2017 07:01:45 -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 360AA7EA9B; Tue, 19 Sep 2017 14:01:44 +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 173C91980A; Tue, 19 Sep 2017 14:01:44 +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 D0C7A3FAD5; Tue, 19 Sep 2017 14:01:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQBSV013073 for ; Tue, 19 Sep 2017 09:26:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 662D36017B; Tue, 19 Sep 2017 13:26:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29EAC60475 for ; Tue, 19 Sep 2017 13:26:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 360AA7EA9B 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: Tue, 19 Sep 2017 09:25:15 -0400 Message-Id: <20170919132518.28151-17-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/19] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 19 Sep 2017 14:01:44 +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 fb0613853..2dc26af38 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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505829727109648.4980017953756; Tue, 19 Sep 2017 07:02:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CDBDC806CB; Tue, 19 Sep 2017 14:02:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D6C8679F1; Tue, 19 Sep 2017 14:02:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9B8921806104; Tue, 19 Sep 2017 14:02:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQCJG013081 for ; Tue, 19 Sep 2017 09:26:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F9E1197F5; Tue, 19 Sep 2017 13:26:12 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04F616017B for ; Tue, 19 Sep 2017 13:26:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CDBDC806CB Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Tue, 19 Sep 2017 09:25:16 -0400 Message-Id: <20170919132518.28151-18-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/19] storage: Use virStoragePoolObjGetDef accessor for ZFS backend X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 19 Sep 2017 14:02:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In preparation for privatizing the object, use the accessor. Signed-off-by: John Ferlan --- src/storage/storage_backend_zfs.c | 39 +++++++++++++++++++++++------------= ---- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index c2662815a..198c788ac 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -86,10 +86,11 @@ static int virStorageBackendZFSCheckPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, bool *isActive) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *devpath; =20 if (virAsprintf(&devpath, "/dev/zvol/%s", - pool->def->source.name) < 0) + def->source.name) < 0) return -1; *isActive =3D virFileIsDir(devpath); VIR_FREE(devpath); @@ -109,6 +110,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, char *vol_name; bool is_new_vol =3D false; virStorageVolDefPtr volume =3D NULL; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 if (!(tokens =3D virStringSplitCount(volume_string, "\t", 0, &count))) return -1; @@ -142,7 +144,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, =20 if (volume->target.path =3D=3D NULL) { if (virAsprintf(&volume->target.path, "%s/%s", - pool->def->target.path, volume->name) < 0) + def->target.path, volume->name) < 0) goto cleanup; } =20 @@ -178,6 +180,7 @@ static int virStorageBackendZFSFindVols(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; char *volumes_list =3D NULL; char **lines =3D NULL; @@ -199,7 +202,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool, "list", "-Hp", "-t", "volume", "-r", "-o", "name,volsize,refreservation", - pool->def->source.name, + def->source.name, NULL); virCommandSetOutputBuffer(cmd, &volumes_list); if (virCommandRun(cmd, NULL) < 0) @@ -228,6 +231,7 @@ static int virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool ATTRIBUTE_UNUSED) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; char *zpool_props =3D NULL; char **lines =3D NULL; @@ -247,7 +251,7 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn ATTR= IBUTE_UNUSED, cmd =3D virCommandNewArgList(ZPOOL, "get", "-Hp", "health,size,free,allocated", - pool->def->source.name, + def->source.name, NULL); virCommandSetOutputBuffer(cmd, &zpool_props); if (virCommandRun(cmd, NULL) < 0) @@ -279,11 +283,11 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn AT= TRIBUTE_UNUSED, goto cleanup; =20 if (STREQ(prop_name, "free")) - pool->def->available =3D value; + def->available =3D value; else if (STREQ(prop_name, "size")) - pool->def->capacity =3D value; + def->capacity =3D value; else if (STREQ(prop_name, "allocated")) - pool->def->allocation =3D value; + def->allocation =3D value; } } =20 @@ -305,6 +309,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIB= UTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; int ret =3D -1; int volmode_needed =3D -1; @@ -320,7 +325,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIB= UTE_UNUSED, =20 VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", - pool->def->target.path, vol->name) < 0) + def->target.path, vol->name) < 0) return -1; =20 if (VIR_STRDUP(vol->key, vol->target.path) < 0) @@ -356,8 +361,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIB= UTE_UNUSED, virCommandAddArg(cmd, "-V"); virCommandAddArgFormat(cmd, "%lluK", VIR_DIV_UP(vol->target.capacity, 1024)); - virCommandAddArgFormat(cmd, "%s/%s", - pool->def->source.name, vol->name); + virCommandAddArgFormat(cmd, "%s/%s", def->source.name, vol->name); =20 if (virCommandRun(cmd, NULL) < 0) goto cleanup; @@ -379,6 +383,7 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIB= UTE_UNUSED, unsigned int flags) { int ret =3D -1; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr destroy_cmd =3D NULL; =20 virCheckFlags(0, -1); @@ -386,7 +391,7 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIB= UTE_UNUSED, destroy_cmd =3D virCommandNewArgList(ZFS, "destroy", NULL); =20 virCommandAddArgFormat(destroy_cmd, "%s/%s", - pool->def->source.name, vol->name); + def->source.name, vol->name); =20 if (virCommandRun(destroy_cmd, NULL) < 0) goto cleanup; @@ -402,23 +407,24 @@ virStorageBackendZFSBuildPool(virConnectPtr conn ATTR= IBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; size_t i; int ret =3D -1; =20 virCheckFlags(0, -1); =20 - if (pool->def->source.ndevice =3D=3D 0) { + if (def->source.ndevice =3D=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("missing source devices")); return -1; } =20 cmd =3D virCommandNewArgList(ZPOOL, "create", - pool->def->source.name, NULL); + def->source.name, NULL); =20 - for (i =3D 0; i < pool->def->source.ndevice; i++) - virCommandAddArg(cmd, pool->def->source.devices[i].path); + for (i =3D 0; i < def->source.ndevice; i++) + virCommandAddArg(cmd, def->source.devices[i].path); =20 if (virCommandRun(cmd, NULL) < 0) goto cleanup; @@ -435,13 +441,14 @@ virStorageBackendZFSDeletePool(virConnectPtr conn ATT= RIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; int ret =3D -1; =20 virCheckFlags(0, -1); =20 cmd =3D virCommandNewArgList(ZPOOL, "destroy", - pool->def->source.name, NULL); + def->source.name, NULL); =20 if (virCommandRun(cmd, NULL) < 0) goto cleanup; --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505828635067112.75972718952517; Tue, 19 Sep 2017 06:43:55 -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 C0886A24E8; Tue, 19 Sep 2017 13:43:53 +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 978FF19813; Tue, 19 Sep 2017 13:43: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 62476410B4; Tue, 19 Sep 2017 13:43:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQDSa013101 for ; Tue, 19 Sep 2017 09:26:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9B162197F3; Tue, 19 Sep 2017 13:26:13 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AAB461342 for ; Tue, 19 Sep 2017 13:26:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C0886A24E8 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Tue, 19 Sep 2017 09:25:17 -0400 Message-Id: <20170919132518.28151-19-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 18/19] 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.39]); Tue, 19 Sep 2017 13:43:54 +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 --- 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 8ac6796a6..b349783d2 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 ff04c9efe..50dbd7bf4 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 cf7ee06cd..69e737226 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.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 15:45:15 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 1505828652679195.65577125137509; Tue, 19 Sep 2017 06:44:12 -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 A4ED61F56A; Tue, 19 Sep 2017 13:44:11 +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 80C2460F89; Tue, 19 Sep 2017 13:44:11 +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 4347F1855944; Tue, 19 Sep 2017 13:44:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JDQFFn013121 for ; Tue, 19 Sep 2017 09:26:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4FBBE197F5; Tue, 19 Sep 2017 13:26:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FBE061342 for ; Tue, 19 Sep 2017 13:26:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A4ED61F56A 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: Tue, 19 Sep 2017 09:25:18 -0400 Message-Id: <20170919132518.28151-20-jferlan@redhat.com> In-Reply-To: <20170919132518.28151-1-jferlan@redhat.com> References: <20170919132518.28151-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 19/19] storage: Change storage_util to use obj instead of pool 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.30]); Tue, 19 Sep 2017 13:44:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For consistency sake - use @obj as the variable name. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 106 ++++++++++++++++++++++-------------------= ---- src/storage/storage_util.h | 30 ++++++------- 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index adcec36cc..020df6387 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -223,7 +223,7 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, =20 static int storageBackendCreateBlockFrom(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, + virStoragePoolObjPtr obj ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -391,12 +391,12 @@ createRawFile(int fd, virStorageVolDefPtr vol, =20 static int storageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); int ret =3D -1; int fd =3D -1; int operation_flags; @@ -594,11 +594,11 @@ virStorageGenerateQcowEncryption(virConnectPtr conn, } =20 static int -virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, +virStorageBackendCreateExecCommand(virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virCommandPtr cmd) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); struct stat st; gid_t gid; uid_t uid; @@ -696,7 +696,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr= pool, * if function fails to create image file the directory will be deleted.*/ static int storageBackendCreatePloop(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, + virStoragePoolObjPtr obj ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -1026,12 +1026,12 @@ storageBackendCreateQemuImgSetInput(virStorageVolDe= fPtr inputvol, =20 =20 static int -storageBackendCreateQemuImgSetBacking(virStoragePoolObjPtr pool, +storageBackendCreateQemuImgSetBacking(virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, struct _virStorageBackendQemuImgInfo= *info) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); int accessRetCode =3D -1; char *absolutePath =3D NULL; =20 @@ -1151,7 +1151,7 @@ storageBackendCreateQemuImgSecretObject(virCommandPtr= cmd, */ virCommandPtr virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags, @@ -1231,7 +1231,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPt= r conn, return NULL; =20 if (vol->target.backingStore && - storageBackendCreateQemuImgSetBacking(pool, vol, inputvol, &info) = < 0) + storageBackendCreateQemuImgSetBacking(obj, vol, inputvol, &info) <= 0) return NULL; =20 if (info.encryption && @@ -1288,7 +1288,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPt= r conn, =20 static char * storageBackendCreateQemuImgSecretPath(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol) { virStorageEncryptionPtr enc =3D vol->target.encryption; @@ -1312,7 +1312,7 @@ storageBackendCreateQemuImgSecretPath(virConnectPtr c= onn, return NULL; } =20 - if (!(secretPath =3D virStoragePoolObjBuildTempFilePath(pool, vol))) + if (!(secretPath =3D virStoragePoolObjBuildTempFilePath(obj, vol))) goto cleanup; =20 if ((fd =3D mkostemp(secretPath, O_CLOEXEC)) < 0) { @@ -1358,7 +1358,7 @@ storageBackendCreateQemuImgSecretPath(virConnectPtr c= onn, =20 static int storageBackendCreateQemuImg(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -1387,17 +1387,17 @@ storageBackendCreateQemuImg(virConnectPtr conn, vol->target.encryption && vol->target.encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMA= T_LUKS) { if (!(secretPath =3D - storageBackendCreateQemuImgSecretPath(conn, pool, vol))) + storageBackendCreateQemuImgSecretPath(conn, obj, vol))) goto cleanup; } =20 - cmd =3D virStorageBackendCreateQemuImgCmdFromVol(conn, pool, vol, inpu= tvol, + cmd =3D virStorageBackendCreateQemuImgCmdFromVol(conn, obj, vol, input= vol, flags, create_tool, imgformat, secretPath); if (!cmd) goto cleanup; =20 - ret =3D virStorageBackendCreateExecCommand(pool, vol, cmd); + ret =3D virStorageBackendCreateExecCommand(obj, vol, cmd); =20 virCommandFree(cmd); cleanup: @@ -1939,11 +1939,11 @@ virStorageBackendPoolPathIsStable(const char *path) * a change to appear. */ char * -virStorageBackendStablePath(virStoragePoolObjPtr pool, +virStorageBackendStablePath(virStoragePoolObjPtr obj, const char *devpath, bool loop) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); DIR *dh; struct dirent *dent; char *stablepath; @@ -2018,12 +2018,12 @@ virStorageBackendStablePath(virStoragePoolObjPtr po= ol, /* Common/Local File System/Directory Volume API's */ static int createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); int err; =20 virCheckFlags(0, -1); @@ -2065,10 +2065,10 @@ createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED, */ int virStorageBackendVolCreateLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); =20 if (vol->target.format =3D=3D VIR_STORAGE_FILE_DIR) vol->type =3D VIR_STORAGE_VOL_DIR; @@ -2104,7 +2104,7 @@ virStorageBackendVolCreateLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, =20 static int storageBackendVolBuildLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -2133,7 +2133,7 @@ storageBackendVolBuildLocal(virConnectPtr conn, create_func =3D storageBackendCreateQemuImg; } =20 - if (create_func(conn, pool, vol, inputvol, flags) < 0) + if (create_func(conn, obj, vol, inputvol, flags) < 0) return -1; return 0; } @@ -2146,11 +2146,11 @@ storageBackendVolBuildLocal(virConnectPtr conn, */ int virStorageBackendVolBuildLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, unsigned int flags) { - return storageBackendVolBuildLocal(conn, pool, vol, NULL, flags); + return storageBackendVolBuildLocal(conn, obj, vol, NULL, flags); } =20 =20 @@ -2159,12 +2159,12 @@ virStorageBackendVolBuildLocal(virConnectPtr conn, */ int virStorageBackendVolBuildFromLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) { - return storageBackendVolBuildLocal(conn, pool, vol, inputvol, flags); + return storageBackendVolBuildLocal(conn, obj, vol, inputvol, flags); } =20 =20 @@ -2173,7 +2173,7 @@ virStorageBackendVolBuildFromLocal(virConnectPtr conn, */ int virStorageBackendVolDeleteLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, + virStoragePoolObjPtr obj ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, unsigned int flags) { @@ -2270,7 +2270,7 @@ storageBackendLoadDefaultSecrets(virConnectPtr conn, */ int virStorageBackendVolRefreshLocal(virConnectPtr conn, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSE= D, + virStoragePoolObjPtr obj ATTRIBUTE_UNUSED, virStorageVolDefPtr vol) { int ret; @@ -2323,7 +2323,7 @@ storageBackendResizeQemuImg(const char *path, */ int virStorageBackendVolResizeLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, + virStoragePoolObjPtr obj ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, unsigned long long capacity, unsigned int flags) @@ -2395,7 +2395,7 @@ storageBackendPloopHasSnapshots(char *path) =20 int virStorageBackendVolUploadLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, + virStoragePoolObjPtr obj ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, virStreamPtr stream, unsigned long long offset, @@ -2442,7 +2442,7 @@ virStorageBackendVolUploadLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, =20 int virStorageBackendVolDownloadLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUS= ED, + virStoragePoolObjPtr obj ATTRIBUTE_UNUSE= D, virStorageVolDefPtr vol, virStreamPtr stream, unsigned long long offset, @@ -2740,7 +2740,7 @@ storageBackendVolWipePloop(virStorageVolDefPtr vol, =20 int virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, + virStoragePoolObjPtr obj ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, unsigned int algorithm, unsigned int flags) @@ -2764,7 +2764,7 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, =20 =20 /** - * @pool: storage pool to build + * @obj: storage pool to build * @dir_create_flags: flags for directory creation * * Common code to build a directory based storage pool @@ -2772,9 +2772,9 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, * Returns 0 on success, -1 on failure */ int -virStorageBackendBuildLocal(virStoragePoolObjPtr pool) +virStorageBackendBuildLocal(virStoragePoolObjPtr obj) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); int ret =3D -1; char *parent =3D NULL; char *p =3D NULL; @@ -2832,7 +2832,7 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool) =20 /** * @conn connection to report errors against - * @pool storage pool to delete + * @obj storage pool to delete * * Delete a directory based storage pool * @@ -2840,10 +2840,10 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr po= ol) */ int virStorageBackendDeleteLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, unsigned int flags) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); =20 virCheckFlags(0, -1); =20 @@ -3582,9 +3582,9 @@ virStorageBackendRefreshVolTargetUpdate(virStorageVol= DefPtr vol) */ int virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) + virStoragePoolObjPtr obj) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); DIR *dir; struct dirent *ent; struct statvfs sb; @@ -3631,7 +3631,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, goto cleanup; } =20 - if (virStoragePoolObjAddVol(pool, vol) < 0) + if (virStoragePoolObjAddVol(obj, vol) < 0) goto cleanup; vol =3D NULL; } @@ -3687,7 +3687,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, virStorageVolDefFree(vol); virStorageSourceFree(target); if (ret < 0) - virStoragePoolObjClearVols(pool); + virStoragePoolObjClearVols(obj); return ret; } =20 @@ -3740,14 +3740,14 @@ virStorageBackendSCSISerial(const char *dev) * -2 =3D> Failure to find a stable path, not fatal, caller can try anoth= er */ static int -virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, +virStorageBackendSCSINewLun(virStoragePoolObjPtr obj, uint32_t host ATTRIBUTE_UNUSED, uint32_t bus, uint32_t target, uint32_t lun, const char *dev) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); virStorageVolDefPtr vol =3D NULL; char *devpath =3D NULL; int retval =3D -1; @@ -3792,7 +3792,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, * dir every time its run. Should figure out a more efficient * way of doing this... */ - if ((vol->target.path =3D virStorageBackendStablePath(pool, + if ((vol->target.path =3D virStorageBackendStablePath(obj, devpath, true)) =3D=3D NULL) goto cleanup; @@ -3820,7 +3820,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, def->capacity +=3D vol->target.capacity; def->allocation +=3D vol->target.allocation; =20 - if (virStoragePoolObjAddVol(pool, vol) < 0) + if (virStoragePoolObjAddVol(obj, vol) < 0) goto cleanup; vol =3D NULL; =20 @@ -4039,7 +4039,7 @@ getDeviceType(uint32_t host, * -2 =3D> non-fatal error or a non-disk entry */ static int -processLU(virStoragePoolObjPtr pool, +processLU(virStoragePoolObjPtr obj, uint32_t host, uint32_t bus, uint32_t target, @@ -4074,7 +4074,7 @@ processLU(virStoragePoolObjPtr pool, return retval; } =20 - retval =3D virStorageBackendSCSINewLun(pool, host, bus, target, lun, + retval =3D virStorageBackendSCSINewLun(obj, host, bus, target, lun, block_device); if (retval < 0) { VIR_DEBUG("Failed to create new storage volume for %u:%u:%u:%u", @@ -4092,10 +4092,10 @@ processLU(virStoragePoolObjPtr pool, =20 =20 int -virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, +virStorageBackendSCSIFindLUs(virStoragePoolObjPtr obj, uint32_t scanhost) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); int retval =3D 0; uint32_t bus, target, lun; const char *device_path =3D "/sys/bus/scsi/devices"; @@ -4123,7 +4123,7 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr poo= l, =20 VIR_DEBUG("Found possible LU '%s'", lun_dirent->d_name); =20 - rc =3D processLU(pool, scanhost, bus, target, lun); + rc =3D processLU(obj, scanhost, bus, target, lun); if (rc =3D=3D -1) { retval =3D -1; break; diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index 00793ff3a..d8001ad25 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -32,37 +32,37 @@ virStorageBackendGetBuildVolFromFunction(virStorageVolD= efPtr vol, virStorageVolDefPtr inputvol); =20 int virStorageBackendVolCreateLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol); =20 int virStorageBackendVolBuildLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, unsigned int flags); =20 int virStorageBackendVolBuildFromLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags); =20 int virStorageBackendVolDeleteLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, unsigned int flags); =20 int virStorageBackendVolRefreshLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol); =20 int virStorageBackendVolResizeLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, unsigned long long capacity, unsigned int flags); =20 int virStorageBackendVolUploadLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStreamPtr stream, unsigned long long offset, @@ -70,7 +70,7 @@ int virStorageBackendVolUploadLocal(virConnectPtr conn, unsigned int flags); =20 int virStorageBackendVolDownloadLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStreamPtr stream, unsigned long long offset, @@ -78,23 +78,23 @@ int virStorageBackendVolDownloadLocal(virConnectPtr con= n, unsigned int flags); =20 int virStorageBackendVolWipeLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, unsigned int algorithm, unsigned int flags); =20 /* Local/Common Storage Pool Backend APIs */ -int virStorageBackendBuildLocal(virStoragePoolObjPtr pool); +int virStorageBackendBuildLocal(virStoragePoolObjPtr obj); =20 int virStorageBackendDeleteLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, unsigned int flags); =20 int virStorageBackendRefreshVolTargetUpdate(virStorageVolDefPtr vol); =20 int virStorageBackendRefreshLocal(virConnectPtr conn, - virStoragePoolObjPtr pool); + virStoragePoolObjPtr obj); =20 int virStorageUtilGlusterExtractPoolSources(const char *host, const char *xml, @@ -153,13 +153,13 @@ int virStorageBackendUpdateVolTargetInfoFD(virStorage= SourcePtr target, struct stat *sb); =20 bool virStorageBackendPoolPathIsStable(const char *path); -char *virStorageBackendStablePath(virStoragePoolObjPtr pool, +char *virStorageBackendStablePath(virStoragePoolObjPtr obj, const char *devpath, bool loop); =20 virCommandPtr virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags, @@ -167,7 +167,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr = conn, int imgformat, const char *secretPath); =20 -int virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, +int virStorageBackendSCSIFindLUs(virStoragePoolObjPtr obj, uint32_t scanhost); =20 int --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list