From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343837715605.7265496426805; Tue, 9 May 2017 08:30:37 -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 08E407F7DF; Tue, 9 May 2017 15:30:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C9F377EFC; Tue, 9 May 2017 15:30:35 +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 162D05EC63; Tue, 9 May 2017 15:30:34 +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 v49FUVT6002837 for ; Tue, 9 May 2017 11:30:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6534619651; Tue, 9 May 2017 15:30:31 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 265078AC44 for ; Tue, 9 May 2017 15:30:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 08E407F7DF 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 08E407F7DF From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:08 -0400 Message-Id: <20170509153026.19767-2-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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] test: Fix up formatting in storage test API's X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 09 May 2017 15:30:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fix some spacing/formatting in the storage pool/vol test driver code. Signed-off-by: John Ferlan --- src/test/test_driver.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2db3f7d..548f318 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1035,6 +1035,7 @@ testParseInterfaces(testDriverPtr privconn, return ret; } =20 + static int testOpenVolumesForPool(const char *file, xmlXPathContextPtr ctxt, @@ -1091,6 +1092,7 @@ testOpenVolumesForPool(const char *file, return ret; } =20 + static int testParseStorage(testDriverPtr privconn, const char *file, @@ -1143,6 +1145,7 @@ testParseStorage(testDriverPtr privconn, return ret; } =20 + static int testParseNodedevs(testDriverPtr privconn, const char *file, @@ -3996,8 +3999,8 @@ testInterfaceDestroy(virInterfacePtr iface, * Storage Driver routines */ =20 - -static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool) +static int +testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool) { =20 pool->def->capacity =3D defaultPoolCap; @@ -4069,6 +4072,7 @@ testStoragePoolLookupByUUID(virConnectPtr conn, return ret; } =20 + static virStoragePoolPtr testStoragePoolLookupByName(virConnectPtr conn, const char *name) @@ -4089,6 +4093,7 @@ testStoragePoolLookupByName(virConnectPtr conn, return ret; } =20 + static virStoragePoolPtr testStoragePoolLookupByVolume(virStorageVolPtr vol) { @@ -4159,6 +4164,7 @@ testConnectListDefinedStoragePools(virConnectPtr conn, return n; } =20 + static int testConnectListAllStoragePools(virConnectPtr conn, virStoragePoolPtr **pools, @@ -4177,7 +4183,9 @@ testConnectListAllStoragePools(virConnectPtr conn, return ret; } =20 -static int testStoragePoolIsActive(virStoragePoolPtr pool) + +static int +testStoragePoolIsActive(virStoragePoolPtr pool) { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; @@ -4194,7 +4202,9 @@ static int testStoragePoolIsActive(virStoragePoolPtr = pool) return ret; } =20 -static int testStoragePoolIsPersistent(virStoragePoolPtr pool) + +static int +testStoragePoolIsPersistent(virStoragePoolPtr pool) { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; @@ -4212,7 +4222,6 @@ static int testStoragePoolIsPersistent(virStoragePool= Ptr pool) } =20 =20 - static int testStoragePoolCreate(virStoragePoolPtr pool, unsigned int flags) @@ -4247,6 +4256,7 @@ testStoragePoolCreate(virStoragePoolPtr pool, return ret; } =20 + static char * testConnectFindStoragePoolSources(virConnectPtr conn ATTRIBUTE_UNUSED, const char *type, @@ -4401,6 +4411,7 @@ testStoragePoolCreateXML(virConnectPtr conn, return ret; } =20 + static virStoragePoolPtr testStoragePoolDefineXML(virConnectPtr conn, const char *xml, @@ -4448,6 +4459,7 @@ testStoragePoolDefineXML(virConnectPtr conn, return ret; } =20 + static int testStoragePoolUndefine(virStoragePoolPtr pool) { @@ -4480,6 +4492,7 @@ testStoragePoolUndefine(virStoragePoolPtr pool) return ret; } =20 + static int testStoragePoolBuild(virStoragePoolPtr pool, unsigned int flags) @@ -4677,6 +4690,7 @@ testStoragePoolGetInfo(virStoragePoolPtr pool, return ret; } =20 + static char * testStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) @@ -4698,6 +4712,7 @@ testStoragePoolGetXMLDesc(virStoragePoolPtr pool, return ret; } =20 + static int testStoragePoolGetAutostart(virStoragePoolPtr pool, int *autostart) @@ -4722,6 +4737,7 @@ testStoragePoolGetAutostart(virStoragePoolPtr pool, return ret; } =20 + static int testStoragePoolSetAutostart(virStoragePoolPtr pool, int autostart) @@ -4832,6 +4848,7 @@ testStoragePoolListAllVolumes(virStoragePoolPtr obj, return ret; } =20 + static virStorageVolPtr testStorageVolLookupByName(virStoragePoolPtr pool, const char *name ATTRIBUTE_UNUSED) @@ -4905,6 +4922,7 @@ testStorageVolLookupByKey(virConnectPtr conn, return ret; } =20 + static virStorageVolPtr testStorageVolLookupByPath(virConnectPtr conn, const char *path) @@ -4941,6 +4959,7 @@ testStorageVolLookupByPath(virConnectPtr conn, return ret; } =20 + static virStorageVolPtr testStorageVolCreateXML(virStoragePoolPtr pool, const char *xmldesc, @@ -5007,6 +5026,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool, return ret; } =20 + static virStorageVolPtr testStorageVolCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc, @@ -5084,6 +5104,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, return ret; } =20 + static int testStorageVolDelete(virStorageVolPtr vol, unsigned int flags) @@ -5136,7 +5157,8 @@ testStorageVolDelete(virStorageVolPtr vol, } =20 =20 -static int testStorageVolumeTypeForPool(int pooltype) +static int +testStorageVolumeTypeForPool(int pooltype) { =20 switch (pooltype) { @@ -5149,6 +5171,7 @@ static int testStorageVolumeTypeForPool(int pooltype) } } =20 + static int testStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info) @@ -5188,6 +5211,7 @@ testStorageVolGetInfo(virStorageVolPtr vol, return ret; } =20 + static char * testStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) @@ -5225,6 +5249,7 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, return ret; } =20 + static char * testStorageVolGetPath(virStorageVolPtr vol) { --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343838501446.53692924844063; Tue, 9 May 2017 08:30:38 -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 70FE8770F; Tue, 9 May 2017 15:30:36 +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 4568F87FBA; Tue, 9 May 2017 15:30:36 +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 D81E81800C83; Tue, 9 May 2017 15:30:35 +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 v49FUXP6002843 for ; Tue, 9 May 2017 11:30:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id A00518AC43; Tue, 9 May 2017 15:30:33 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DDCA19651 for ; Tue, 9 May 2017 15:30:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 70FE8770F 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 70FE8770F From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:09 -0400 Message-Id: <20170509153026.19767-3-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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] test: Use consistent variable names for storage test driver 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.38]); Tue, 09 May 2017 15:30:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A virStoragePoolObjPtr will be an 'obj'. A virStoragePoolPtr will be a 'pool'. Signed-off-by: John Ferlan --- src/test/test_driver.c | 443 ++++++++++++++++++++++++---------------------= ---- 1 file changed, 219 insertions(+), 224 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 548f318..c0e46af 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -565,7 +565,7 @@ static const char *defaultPoolSourcesNetFSXML =3D static const unsigned long long defaultPoolCap =3D (100 * 1024 * 1024 * 10= 24ull); static const unsigned long long defaultPoolAlloc; =20 -static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool); +static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj); static int testNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info); =20 static virDomainObjPtr @@ -1039,8 +1039,8 @@ testParseInterfaces(testDriverPtr privconn, static int testOpenVolumesForPool(const char *file, xmlXPathContextPtr ctxt, - virStoragePoolObjPtr pool, - int poolidx) + virStoragePoolObjPtr obj, + int objidx) { char *vol_xpath; size_t i; @@ -1049,7 +1049,7 @@ testOpenVolumesForPool(const char *file, virStorageVolDefPtr def =3D NULL; =20 /* Find storage volumes */ - if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", poolidx) < 0) + if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0) goto error; =20 num =3D virXPathNodeSet(vol_xpath, ctxt, &nodes); @@ -1063,25 +1063,24 @@ testOpenVolumesForPool(const char *file, if (!node) goto error; =20 - def =3D virStorageVolDefParseNode(pool->def, ctxt->doc, node, 0); + def =3D virStorageVolDefParseNode(obj->def, ctxt->doc, node, 0); if (!def) goto error; =20 if (def->target.path =3D=3D NULL) { if (virAsprintf(&def->target.path, "%s/%s", - pool->def->target.path, + obj->def->target.path, def->name) =3D=3D -1) goto error; } =20 if (!def->key && VIR_STRDUP(def->key, def->target.path) < 0) goto error; - if (VIR_APPEND_ELEMENT_COPY(pool->volumes.objs, pool->volumes.coun= t, def) < 0) + if (VIR_APPEND_ELEMENT_COPY(obj->volumes.objs, obj->volumes.count,= def) < 0) goto error; =20 - pool->def->allocation +=3D def->target.allocation; - pool->def->available =3D (pool->def->capacity - - pool->def->allocation); + obj->def->allocation +=3D def->target.allocation; + obj->def->available =3D (obj->def->capacity - obj->def->allocation= ); def =3D NULL; } =20 @@ -4000,14 +3999,14 @@ testInterfaceDestroy(virInterfacePtr iface, */ =20 static int -testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool) +testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj) { =20 - pool->def->capacity =3D defaultPoolCap; - pool->def->allocation =3D defaultPoolAlloc; - pool->def->available =3D defaultPoolCap - defaultPoolAlloc; + obj->def->capacity =3D defaultPoolCap; + obj->def->allocation =3D defaultPoolAlloc; + obj->def->available =3D defaultPoolCap - defaultPoolAlloc; =20 - return VIR_STRDUP(pool->configFile, ""); + return VIR_STRDUP(obj->configFile, ""); } =20 =20 @@ -4015,18 +4014,18 @@ static virStoragePoolObjPtr testStoragePoolObjFindByName(testDriverPtr privconn, const char *name) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; =20 testDriverLock(privconn); - pool =3D virStoragePoolObjFindByName(&privconn->pools, name); + obj =3D virStoragePoolObjFindByName(&privconn->pools, name); testDriverUnlock(privconn); =20 - if (!pool) + if (!obj) virReportError(VIR_ERR_NO_STORAGE_POOL, _("no storage pool with matching name '%s'"), name); =20 - return pool; + return obj; } =20 =20 @@ -4034,21 +4033,21 @@ static virStoragePoolObjPtr testStoragePoolObjFindByUUID(testDriverPtr privconn, const unsigned char *uuid) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 testDriverLock(privconn); - pool =3D virStoragePoolObjFindByUUID(&privconn->pools, uuid); + obj =3D virStoragePoolObjFindByUUID(&privconn->pools, uuid); testDriverUnlock(privconn); =20 - if (!pool) { + if (!obj) { virUUIDFormat(uuid, uuidstr); virReportError(VIR_ERR_NO_STORAGE_POOL, _("no storage pool with matching uuid '%s'"), uuidstr); } =20 - return pool; + return obj; } =20 =20 @@ -4057,18 +4056,18 @@ testStoragePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { testDriverPtr privconn =3D conn->privateData; - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStoragePoolPtr ret =3D NULL; =20 - if (!(pool =3D testStoragePoolObjFindByUUID(privconn, uuid))) + if (!(obj =3D testStoragePoolObjFindByUUID(privconn, uuid))) goto cleanup; =20 - ret =3D virGetStoragePool(conn, pool->def->name, pool->def->uuid, + ret =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL); =20 cleanup: - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4078,18 +4077,18 @@ testStoragePoolLookupByName(virConnectPtr conn, const char *name) { testDriverPtr privconn =3D conn->privateData; - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStoragePoolPtr ret =3D NULL; =20 - if (!(pool =3D testStoragePoolObjFindByName(privconn, name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, name))) goto cleanup; =20 - ret =3D virGetStoragePool(conn, pool->def->name, pool->def->uuid, + ret =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL); =20 cleanup: - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4227,22 +4226,22 @@ testStoragePoolCreate(virStoragePoolPtr pool, unsigned int flags) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int ret =3D -1; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, -1); =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (virStoragePoolObjIsActive(privpool)) { + if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is already active"), pool->nam= e); goto cleanup; } =20 - privpool->active =3D 1; + obj->active =3D 1; =20 event =3D virStoragePoolEventLifecycleNew(pool->name, pool->uuid, VIR_STORAGE_POOL_EVENT_STARTED, @@ -4251,8 +4250,8 @@ testStoragePoolCreate(virStoragePoolPtr pool, =20 cleanup: testObjectEventQueue(privconn, event); - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4345,7 +4344,7 @@ testStoragePoolCreateXML(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolDefPtr def; - virStoragePoolObjPtr pool =3D NULL; + virStoragePoolObjPtr obj =3D NULL; virStoragePoolPtr ret =3D NULL; virObjectEventPtr event =3D NULL; =20 @@ -4355,58 +4354,58 @@ testStoragePoolCreateXML(virConnectPtr conn, if (!(def =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - pool =3D virStoragePoolObjFindByUUID(&privconn->pools, def->uuid); - if (!pool) - pool =3D virStoragePoolObjFindByName(&privconn->pools, def->name); - if (pool) { + obj =3D virStoragePoolObjFindByUUID(&privconn->pools, def->uuid); + if (!obj) + obj =3D virStoragePoolObjFindByName(&privconn->pools, def->name); + if (obj) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("storage pool already exists")); goto cleanup; } =20 - if (!(pool =3D virStoragePoolObjAssignDef(&privconn->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, def))) goto cleanup; def =3D NULL; =20 - if (pool->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_= HOST) { + if (obj->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_H= OST) { /* 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, - pool->def->source.adapter.data.fchost.wwnn, - pool->def->source.adapter.data.fchost.wwpn) < = 0) { - virStoragePoolObjRemove(&privconn->pools, pool); - pool =3D NULL; + obj->def->source.adapter.data.fchost.wwnn, + obj->def->source.adapter.data.fchost.wwpn) < 0= ) { + virStoragePoolObjRemove(&privconn->pools, obj); + obj =3D NULL; goto cleanup; } } =20 - if (testStoragePoolObjSetDefaults(pool) =3D=3D -1) { - virStoragePoolObjRemove(&privconn->pools, pool); - pool =3D NULL; + if (testStoragePoolObjSetDefaults(obj) =3D=3D -1) { + virStoragePoolObjRemove(&privconn->pools, obj); + obj =3D NULL; goto cleanup; } =20 /* *SetDefaults fills this in for the persistent pools, but this * would be a transient pool so remove it; otherwise, the Destroy * code will not Remove the pool */ - VIR_FREE(pool->configFile); + VIR_FREE(obj->configFile); =20 - pool->active =3D 1; + obj->active =3D 1; =20 - event =3D virStoragePoolEventLifecycleNew(pool->def->name, pool->def->= uuid, + event =3D virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uu= id, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 - ret =3D virGetStoragePool(conn, pool->def->name, pool->def->uuid, + ret =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL); =20 cleanup: virStoragePoolDefFree(def); testObjectEventQueue(privconn, event); - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); testDriverUnlock(privconn); return ret; } @@ -4419,7 +4418,7 @@ testStoragePoolDefineXML(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolDefPtr def; - virStoragePoolObjPtr pool =3D NULL; + virStoragePoolObjPtr obj =3D NULL; virStoragePoolPtr ret =3D NULL; virObjectEventPtr event =3D NULL; =20 @@ -4433,28 +4432,28 @@ testStoragePoolDefineXML(virConnectPtr conn, def->allocation =3D defaultPoolAlloc; def->available =3D defaultPoolCap - defaultPoolAlloc; =20 - if (!(pool =3D virStoragePoolObjAssignDef(&privconn->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, def))) goto cleanup; def =3D NULL; =20 - event =3D virStoragePoolEventLifecycleNew(pool->def->name, pool->def->= uuid, + event =3D virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uu= id, VIR_STORAGE_POOL_EVENT_DEFINED, 0); =20 - if (testStoragePoolObjSetDefaults(pool) =3D=3D -1) { - virStoragePoolObjRemove(&privconn->pools, pool); - pool =3D NULL; + if (testStoragePoolObjSetDefaults(obj) =3D=3D -1) { + virStoragePoolObjRemove(&privconn->pools, obj); + obj =3D NULL; goto cleanup; } =20 - ret =3D virGetStoragePool(conn, pool->def->name, pool->def->uuid, + ret =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL); =20 cleanup: virStoragePoolDefFree(def); testObjectEventQueue(privconn, event); - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); testDriverUnlock(privconn); return ret; } @@ -4464,14 +4463,14 @@ static int testStoragePoolUndefine(virStoragePoolPtr pool) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int ret =3D -1; virObjectEventPtr event =3D NULL; =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (virStoragePoolObjIsActive(privpool)) { + if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is already active"), pool->nam= e); goto cleanup; @@ -4481,13 +4480,13 @@ testStoragePoolUndefine(virStoragePoolPtr pool) VIR_STORAGE_POOL_EVENT_UNDEFIN= ED, 0); =20 - virStoragePoolObjRemove(&privconn->pools, privpool); - privpool =3D NULL; + virStoragePoolObjRemove(&privconn->pools, obj); + obj =3D NULL; ret =3D 0; =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); testObjectEventQueue(privconn, event); return ret; } @@ -4498,15 +4497,15 @@ testStoragePoolBuild(virStoragePoolPtr pool, unsigned int flags) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int ret =3D -1; =20 virCheckFlags(0, -1); =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (virStoragePoolObjIsActive(privpool)) { + if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is already active"), pool->nam= e); goto cleanup; @@ -4514,8 +4513,8 @@ testStoragePoolBuild(virStoragePoolPtr pool, ret =3D 0; =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4562,44 +4561,44 @@ static int testStoragePoolDestroy(virStoragePoolPtr pool) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int ret =3D -1; virObjectEventPtr event =3D NULL; =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), pool->name); goto cleanup; } =20 - privpool->active =3D 0; + obj->active =3D 0; =20 - if (privpool->def->source.adapter.type =3D=3D + if (obj->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { if (testDestroyVport(privconn, - privpool->def->source.adapter.data.fchost.wwn= n, - privpool->def->source.adapter.data.fchost.wwp= n) < 0) + obj->def->source.adapter.data.fchost.wwnn, + obj->def->source.adapter.data.fchost.wwpn) < = 0) goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(privpool->def->name, - privpool->def->uuid, + event =3D virStoragePoolEventLifecycleNew(obj->def->name, + obj->def->uuid, VIR_STORAGE_POOL_EVENT_STOPPED, 0); =20 - if (privpool->configFile =3D=3D NULL) { - virStoragePoolObjRemove(&privconn->pools, privpool); - privpool =3D NULL; + if (obj->configFile =3D=3D NULL) { + virStoragePoolObjRemove(&privconn->pools, obj); + obj =3D NULL; } ret =3D 0; =20 cleanup: testObjectEventQueue(privconn, event); - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4609,15 +4608,15 @@ testStoragePoolDelete(virStoragePoolPtr pool, unsigned int flags) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int ret =3D -1; =20 virCheckFlags(0, -1); =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (virStoragePoolObjIsActive(privpool)) { + if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is already active"), pool->nam= e); goto cleanup; @@ -4626,8 +4625,8 @@ testStoragePoolDelete(virStoragePoolPtr pool, ret =3D 0; =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4637,16 +4636,16 @@ testStoragePoolRefresh(virStoragePoolPtr pool, unsigned int flags) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int ret =3D -1; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, -1); =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), pool->name); goto cleanup; @@ -4657,8 +4656,8 @@ testStoragePoolRefresh(virStoragePoolPtr pool, =20 cleanup: testObjectEventQueue(privconn, event); - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4668,25 +4667,25 @@ testStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int ret =3D -1; =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 memset(info, 0, sizeof(virStoragePoolInfo)); - if (privpool->active) + if (obj->active) info->state =3D VIR_STORAGE_POOL_RUNNING; else info->state =3D VIR_STORAGE_POOL_INACTIVE; - info->capacity =3D privpool->def->capacity; - info->allocation =3D privpool->def->allocation; - info->available =3D privpool->def->available; + info->capacity =3D obj->def->capacity; + info->allocation =3D obj->def->allocation; + info->available =3D obj->def->available; ret =3D 0; =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4696,19 +4695,19 @@ testStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; char *ret =3D NULL; =20 virCheckFlags(0, NULL); =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - ret =3D virStoragePoolDefFormat(privpool->def); + ret =3D virStoragePoolDefFormat(obj->def); =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4718,22 +4717,22 @@ testStoragePoolGetAutostart(virStoragePoolPtr pool, int *autostart) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int ret =3D -1; =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (!privpool->configFile) { + if (!obj->configFile) { *autostart =3D 0; } else { - *autostart =3D privpool->autostart; + *autostart =3D obj->autostart; } ret =3D 0; =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4743,25 +4742,25 @@ testStoragePoolSetAutostart(virStoragePoolPtr pool, int autostart) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int ret =3D -1; =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (!privpool->configFile) { + if (!obj->configFile) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("pool has no config file")); goto cleanup; } =20 autostart =3D (autostart !=3D 0); - privpool->autostart =3D autostart; + obj->autostart =3D autostart; ret =3D 0; =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4770,24 +4769,24 @@ static int testStoragePoolNumOfVolumes(virStoragePoolPtr pool) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int ret =3D -1; =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), pool->name); goto cleanup; } =20 - ret =3D virStoragePoolObjNumOfVolumes(&privpool->volumes, pool->conn, - privpool->def, NULL); + ret =3D virStoragePoolObjNumOfVolumes(&obj->volumes, pool->conn, + obj->def, NULL); =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4798,52 +4797,52 @@ testStoragePoolListVolumes(virStoragePoolPtr pool, int maxnames) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; int n =3D -1; =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) return -1; =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), pool->name); goto cleanup; } =20 - n =3D virStoragePoolObjVolumeGetNames(&privpool->volumes, pool->conn, - privpool->def, NULL, names, maxnam= es); + n =3D virStoragePoolObjVolumeGetNames(&obj->volumes, pool->conn, + obj->def, NULL, names, maxnames); =20 cleanup: - virStoragePoolObjUnlock(privpool); + virStoragePoolObjUnlock(obj); return n; } =20 =20 static int -testStoragePoolListAllVolumes(virStoragePoolPtr obj, +testStoragePoolListAllVolumes(virStoragePoolPtr pool, virStorageVolPtr **vols, unsigned int flags) { - testDriverPtr privconn =3D obj->conn->privateData; - virStoragePoolObjPtr pool; + testDriverPtr privconn =3D pool->conn->privateData; + virStoragePoolObjPtr obj; int ret =3D -1; =20 virCheckFlags(0, -1); =20 - if (!(pool =3D testStoragePoolObjFindByUUID(privconn, obj->uuid))) + if (!(obj =3D testStoragePoolObjFindByUUID(privconn, pool->uuid))) return -1; =20 - if (!virStoragePoolObjIsActive(pool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("storage pool is not active")); goto cleanup; } =20 - ret =3D virStoragePoolObjVolumeListExport(obj->conn, &pool->volumes, - pool->def, vols, NULL); + ret =3D virStoragePoolObjVolumeListExport(pool->conn, &obj->volumes, + obj->def, vols, NULL); =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); =20 return ret; } @@ -4854,20 +4853,20 @@ testStorageVolLookupByName(virStoragePoolPtr pool, const char *name ATTRIBUTE_UNUSED) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; virStorageVolDefPtr privvol; virStorageVolPtr ret =3D NULL; =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), pool->name); goto cleanup; } =20 - privvol =3D virStorageVolDefFindByName(privpool, name); + privvol =3D virStorageVolDefFindByName(obj, name); =20 if (!privvol) { virReportError(VIR_ERR_NO_STORAGE_VOL, @@ -4875,13 +4874,13 @@ testStorageVolLookupByName(virStoragePoolPtr pool, goto cleanup; } =20 - ret =3D virGetStorageVol(pool->conn, privpool->def->name, + ret =3D virGetStorageVol(pool->conn, obj->def->name, privvol->name, privvol->key, NULL, NULL); =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4966,34 +4965,34 @@ testStorageVolCreateXML(virStoragePoolPtr pool, unsigned int flags) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; virStorageVolDefPtr privvol =3D NULL; virStorageVolPtr ret =3D NULL; =20 virCheckFlags(0, NULL); =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), pool->name); goto cleanup; } =20 - privvol =3D virStorageVolDefParseString(privpool->def, xmldesc, 0); + privvol =3D virStorageVolDefParseString(obj->def, xmldesc, 0); if (privvol =3D=3D NULL) goto cleanup; =20 - if (virStorageVolDefFindByName(privpool, privvol->name)) { + if (virStorageVolDefFindByName(obj, privvol->name)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("storage vol already exists")); goto cleanup; } =20 /* Make sure enough space */ - if ((privpool->def->allocation + privvol->target.allocation) > - privpool->def->capacity) { + if ((obj->def->allocation + privvol->target.allocation) > + obj->def->capacity) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Not enough free space in pool for volume '%s'"), privvol->name); @@ -5001,28 +5000,27 @@ testStorageVolCreateXML(virStoragePoolPtr pool, } =20 if (virAsprintf(&privvol->target.path, "%s/%s", - privpool->def->target.path, + obj->def->target.path, privvol->name) =3D=3D -1) goto cleanup; =20 if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || - VIR_APPEND_ELEMENT_COPY(privpool->volumes.objs, - privpool->volumes.count, privvol) < 0) + VIR_APPEND_ELEMENT_COPY(obj->volumes.objs, + obj->volumes.count, privvol) < 0) goto cleanup; =20 - privpool->def->allocation +=3D privvol->target.allocation; - privpool->def->available =3D (privpool->def->capacity - - privpool->def->allocation); + obj->def->allocation +=3D privvol->target.allocation; + obj->def->available =3D (obj->def->capacity - obj->def->allocation); =20 - ret =3D virGetStorageVol(pool->conn, privpool->def->name, + ret =3D virGetStorageVol(pool->conn, obj->def->name, privvol->name, privvol->key, NULL, NULL); privvol =3D NULL; =20 cleanup: virStorageVolDefFree(privvol); - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -5034,32 +5032,32 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, unsigned int flags) { testDriverPtr privconn =3D pool->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; virStorageVolDefPtr privvol =3D NULL, origvol =3D NULL; virStorageVolPtr ret =3D NULL; =20 virCheckFlags(0, NULL); =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) goto cleanup; =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), pool->name); goto cleanup; } =20 - privvol =3D virStorageVolDefParseString(privpool->def, xmldesc, 0); + privvol =3D virStorageVolDefParseString(obj->def, xmldesc, 0); if (privvol =3D=3D NULL) goto cleanup; =20 - if (virStorageVolDefFindByName(privpool, privvol->name)) { + if (virStorageVolDefFindByName(obj, privvol->name)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("storage vol already exists")); goto cleanup; } =20 - origvol =3D virStorageVolDefFindByName(privpool, clonevol->name); + origvol =3D virStorageVolDefFindByName(obj, clonevol->name); if (!origvol) { virReportError(VIR_ERR_NO_STORAGE_VOL, _("no storage vol with matching name '%s'"), @@ -5068,39 +5066,37 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, } =20 /* Make sure enough space */ - if ((privpool->def->allocation + privvol->target.allocation) > - privpool->def->capacity) { + if ((obj->def->allocation + privvol->target.allocation) > + obj->def->capacity) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Not enough free space in pool for volume '%s'"), privvol->name); goto cleanup; } - privpool->def->available =3D (privpool->def->capacity - - privpool->def->allocation); + obj->def->available =3D (obj->def->capacity - obj->def->allocation); =20 if (virAsprintf(&privvol->target.path, "%s/%s", - privpool->def->target.path, + obj->def->target.path, privvol->name) =3D=3D -1) goto cleanup; =20 if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || - VIR_APPEND_ELEMENT_COPY(privpool->volumes.objs, - privpool->volumes.count, privvol) < 0) + VIR_APPEND_ELEMENT_COPY(obj->volumes.objs, + obj->volumes.count, privvol) < 0) goto cleanup; =20 - privpool->def->allocation +=3D privvol->target.allocation; - privpool->def->available =3D (privpool->def->capacity - - privpool->def->allocation); + obj->def->allocation +=3D privvol->target.allocation; + obj->def->available =3D (obj->def->capacity - obj->def->allocation); =20 - ret =3D virGetStorageVol(pool->conn, privpool->def->name, + ret =3D virGetStorageVol(pool->conn, obj->def->name, privvol->name, privvol->key, NULL, NULL); privvol =3D NULL; =20 cleanup: virStorageVolDefFree(privvol); - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -5110,17 +5106,17 @@ testStorageVolDelete(virStorageVolPtr vol, unsigned int flags) { testDriverPtr privconn =3D vol->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; virStorageVolDefPtr privvol; size_t i; int ret =3D -1; =20 virCheckFlags(0, -1); =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, vol->pool))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, vol->pool))) goto cleanup; =20 - privvol =3D virStorageVolDefFindByName(privpool, vol->name); + privvol =3D virStorageVolDefFindByName(obj, vol->name); =20 if (privvol =3D=3D NULL) { virReportError(VIR_ERR_NO_STORAGE_VOL, @@ -5129,30 +5125,29 @@ testStorageVolDelete(virStorageVolPtr vol, goto cleanup; } =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), vol->pool); goto cleanup; } =20 =20 - privpool->def->allocation -=3D privvol->target.allocation; - privpool->def->available =3D (privpool->def->capacity - - privpool->def->allocation); + obj->def->allocation -=3D privvol->target.allocation; + obj->def->available =3D (obj->def->capacity - obj->def->allocation); =20 - for (i =3D 0; i < privpool->volumes.count; i++) { - if (privpool->volumes.objs[i] =3D=3D privvol) { + for (i =3D 0; i < obj->volumes.count; i++) { + if (obj->volumes.objs[i] =3D=3D privvol) { virStorageVolDefFree(privvol); =20 - VIR_DELETE_ELEMENT(privpool->volumes.objs, i, privpool->volume= s.count); + VIR_DELETE_ELEMENT(obj->volumes.objs, i, obj->volumes.count); break; } } ret =3D 0; =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -5177,14 +5172,14 @@ testStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info) { testDriverPtr privconn =3D vol->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; virStorageVolDefPtr privvol; int ret =3D -1; =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, vol->pool))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, vol->pool))) goto cleanup; =20 - privvol =3D virStorageVolDefFindByName(privpool, vol->name); + privvol =3D virStorageVolDefFindByName(obj, vol->name); =20 if (privvol =3D=3D NULL) { virReportError(VIR_ERR_NO_STORAGE_VOL, @@ -5193,21 +5188,21 @@ testStorageVolGetInfo(virStorageVolPtr vol, goto cleanup; } =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), vol->pool); goto cleanup; } =20 memset(info, 0, sizeof(*info)); - info->type =3D testStorageVolumeTypeForPool(privpool->def->type); + info->type =3D testStorageVolumeTypeForPool(obj->def->type); info->capacity =3D privvol->target.capacity; info->allocation =3D privvol->target.allocation; ret =3D 0; =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -5217,16 +5212,16 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) { testDriverPtr privconn =3D vol->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; virStorageVolDefPtr privvol; char *ret =3D NULL; =20 virCheckFlags(0, NULL); =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, vol->pool))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, vol->pool))) goto cleanup; =20 - privvol =3D virStorageVolDefFindByName(privpool, vol->name); + privvol =3D virStorageVolDefFindByName(obj, vol->name); =20 if (privvol =3D=3D NULL) { virReportError(VIR_ERR_NO_STORAGE_VOL, @@ -5235,17 +5230,17 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, goto cleanup; } =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), vol->pool); goto cleanup; } =20 - ret =3D virStorageVolDefFormat(privpool->def, privvol); + ret =3D virStorageVolDefFormat(obj->def, privvol); =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -5254,14 +5249,14 @@ static char * testStorageVolGetPath(virStorageVolPtr vol) { testDriverPtr privconn =3D vol->conn->privateData; - virStoragePoolObjPtr privpool; + virStoragePoolObjPtr obj; virStorageVolDefPtr privvol; char *ret =3D NULL; =20 - if (!(privpool =3D testStoragePoolObjFindByName(privconn, vol->pool))) + if (!(obj =3D testStoragePoolObjFindByName(privconn, vol->pool))) goto cleanup; =20 - privvol =3D virStorageVolDefFindByName(privpool, vol->name); + privvol =3D virStorageVolDefFindByName(obj, vol->name); =20 if (privvol =3D=3D NULL) { virReportError(VIR_ERR_NO_STORAGE_VOL, @@ -5270,7 +5265,7 @@ testStorageVolGetPath(virStorageVolPtr vol) goto cleanup; } =20 - if (!virStoragePoolObjIsActive(privpool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), vol->pool); goto cleanup; @@ -5279,8 +5274,8 @@ testStorageVolGetPath(virStorageVolPtr vol) ignore_value(VIR_STRDUP(ret, privvol->target.path)); =20 cleanup: - if (privpool) - virStoragePoolObjUnlock(privpool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343853141244.91758994873567; Tue, 9 May 2017 08:30:53 -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 34A1E7F6C5; Tue, 9 May 2017 15:30:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F290218231; Tue, 9 May 2017 15:30:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9B5B45EC63; Tue, 9 May 2017 15:30:48 +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 v49FUYKN002856 for ; Tue, 9 May 2017 11:30:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1387F8AC43; Tue, 9 May 2017 15:30:34 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8A5A19651 for ; Tue, 9 May 2017 15:30:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 34A1E7F6C5 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 34A1E7F6C5 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:10 -0400 Message-Id: <20170509153026.19767-4-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Cleanup exit/failure paths of some storage pool 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 09 May 2017 15:30:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rework some of the test driver API's to remove the need to return failure when testStoragePoolObjFindByName returns NULL rather than going to cleanup. This removes the need for check for "if (obj)" and in some instances the need to for a cleanup label and a local ret variable. Signed-off-by: John Ferlan --- src/test/test_driver.c | 49 ++++++++++++++++------------------------------= --- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c0e46af..efa54ff 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4060,14 +4060,12 @@ testStoragePoolLookupByUUID(virConnectPtr conn, virStoragePoolPtr ret =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindByUUID(privconn, uuid))) - goto cleanup; + return NULL; =20 ret =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL); =20 - cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4081,14 +4079,12 @@ testStoragePoolLookupByName(virConnectPtr conn, virStoragePoolPtr ret =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindByName(privconn, name))) - goto cleanup; + return NULL; =20 ret =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL); =20 - cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4210,13 +4206,11 @@ testStoragePoolIsPersistent(virStoragePoolPtr pool) int ret =3D -1; =20 if (!(obj =3D testStoragePoolObjFindByUUID(privconn, pool->uuid))) - goto cleanup; + return -1; =20 ret =3D obj->configFile ? 1 : 0; =20 - cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4668,10 +4662,9 @@ testStoragePoolGetInfo(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; - int ret =3D -1; =20 if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; + return -1; =20 memset(info, 0, sizeof(virStoragePoolInfo)); if (obj->active) @@ -4681,12 +4674,9 @@ testStoragePoolGetInfo(virStoragePoolPtr pool, info->capacity =3D obj->def->capacity; info->allocation =3D obj->def->allocation; info->available =3D obj->def->available; - ret =3D 0; =20 - cleanup: - if (obj) - virStoragePoolObjUnlock(obj); - return ret; + virStoragePoolObjUnlock(obj); + return 0; } =20 =20 @@ -4701,13 +4691,11 @@ testStoragePoolGetXMLDesc(virStoragePoolPtr pool, virCheckFlags(0, NULL); =20 if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; + return NULL; =20 ret =3D virStoragePoolDefFormat(obj->def); =20 - cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4718,22 +4706,18 @@ testStoragePoolGetAutostart(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; - int ret =3D -1; =20 if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; + return -1; =20 if (!obj->configFile) { *autostart =3D 0; } else { *autostart =3D obj->autostart; } - ret =3D 0; =20 - cleanup: - if (obj) - virStoragePoolObjUnlock(obj); - return ret; + virStoragePoolObjUnlock(obj); + return 0; } =20 =20 @@ -4746,7 +4730,7 @@ testStoragePoolSetAutostart(virStoragePoolPtr pool, int ret =3D -1; =20 if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; + return -1; =20 if (!obj->configFile) { virReportError(VIR_ERR_INVALID_ARG, @@ -4759,8 +4743,7 @@ testStoragePoolSetAutostart(virStoragePoolPtr pool, ret =3D 0; =20 cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343850244489.49876703862776; Tue, 9 May 2017 08:30:50 -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 9F7F16371; Tue, 9 May 2017 15:30:46 +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 7D5C1179FD; Tue, 9 May 2017 15:30:46 +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 3A8981800C8C; Tue, 9 May 2017 15:30:46 +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 v49FUYw6002863 for ; Tue, 9 May 2017 11:30:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 90FE38AC48; Tue, 9 May 2017 15:30:34 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50BFC19651 for ; Tue, 9 May 2017 15:30:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9F7F16371 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9F7F16371 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:11 -0400 Message-Id: <20170509153026.19767-5-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Add helpers to fetch active/inactive storage pool by name 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.38]); Tue, 09 May 2017 15:30:48 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than have repetitive code - create/use a couple of helpers: testStoragePoolObjFindActiveByName and testStoragePoolObjFindInactiveByName This will also allow for the reduction of some cleanup path logic. Signed-off-by: John Ferlan --- src/test/test_driver.c | 256 +++++++++++++++++----------------------------= ---- 1 file changed, 86 insertions(+), 170 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index efa54ff..9918df6 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4030,6 +4030,46 @@ testStoragePoolObjFindByName(testDriverPtr privconn, =20 =20 static virStoragePoolObjPtr +testStoragePoolObjFindActiveByName(testDriverPtr privconn, + const char *name) +{ + virStoragePoolObjPtr obj; + + if (!(obj =3D testStoragePoolObjFindByName(privconn, name))) + return NULL; + + if (!virStoragePoolObjIsActive(obj)) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("storage pool '%s' is not active"), name); + virStoragePoolObjUnlock(obj); + return NULL; + } + + return obj; +} + + +static virStoragePoolObjPtr +testStoragePoolObjFindInactiveByName(testDriverPtr privconn, + const char *name) +{ + virStoragePoolObjPtr obj; + + if (!(obj =3D testStoragePoolObjFindByName(privconn, name))) + return NULL; + + if (virStoragePoolObjIsActive(obj)) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("storage pool '%s' is already active"), name); + virStoragePoolObjUnlock(obj); + return NULL; + } + + return obj; +} + + +static virStoragePoolObjPtr testStoragePoolObjFindByUUID(testDriverPtr privconn, const unsigned char *uuid) { @@ -4221,32 +4261,22 @@ testStoragePoolCreate(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; - int ret =3D -1; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, -1); =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; - - if (virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is already active"), pool->nam= e); - goto cleanup; - } + if (!(obj =3D testStoragePoolObjFindInactiveByName(privconn, pool->nam= e))) + return -1; =20 obj->active =3D 1; =20 event =3D virStoragePoolEventLifecycleNew(pool->name, pool->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); - ret =3D 0; =20 - cleanup: testObjectEventQueue(privconn, event); - if (obj) - virStoragePoolObjUnlock(obj); - return ret; + virStoragePoolObjUnlock(obj); + return 0; } =20 =20 @@ -4458,31 +4488,19 @@ testStoragePoolUndefine(virStoragePoolPtr pool) { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; - int ret =3D -1; virObjectEventPtr event =3D NULL; =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; - - if (virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is already active"), pool->nam= e); - goto cleanup; - } + if (!(obj =3D testStoragePoolObjFindInactiveByName(privconn, pool->nam= e))) + return -1; =20 event =3D virStoragePoolEventLifecycleNew(pool->name, pool->uuid, VIR_STORAGE_POOL_EVENT_UNDEFIN= ED, 0); =20 virStoragePoolObjRemove(&privconn->pools, obj); - obj =3D NULL; - ret =3D 0; =20 - cleanup: - if (obj) - virStoragePoolObjUnlock(obj); testObjectEventQueue(privconn, event); - return ret; + return 0; } =20 =20 @@ -4492,24 +4510,14 @@ testStoragePoolBuild(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; - int ret =3D -1; =20 virCheckFlags(0, -1); =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; - - if (virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is already active"), pool->nam= e); - goto cleanup; - } - ret =3D 0; + if (!(obj =3D testStoragePoolObjFindInactiveByName(privconn, pool->nam= e))) + return -1; =20 - cleanup: - if (obj) - virStoragePoolObjUnlock(obj); - return ret; + virStoragePoolObjUnlock(obj); + return 0; } =20 =20 @@ -4559,14 +4567,8 @@ testStoragePoolDestroy(virStoragePoolPtr pool) int ret =3D -1; virObjectEventPtr event =3D NULL; =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; - - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->name); - goto cleanup; - } + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) + return -1; =20 obj->active =3D 0; =20 @@ -4603,25 +4605,14 @@ testStoragePoolDelete(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; - int ret =3D -1; =20 virCheckFlags(0, -1); =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; - - if (virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is already active"), pool->nam= e); - goto cleanup; - } - - ret =3D 0; + if (!(obj =3D testStoragePoolObjFindInactiveByName(privconn, pool->nam= e))) + return -1; =20 - cleanup: - if (obj) - virStoragePoolObjUnlock(obj); - return ret; + virStoragePoolObjUnlock(obj); + return 0; } =20 =20 @@ -4631,28 +4622,18 @@ testStoragePoolRefresh(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; - int ret =3D -1; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, -1); =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; - - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->name); - goto cleanup; - } + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) + return -1; =20 event =3D virStoragePoolEventRefreshNew(pool->name, pool->uuid); - ret =3D 0; =20 - cleanup: testObjectEventQueue(privconn, event); - if (obj) - virStoragePoolObjUnlock(obj); - return ret; + virStoragePoolObjUnlock(obj); + return 0; } =20 =20 @@ -4755,21 +4736,13 @@ testStoragePoolNumOfVolumes(virStoragePoolPtr pool) virStoragePoolObjPtr obj; int ret =3D -1; =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; - - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->name); - goto cleanup; - } + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) + return -1; =20 ret =3D virStoragePoolObjNumOfVolumes(&obj->volumes, pool->conn, obj->def, NULL); =20 - cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4783,19 +4756,12 @@ testStoragePoolListVolumes(virStoragePoolPtr pool, virStoragePoolObjPtr obj; int n =3D -1; =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) return -1; =20 - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->name); - goto cleanup; - } - n =3D virStoragePoolObjVolumeGetNames(&obj->volumes, pool->conn, obj->def, NULL, names, maxnames); =20 - cleanup: virStoragePoolObjUnlock(obj); return n; } @@ -4840,14 +4806,8 @@ testStorageVolLookupByName(virStoragePoolPtr pool, virStorageVolDefPtr privvol; virStorageVolPtr ret =3D NULL; =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; - - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->name); - goto cleanup; - } + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) + return NULL; =20 privvol =3D virStorageVolDefFindByName(obj, name); =20 @@ -4862,8 +4822,7 @@ testStorageVolLookupByName(virStoragePoolPtr pool, NULL, NULL); =20 cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -4954,14 +4913,8 @@ testStorageVolCreateXML(virStoragePoolPtr pool, =20 virCheckFlags(0, NULL); =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; - - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->name); - goto cleanup; - } + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) + return NULL; =20 privvol =3D virStorageVolDefParseString(obj->def, xmldesc, 0); if (privvol =3D=3D NULL) @@ -5002,8 +4955,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool, =20 cleanup: virStorageVolDefFree(privvol); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -5021,14 +4973,8 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, =20 virCheckFlags(0, NULL); =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) - goto cleanup; - - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->name); - goto cleanup; - } + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) + return NULL; =20 privvol =3D virStorageVolDefParseString(obj->def, xmldesc, 0); if (privvol =3D=3D NULL) @@ -5078,8 +5024,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, =20 cleanup: virStorageVolDefFree(privvol); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -5096,8 +5041,8 @@ testStorageVolDelete(virStorageVolPtr vol, =20 virCheckFlags(0, -1); =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, vol->pool))) - goto cleanup; + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, vol->pool))) + return -1; =20 privvol =3D virStorageVolDefFindByName(obj, vol->name); =20 @@ -5108,13 +5053,6 @@ testStorageVolDelete(virStorageVolPtr vol, goto cleanup; } =20 - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), vol->pool); - goto cleanup; - } - - obj->def->allocation -=3D privvol->target.allocation; obj->def->available =3D (obj->def->capacity - obj->def->allocation); =20 @@ -5129,8 +5067,7 @@ testStorageVolDelete(virStorageVolPtr vol, ret =3D 0; =20 cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -5159,8 +5096,8 @@ testStorageVolGetInfo(virStorageVolPtr vol, virStorageVolDefPtr privvol; int ret =3D -1; =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, vol->pool))) - goto cleanup; + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, vol->pool))) + return -1; =20 privvol =3D virStorageVolDefFindByName(obj, vol->name); =20 @@ -5171,12 +5108,6 @@ testStorageVolGetInfo(virStorageVolPtr vol, goto cleanup; } =20 - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), vol->pool); - goto cleanup; - } - memset(info, 0, sizeof(*info)); info->type =3D testStorageVolumeTypeForPool(obj->def->type); info->capacity =3D privvol->target.capacity; @@ -5184,8 +5115,7 @@ testStorageVolGetInfo(virStorageVolPtr vol, ret =3D 0; =20 cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -5201,8 +5131,8 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, =20 virCheckFlags(0, NULL); =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, vol->pool))) - goto cleanup; + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, vol->pool))) + return NULL; =20 privvol =3D virStorageVolDefFindByName(obj, vol->name); =20 @@ -5213,17 +5143,10 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, goto cleanup; } =20 - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), vol->pool); - goto cleanup; - } - ret =3D virStorageVolDefFormat(obj->def, privvol); =20 cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -5236,8 +5159,8 @@ testStorageVolGetPath(virStorageVolPtr vol) virStorageVolDefPtr privvol; char *ret =3D NULL; =20 - if (!(obj =3D testStoragePoolObjFindByName(privconn, vol->pool))) - goto cleanup; + if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, vol->pool))) + return NULL; =20 privvol =3D virStorageVolDefFindByName(obj, vol->name); =20 @@ -5248,17 +5171,10 @@ testStorageVolGetPath(virStorageVolPtr vol) goto cleanup; } =20 - if (!virStoragePoolObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), vol->pool); - goto cleanup; - } - ignore_value(VIR_STRDUP(ret, privvol->target.path)); =20 cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjUnlock(obj); return ret; } =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343854522986.7863063193118; Tue, 9 May 2017 08:30:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD8EF7F7DE; Tue, 9 May 2017 15:30:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B3ABE8852C; Tue, 9 May 2017 15:30:52 +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 624B85EC6A; Tue, 9 May 2017 15:30:52 +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 v49FUZhb002868 for ; Tue, 9 May 2017 11:30:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 044BC19651; Tue, 9 May 2017 15:30:35 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8F0F8AC45 for ; Tue, 9 May 2017 15:30:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DD8EF7F7DE 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DD8EF7F7DE From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:12 -0400 Message-Id: <20170509153026.19767-6-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Add testStorageVolDefFindByName for storage volume tests 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, 09 May 2017 15:30:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove repetitive code, replace with common function. Signed-off-by: John Ferlan --- src/test/test_driver.c | 56 +++++++++++++++++++---------------------------= ---- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 9918df6..460aa88 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4797,9 +4797,24 @@ testStoragePoolListAllVolumes(virStoragePoolPtr pool, } =20 =20 +static virStorageVolDefPtr +testStorageVolDefFindByName(virStoragePoolObjPtr obj, + const char *name) +{ + virStorageVolDefPtr privvol; + + if (!(privvol =3D virStorageVolDefFindByName(obj, name))) { + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), name); + } + + return privvol; +} + + static virStorageVolPtr testStorageVolLookupByName(virStoragePoolPtr pool, - const char *name ATTRIBUTE_UNUSED) + const char *name) { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; @@ -4809,13 +4824,8 @@ testStorageVolLookupByName(virStoragePoolPtr pool, if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) return NULL; =20 - privvol =3D virStorageVolDefFindByName(obj, name); - - if (!privvol) { - virReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), name); + if (!(privvol =3D testStorageVolDefFindByName(obj, name))) goto cleanup; - } =20 ret =3D virGetStorageVol(pool->conn, obj->def->name, privvol->name, privvol->key, @@ -5044,14 +5054,8 @@ testStorageVolDelete(virStorageVolPtr vol, if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, vol->pool))) return -1; =20 - privvol =3D virStorageVolDefFindByName(obj, vol->name); - - if (privvol =3D=3D NULL) { - virReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - vol->name); + 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); @@ -5099,14 +5103,8 @@ testStorageVolGetInfo(virStorageVolPtr vol, if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, vol->pool))) return -1; =20 - privvol =3D virStorageVolDefFindByName(obj, vol->name); - - if (privvol =3D=3D NULL) { - virReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - vol->name); + if (!(privvol =3D testStorageVolDefFindByName(obj, vol->name))) goto cleanup; - } =20 memset(info, 0, sizeof(*info)); info->type =3D testStorageVolumeTypeForPool(obj->def->type); @@ -5134,14 +5132,8 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, vol->pool))) return NULL; =20 - privvol =3D virStorageVolDefFindByName(obj, vol->name); - - if (privvol =3D=3D NULL) { - virReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - vol->name); + if (!(privvol =3D testStorageVolDefFindByName(obj, vol->name))) goto cleanup; - } =20 ret =3D virStorageVolDefFormat(obj->def, privvol); =20 @@ -5162,14 +5154,8 @@ testStorageVolGetPath(virStorageVolPtr vol) if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, vol->pool))) return NULL; =20 - privvol =3D virStorageVolDefFindByName(obj, vol->name); - - if (privvol =3D=3D NULL) { - virReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - vol->name); + if (!(privvol =3D testStorageVolDefFindByName(obj, vol->name))) goto cleanup; - } =20 ignore_value(VIR_STRDUP(ret, privvol->target.path)); =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343852497165.75401096661244; Tue, 9 May 2017 08:30:52 -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 4EAA880C17; Tue, 9 May 2017 15:30:49 +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 E99E9179FD; Tue, 9 May 2017 15:30:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 97F23180BAF3; Tue, 9 May 2017 15:30:48 +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 v49FUZBm002883 for ; Tue, 9 May 2017 11:30:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id E2E9F8AC40; Tue, 9 May 2017 15:30:35 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id A42C28AC43 for ; Tue, 9 May 2017 15:30:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4EAA880C17 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4EAA880C17 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:13 -0400 Message-Id: <20170509153026.19767-7-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Fix return value checks for virAsprintf 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, 09 May 2017 15:30:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the < 0 rather than =3D=3D -1 (consistently) for virAsprintf errors. Signed-off-by: John Ferlan --- src/storage/storage_backend_logical.c | 2 +- src/storage/storage_backend_rbd.c | 8 ++++---- src/storage/storage_backend_sheepdog.c | 4 ++-- src/storage/storage_backend_zfs.c | 4 ++-- src/storage/storage_util.c | 6 +++--- src/test/test_driver.c | 9 +++------ 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index ed26c24..67f70e5 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -948,7 +948,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", pool->def->target.path, - vol->name) =3D=3D -1) + vol->name) < 0) return -1; =20 cmd =3D virCommandNewArgList(LVCREATE, diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index c806d6d..7b8887b 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -404,13 +404,13 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPt= r vol, VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", pool->def->source.name, - vol->name) =3D=3D -1) + vol->name) < 0) goto cleanup; =20 VIR_FREE(vol->key); if (virAsprintf(&vol->key, "%s/%s", pool->def->source.name, - vol->name) =3D=3D -1) + vol->name) < 0) goto cleanup; =20 ret =3D 0; @@ -662,13 +662,13 @@ virStorageBackendRBDCreateVol(virConnectPtr conn ATTR= IBUTE_UNUSED, VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", pool->def->source.name, - vol->name) =3D=3D -1) + vol->name) < 0) return -1; =20 VIR_FREE(vol->key); if (virAsprintf(&vol->key, "%s/%s", pool->def->source.name, - vol->name) =3D=3D -1) + vol->name) < 0) return -1; =20 return 0; diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_b= ackend_sheepdog.c index a9a2301..b55d96a 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -249,7 +249,7 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn A= TTRIBUTE_UNUSED, =20 VIR_FREE(vol->key); if (virAsprintf(&vol->key, "%s/%s", - pool->def->source.name, vol->name) =3D=3D -1) + pool->def->source.name, vol->name) < 0) return -1; =20 VIR_FREE(vol->target.path); @@ -374,7 +374,7 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn = ATTRIBUTE_UNUSED, =20 VIR_FREE(vol->key); if (virAsprintf(&vol->key, "%s/%s", - pool->def->source.name, vol->name) =3D=3D -1) + pool->def->source.name, vol->name) < 0) goto cleanup; =20 VIR_FREE(vol->target.path); diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index 004d95a..c6dae71 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -89,7 +89,7 @@ virStorageBackendZFSCheckPool(virStoragePoolObjPtr pool A= TTRIBUTE_UNUSED, char *devpath; =20 if (virAsprintf(&devpath, "/dev/zvol/%s", - pool->def->source.name) =3D=3D -1) + pool->def->source.name) < 0) return -1; *isActive =3D virFileIsDir(devpath); VIR_FREE(devpath); @@ -322,7 +322,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) =3D=3D -1) + pool->def->target.path, vol->name) < 0) return -1; =20 if (VIR_STRDUP(vol->key, vol->target.path) < 0) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 43f3561..08dca94 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1982,7 +1982,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, while ((direrr =3D virDirRead(dh, &dent, NULL)) > 0) { if (virAsprintf(&stablepath, "%s/%s", pool->def->target.path, - dent->d_name) =3D=3D -1) { + dent->d_name) < 0) { VIR_DIR_CLOSE(dh); return NULL; } @@ -2082,7 +2082,7 @@ virStorageBackendVolCreateLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", pool->def->target.path, - vol->name) =3D=3D -1) + vol->name) < 0) return -1; =20 if (virFileExists(vol->target.path)) { @@ -3553,7 +3553,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, vol->target.format =3D VIR_STORAGE_FILE_RAW; /* Real value is fill= ed in during probe */ if (virAsprintf(&vol->target.path, "%s/%s", pool->def->target.path, - vol->name) =3D=3D -1) + vol->name) < 0) goto cleanup; =20 if (VIR_STRDUP(vol->key, vol->target.path) < 0) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 460aa88..8d03bdb 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1069,8 +1069,7 @@ testOpenVolumesForPool(const char *file, =20 if (def->target.path =3D=3D NULL) { if (virAsprintf(&def->target.path, "%s/%s", - obj->def->target.path, - def->name) =3D=3D -1) + obj->def->target.path, def->name) < 0) goto error; } =20 @@ -4946,8 +4945,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool, } =20 if (virAsprintf(&privvol->target.path, "%s/%s", - obj->def->target.path, - privvol->name) =3D=3D -1) + obj->def->target.path, privvol->name) < 0) goto cleanup; =20 if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || @@ -5015,8 +5013,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, obj->def->available =3D (obj->def->capacity - obj->def->allocation); =20 if (virAsprintf(&privvol->target.path, "%s/%s", - obj->def->target.path, - privvol->name) =3D=3D -1) + obj->def->target.path, privvol->name) < 0) goto cleanup; =20 if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343872646399.0184888404441; Tue, 9 May 2017 08:31:12 -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 CA982C05AA43; Tue, 9 May 2017 15:31:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A51E14FA24; Tue, 9 May 2017 15:31:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1F6AA180BAFC; Tue, 9 May 2017 15:30:56 +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 v49FUaCW002893 for ; Tue, 9 May 2017 11:30:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7FBA61964E; Tue, 9 May 2017 15:30:36 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 264408AC40 for ; Tue, 9 May 2017 15:30:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CA982C05AA43 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CA982C05AA43 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:14 -0400 Message-Id: <20170509153026.19767-8-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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 consistent variable names in virstorageobj 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.32]); Tue, 09 May 2017 15:31:09 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A virStoragePoolObjPtr will be an 'obj'. A virStoragePoolPtr will be a 'pool'. NB: Also modify the @matchpool to @matchobj. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 342 +++++++++++++++++++++++--------------------= ---- src/conf/virstorageobj.h | 20 +-- 2 files changed, 180 insertions(+), 182 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index dd41701..74a9c67 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -70,15 +70,15 @@ virStoragePoolObjListFree(virStoragePoolObjListPtr pool= s) =20 void virStoragePoolObjRemove(virStoragePoolObjListPtr pools, - virStoragePoolObjPtr pool) + virStoragePoolObjPtr obj) { size_t i; =20 - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); =20 for (i =3D 0; i < pools->count; i++) { virStoragePoolObjLock(pools->objs[i]); - if (pools->objs[i] =3D=3D pool) { + if (pools->objs[i] =3D=3D obj) { virStoragePoolObjUnlock(pools->objs[i]); virStoragePoolObjFree(pools->objs[i]); =20 @@ -125,15 +125,15 @@ virStoragePoolObjFindByName(virStoragePoolObjListPtr = pools, =20 =20 static virStoragePoolObjPtr -virStoragePoolSourceFindDuplicateDevices(virStoragePoolObjPtr pool, +virStoragePoolSourceFindDuplicateDevices(virStoragePoolObjPtr obj, virStoragePoolDefPtr def) { size_t i, j; =20 - for (i =3D 0; i < pool->def->source.ndevice; i++) { + for (i =3D 0; i < obj->def->source.ndevice; i++) { for (j =3D 0; j < def->source.ndevice; j++) { - if (STREQ(pool->def->source.devices[i].path, def->source.devic= es[j].path)) - return pool; + if (STREQ(obj->def->source.devices[i].path, def->source.device= s[j].path)) + return obj; } } =20 @@ -142,54 +142,54 @@ virStoragePoolSourceFindDuplicateDevices(virStoragePo= olObjPtr pool, =20 =20 void -virStoragePoolObjClearVols(virStoragePoolObjPtr pool) +virStoragePoolObjClearVols(virStoragePoolObjPtr obj) { size_t i; - for (i =3D 0; i < pool->volumes.count; i++) - virStorageVolDefFree(pool->volumes.objs[i]); + for (i =3D 0; i < obj->volumes.count; i++) + virStorageVolDefFree(obj->volumes.objs[i]); =20 - VIR_FREE(pool->volumes.objs); - pool->volumes.count =3D 0; + VIR_FREE(obj->volumes.objs); + obj->volumes.count =3D 0; } =20 =20 virStorageVolDefPtr -virStorageVolDefFindByKey(virStoragePoolObjPtr pool, +virStorageVolDefFindByKey(virStoragePoolObjPtr obj, const char *key) { size_t i; =20 - for (i =3D 0; i < pool->volumes.count; i++) - if (STREQ(pool->volumes.objs[i]->key, key)) - return pool->volumes.objs[i]; + for (i =3D 0; i < obj->volumes.count; i++) + if (STREQ(obj->volumes.objs[i]->key, key)) + return obj->volumes.objs[i]; =20 return NULL; } =20 =20 virStorageVolDefPtr -virStorageVolDefFindByPath(virStoragePoolObjPtr pool, +virStorageVolDefFindByPath(virStoragePoolObjPtr obj, const char *path) { size_t i; =20 - for (i =3D 0; i < pool->volumes.count; i++) - if (STREQ(pool->volumes.objs[i]->target.path, path)) - return pool->volumes.objs[i]; + for (i =3D 0; i < obj->volumes.count; i++) + if (STREQ(obj->volumes.objs[i]->target.path, path)) + return obj->volumes.objs[i]; =20 return NULL; } =20 =20 virStorageVolDefPtr -virStorageVolDefFindByName(virStoragePoolObjPtr pool, +virStorageVolDefFindByName(virStoragePoolObjPtr obj, const char *name) { size_t i; =20 - for (i =3D 0; i < pool->volumes.count; i++) - if (STREQ(pool->volumes.objs[i]->name, name)) - return pool->volumes.objs[i]; + for (i =3D 0; i < obj->volumes.count; i++) + if (STREQ(obj->volumes.objs[i]->name, name)) + return obj->volumes.objs[i]; =20 return NULL; } @@ -296,39 +296,39 @@ virStoragePoolObjPtr virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools, virStoragePoolDefPtr def) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; =20 - if ((pool =3D virStoragePoolObjFindByName(pools, def->name))) { - if (!virStoragePoolObjIsActive(pool)) { - virStoragePoolDefFree(pool->def); - pool->def =3D def; + if ((obj =3D virStoragePoolObjFindByName(pools, def->name))) { + if (!virStoragePoolObjIsActive(obj)) { + virStoragePoolDefFree(obj->def); + obj->def =3D def; } else { - virStoragePoolDefFree(pool->newDef); - pool->newDef =3D def; + virStoragePoolDefFree(obj->newDef); + obj->newDef =3D def; } - return pool; + return obj; } =20 - if (VIR_ALLOC(pool) < 0) + if (VIR_ALLOC(obj) < 0) return NULL; =20 - if (virMutexInit(&pool->lock) < 0) { + if (virMutexInit(&obj->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot initialize mutex")); - VIR_FREE(pool); + VIR_FREE(obj); return NULL; } - virStoragePoolObjLock(pool); - pool->active =3D 0; + virStoragePoolObjLock(obj); + obj->active =3D 0; =20 - if (VIR_APPEND_ELEMENT_COPY(pools->objs, pools->count, pool) < 0) { - virStoragePoolObjUnlock(pool); - virStoragePoolObjFree(pool); + if (VIR_APPEND_ELEMENT_COPY(pools->objs, pools->count, obj) < 0) { + virStoragePoolObjUnlock(obj); + virStoragePoolObjFree(obj); return NULL; } - pool->def =3D def; + obj->def =3D def; =20 - return pool; + return obj; } =20 =20 @@ -339,7 +339,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools, const char *autostartLink) { virStoragePoolDefPtr def; - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; =20 if (!(def =3D virStoragePoolDefParseFile(path))) return NULL; @@ -353,26 +353,26 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools, return NULL; } =20 - if (!(pool =3D virStoragePoolObjAssignDef(pools, def))) { + if (!(obj =3D virStoragePoolObjAssignDef(pools, def))) { virStoragePoolDefFree(def); return NULL; } =20 - VIR_FREE(pool->configFile); /* for driver reload */ - if (VIR_STRDUP(pool->configFile, path) < 0) { - virStoragePoolObjRemove(pools, pool); + VIR_FREE(obj->configFile); /* for driver reload */ + if (VIR_STRDUP(obj->configFile, path) < 0) { + virStoragePoolObjRemove(pools, obj); return NULL; } - VIR_FREE(pool->autostartLink); /* for driver reload */ - if (VIR_STRDUP(pool->autostartLink, autostartLink) < 0) { - virStoragePoolObjRemove(pools, pool); + VIR_FREE(obj->autostartLink); /* for driver reload */ + if (VIR_STRDUP(obj->autostartLink, autostartLink) < 0) { + virStoragePoolObjRemove(pools, obj); return NULL; } =20 - pool->autostart =3D virFileLinkPointsTo(pool->autostartLink, - pool->configFile); + obj->autostart =3D virFileLinkPointsTo(obj->autostartLink, + obj->configFile); =20 - return pool; + return obj; } =20 =20 @@ -383,7 +383,7 @@ virStoragePoolObjLoadState(virStoragePoolObjListPtr poo= ls, { char *stateFile =3D NULL; virStoragePoolDefPtr def =3D NULL; - virStoragePoolObjPtr pool =3D NULL; + virStoragePoolObjPtr obj =3D NULL; xmlDocPtr xml =3D NULL; xmlXPathContextPtr ctxt =3D NULL; xmlNodePtr node =3D NULL; @@ -413,7 +413,7 @@ virStoragePoolObjLoadState(virStoragePoolObjListPtr poo= ls, } =20 /* create the object */ - if (!(pool =3D virStoragePoolObjAssignDef(pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(pools, def))) goto error; =20 /* XXX: future handling of some additional useful status data, @@ -421,13 +421,13 @@ virStoragePoolObjLoadState(virStoragePoolObjListPtr p= ools, * as active */ =20 - pool->active =3D 1; + obj->active =3D 1; =20 cleanup: VIR_FREE(stateFile); xmlFreeDoc(xml); xmlXPathFreeContext(ctxt); - return pool; + return obj; =20 error: virStoragePoolDefFree(def); @@ -448,15 +448,14 @@ virStoragePoolObjLoadAllState(virStoragePoolObjListPt= r pools, return rc; =20 while ((ret =3D virDirRead(dir, &entry, stateDir)) > 0) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; =20 if (!virFileStripSuffix(entry->d_name, ".xml")) continue; =20 - if (!(pool =3D virStoragePoolObjLoadState(pools, stateDir, - entry->d_name))) + if (!(obj =3D virStoragePoolObjLoadState(pools, stateDir, entry->d= _name))) continue; - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); } =20 VIR_DIR_CLOSE(dir); @@ -480,7 +479,7 @@ virStoragePoolObjLoadAllConfigs(virStoragePoolObjListPt= r pools, while ((ret =3D virDirRead(dir, &entry, configDir)) > 0) { char *path; char *autostartLink; - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; =20 if (!virFileHasSuffix(entry->d_name, ".xml")) continue; @@ -494,10 +493,9 @@ virStoragePoolObjLoadAllConfigs(virStoragePoolObjListP= tr pools, continue; } =20 - pool =3D virStoragePoolObjLoad(pools, entry->d_name, path, - autostartLink); - if (pool) - virStoragePoolObjUnlock(pool); + obj =3D virStoragePoolObjLoad(pools, entry->d_name, path, autostar= tLink); + if (obj) + virStoragePoolObjUnlock(obj); =20 VIR_FREE(path); VIR_FREE(autostartLink); @@ -510,10 +508,10 @@ virStoragePoolObjLoadAllConfigs(virStoragePoolObjList= Ptr pools, =20 int virStoragePoolObjSaveDef(virStorageDriverStatePtr driver, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStoragePoolDefPtr def) { - if (!pool->configFile) { + if (!obj->configFile) { if (virFileMakePath(driver->configDir) < 0) { virReportSystemError(errno, _("cannot create config directory %s"), @@ -521,35 +519,35 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr dri= ver, return -1; } =20 - if (!(pool->configFile =3D virFileBuildPath(driver->configDir, - def->name, ".xml"))) { + if (!(obj->configFile =3D virFileBuildPath(driver->configDir, + def->name, ".xml"))) { return -1; } =20 - if (!(pool->autostartLink =3D virFileBuildPath(driver->autostartDi= r, - def->name, ".xml"))) { - VIR_FREE(pool->configFile); + if (!(obj->autostartLink =3D virFileBuildPath(driver->autostartDir, + def->name, ".xml"))) { + VIR_FREE(obj->configFile); return -1; } } =20 - return virStoragePoolSaveConfig(pool->configFile, def); + return virStoragePoolSaveConfig(obj->configFile, def); } =20 =20 int -virStoragePoolObjDeleteDef(virStoragePoolObjPtr pool) +virStoragePoolObjDeleteDef(virStoragePoolObjPtr obj) { - if (!pool->configFile) { + if (!obj->configFile) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("no config file for %s"), pool->def->name); + _("no config file for %s"), obj->def->name); return -1; } =20 - if (unlink(pool->configFile) < 0) { + if (unlink(obj->configFile) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot remove config for %s"), - pool->def->name); + obj->def->name); return -1; } =20 @@ -632,27 +630,27 @@ virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr= pools, unsigned int check_active) { int ret =3D -1; - virStoragePoolObjPtr pool =3D NULL; + virStoragePoolObjPtr obj =3D NULL; =20 /* See if a Pool with matching UUID already exists */ - pool =3D virStoragePoolObjFindByUUID(pools, def->uuid); - if (pool) { + obj =3D virStoragePoolObjFindByUUID(pools, def->uuid); + if (obj) { /* UUID matches, but if names don't match, refuse it */ - if (STRNEQ(pool->def->name, def->name)) { + if (STRNEQ(obj->def->name, def->name)) { char uuidstr[VIR_UUID_STRING_BUFLEN]; - virUUIDFormat(pool->def->uuid, uuidstr); + virUUIDFormat(obj->def->uuid, uuidstr); virReportError(VIR_ERR_OPERATION_FAILED, _("pool '%s' is already defined with uuid %s"), - pool->def->name, uuidstr); + obj->def->name, uuidstr); goto cleanup; } =20 if (check_active) { /* UUID & name match, but if Pool is already active, refuse it= */ - if (virStoragePoolObjIsActive(pool)) { + if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("pool is already active as '%s'"), - pool->def->name); + obj->def->name); goto cleanup; } } @@ -660,10 +658,10 @@ virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr= pools, ret =3D 1; } else { /* UUID does not match, but if a name matches, refuse it */ - pool =3D virStoragePoolObjFindByName(pools, def->name); - if (pool) { + obj =3D virStoragePoolObjFindByName(pools, def->name); + if (obj) { char uuidstr[VIR_UUID_STRING_BUFLEN]; - virUUIDFormat(pool->def->uuid, uuidstr); + virUUIDFormat(obj->def->uuid, uuidstr); virReportError(VIR_ERR_OPERATION_FAILED, _("pool '%s' already exists with uuid %s"), def->name, uuidstr); @@ -673,8 +671,8 @@ virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr p= ools, } =20 cleanup: - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -839,10 +837,10 @@ virStoragePoolSourceMatchSingleHost(virStoragePoolSou= rcePtr poolsrc, =20 =20 static bool -virStoragePoolSourceISCSIMatch(virStoragePoolObjPtr matchpool, +virStoragePoolSourceISCSIMatch(virStoragePoolObjPtr obj, virStoragePoolDefPtr def) { - virStoragePoolSourcePtr poolsrc =3D &matchpool->def->source; + virStoragePoolSourcePtr poolsrc =3D &obj->def->source; virStoragePoolSourcePtr defsrc =3D &def->source; =20 /* NB: Do not check the source host name */ @@ -854,23 +852,23 @@ virStoragePoolSourceISCSIMatch(virStoragePoolObjPtr m= atchpool, =20 =20 static virStoragePoolObjPtr -virStoragePoolObjSourceMatchTypeDIR(virStoragePoolObjPtr pool, +virStoragePoolObjSourceMatchTypeDIR(virStoragePoolObjPtr obj, virStoragePoolDefPtr def) { - if (pool->def->type =3D=3D VIR_STORAGE_POOL_DIR) { - if (STREQ(pool->def->target.path, def->target.path)) - return pool; - } else if (pool->def->type =3D=3D VIR_STORAGE_POOL_GLUSTER) { - if (STREQ(pool->def->source.name, def->source.name) && - STREQ_NULLABLE(pool->def->source.dir, def->source.dir) && - virStoragePoolSourceMatchSingleHost(&pool->def->source, + if (obj->def->type =3D=3D VIR_STORAGE_POOL_DIR) { + if (STREQ(obj->def->target.path, def->target.path)) + return obj; + } else if (obj->def->type =3D=3D VIR_STORAGE_POOL_GLUSTER) { + if (STREQ(obj->def->source.name, def->source.name) && + STREQ_NULLABLE(obj->def->source.dir, def->source.dir) && + virStoragePoolSourceMatchSingleHost(&obj->def->source, &def->source)) - return pool; - } else if (pool->def->type =3D=3D VIR_STORAGE_POOL_NETFS) { - if (STREQ(pool->def->source.dir, def->source.dir) && - virStoragePoolSourceMatchSingleHost(&pool->def->source, + return obj; + } else if (obj->def->type =3D=3D VIR_STORAGE_POOL_NETFS) { + if (STREQ(obj->def->source.dir, def->source.dir) && + virStoragePoolSourceMatchSingleHost(&obj->def->source, &def->source)) - return pool; + return obj; } =20 return NULL; @@ -878,11 +876,11 @@ virStoragePoolObjSourceMatchTypeDIR(virStoragePoolObj= Ptr pool, =20 =20 static virStoragePoolObjPtr -virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObjPtr pool, +virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObjPtr obj, virStoragePoolDefPtr def, virConnectPtr conn) { - virStorageAdapterPtr pool_adapter =3D &pool->def->source.adapter; + virStorageAdapterPtr pool_adapter =3D &obj->def->source.adapter; virStorageAdapterPtr def_adapter =3D &def->source.adapter; virStorageAdapterSCSIHostPtr pool_scsi_host; virStorageAdapterSCSIHostPtr def_scsi_host; @@ -899,7 +897,7 @@ virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObj= Ptr pool, =20 if (STREQ(pool_fchost->wwnn, def_fchost->wwnn) && STREQ(pool_fchost->wwpn, def_fchost->wwpn)) - return pool; + return obj; } else if (pool_adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOS= T && def_adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST= ) { pool_scsi_host =3D &pool_adapter->data.scsi_host; @@ -908,13 +906,13 @@ virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolO= bjPtr pool, if (pool_scsi_host->has_parent && def_scsi_host->has_parent && matchSCSIAdapterParent(pool_scsi_host, def_scsi_host)) - return pool; + return obj; =20 if (getSCSIHostNumber(pool_scsi_host, &pool_hostnum) < 0 || getSCSIHostNumber(def_scsi_host, &def_hostnum) < 0) return NULL; if (pool_hostnum =3D=3D def_hostnum) - return pool; + return obj; } else if (pool_adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST = && def_adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST= ) { pool_fchost =3D &pool_adapter->data.fchost; @@ -925,7 +923,7 @@ virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObj= Ptr pool, return NULL; =20 if (matchFCHostToSCSIHost(conn, pool_fchost, scsi_hostnum)) - return pool; + return obj; =20 } else if (pool_adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOS= T && def_adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { @@ -936,7 +934,7 @@ virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObj= Ptr pool, return NULL; =20 if (matchFCHostToSCSIHost(conn, def_fchost, scsi_hostnum)) - return pool; + return obj; } =20 return NULL; @@ -944,20 +942,20 @@ virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolO= bjPtr pool, =20 =20 static virStoragePoolObjPtr -virStoragePoolObjSourceMatchTypeDEVICE(virStoragePoolObjPtr pool, +virStoragePoolObjSourceMatchTypeDEVICE(virStoragePoolObjPtr obj, virStoragePoolDefPtr def) { - virStoragePoolObjPtr matchpool =3D NULL; + virStoragePoolObjPtr matchobj =3D NULL; =20 - if (pool->def->type =3D=3D VIR_STORAGE_POOL_ISCSI) { + if (obj->def->type =3D=3D VIR_STORAGE_POOL_ISCSI) { if (def->type !=3D VIR_STORAGE_POOL_ISCSI) return NULL; =20 - if ((matchpool =3D virStoragePoolSourceFindDuplicateDevices(pool, = def))) { - if (!virStoragePoolSourceISCSIMatch(matchpool, def)) + if ((matchobj =3D virStoragePoolSourceFindDuplicateDevices(obj, de= f))) { + if (!virStoragePoolSourceISCSIMatch(matchobj, def)) return NULL; } - return matchpool; + return matchobj; } =20 if (def->type =3D=3D VIR_STORAGE_POOL_ISCSI) @@ -967,7 +965,7 @@ virStoragePoolObjSourceMatchTypeDEVICE(virStoragePoolOb= jPtr pool, * VIR_STORAGE_POOL_LOGICAL * VIR_STORAGE_POOL_DISK * VIR_STORAGE_POOL_ZFS */ - return virStoragePoolSourceFindDuplicateDevices(pool, def); + return virStoragePoolSourceFindDuplicateDevices(obj, def); } =20 =20 @@ -978,30 +976,30 @@ virStoragePoolObjSourceFindDuplicate(virConnectPtr co= nn, { size_t i; int ret =3D 1; - virStoragePoolObjPtr pool =3D NULL; - virStoragePoolObjPtr matchpool =3D NULL; + virStoragePoolObjPtr obj =3D NULL; + virStoragePoolObjPtr matchobj =3D NULL; =20 /* Check the pool list for duplicate underlying storage */ for (i =3D 0; i < pools->count; i++) { - pool =3D pools->objs[i]; + obj =3D pools->objs[i]; =20 /* Don't match against ourself if re-defining existing pool ! */ - if (STREQ(pool->def->name, def->name)) + if (STREQ(obj->def->name, def->name)) continue; =20 - virStoragePoolObjLock(pool); + virStoragePoolObjLock(obj); =20 - switch ((virStoragePoolType)pool->def->type) { + switch ((virStoragePoolType)obj->def->type) { case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_GLUSTER: case VIR_STORAGE_POOL_NETFS: - if (def->type =3D=3D pool->def->type) - matchpool =3D virStoragePoolObjSourceMatchTypeDIR(pool, de= f); + if (def->type =3D=3D obj->def->type) + matchobj =3D virStoragePoolObjSourceMatchTypeDIR(obj, def); break; =20 case VIR_STORAGE_POOL_SCSI: - if (def->type =3D=3D pool->def->type) - matchpool =3D virStoragePoolObjSourceMatchTypeISCSI(pool, = def, + if (def->type =3D=3D obj->def->type) + matchobj =3D virStoragePoolObjSourceMatchTypeISCSI(obj, de= f, conn); break; =20 @@ -1015,42 +1013,42 @@ virStoragePoolObjSourceFindDuplicate(virConnectPtr = conn, def->type =3D=3D VIR_STORAGE_POOL_LOGICAL || def->type =3D=3D VIR_STORAGE_POOL_DISK || def->type =3D=3D VIR_STORAGE_POOL_ZFS) - matchpool =3D virStoragePoolObjSourceMatchTypeDEVICE(pool,= def); + matchobj =3D virStoragePoolObjSourceMatchTypeDEVICE(obj, d= ef); break; =20 case VIR_STORAGE_POOL_SHEEPDOG: - if (def->type =3D=3D pool->def->type && - virStoragePoolSourceMatchSingleHost(&pool->def->source, + if (def->type =3D=3D obj->def->type && + virStoragePoolSourceMatchSingleHost(&obj->def->source, &def->source)) - matchpool =3D pool; + matchobj =3D obj; break; =20 case VIR_STORAGE_POOL_MPATH: /* Only one mpath pool is valid per host */ - if (def->type =3D=3D pool->def->type) - matchpool =3D pool; + if (def->type =3D=3D obj->def->type) + matchobj =3D obj; break; =20 case VIR_STORAGE_POOL_VSTORAGE: - if (def->type =3D=3D pool->def->type && - STREQ(pool->def->source.name, def->source.name)) - matchpool =3D pool; + if (def->type =3D=3D obj->def->type && + STREQ(obj->def->source.name, def->source.name)) + matchobj =3D obj; break; =20 case VIR_STORAGE_POOL_RBD: case VIR_STORAGE_POOL_LAST: break; } - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); =20 - if (matchpool) + if (matchobj) break; } =20 - if (matchpool) { + if (matchobj) { virReportError(VIR_ERR_OPERATION_FAILED, _("Storage source conflict with pool: '%s'"), - matchpool->def->name); + matchobj->def->name); ret =3D -1; } return ret; @@ -1073,61 +1071,61 @@ virStoragePoolObjUnlock(virStoragePoolObjPtr obj) =20 #define MATCH(FLAG) (flags & (FLAG)) static bool -virStoragePoolMatch(virStoragePoolObjPtr poolobj, +virStoragePoolMatch(virStoragePoolObjPtr obj, unsigned int flags) { /* filter by active state */ if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) && !((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE) && - virStoragePoolObjIsActive(poolobj)) || + virStoragePoolObjIsActive(obj)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE) && - !virStoragePoolObjIsActive(poolobj)))) + !virStoragePoolObjIsActive(obj)))) return false; =20 /* filter by persistence */ if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_PERSISTENT) && !((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT) && - poolobj->configFile) || + obj->configFile) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_TRANSIENT) && - !poolobj->configFile))) + !obj->configFile))) return false; =20 /* filter by autostart option */ if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_AUTOSTART) && !((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_AUTOSTART) && - poolobj->autostart) || + obj->autostart) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_NO_AUTOSTART) && - !poolobj->autostart))) + !obj->autostart))) return false; =20 /* filter by pool type */ if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)) { if (!((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_DIR) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_DIR)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_DIR)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FS) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_FS)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_FS)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_NETFS) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_NETFS)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_NETFS)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_LOGICAL) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_LOGICAL)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_LOGICAL)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_DISK) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_DISK)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_DISK)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_ISCSI)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_ISCSI)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_SCSI) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_SCSI)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_SCSI)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_MPATH) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_MPATH)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_MPATH)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_RBD) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_RBD)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_RBD)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_SHEEPDOG)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_SHEEPDOG)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_GLUSTER)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_GLUSTER)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ZFS) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_ZFS)) || + (obj->def->type =3D=3D VIR_STORAGE_POOL_ZFS)) || (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_VSTORAGE) && - (poolobj->def->type =3D=3D VIR_STORAGE_POOL_VSTORAGE)))) + (obj->def->type =3D=3D VIR_STORAGE_POOL_VSTORAGE)))) return false; } =20 @@ -1153,23 +1151,23 @@ virStoragePoolObjListExport(virConnectPtr conn, goto cleanup; =20 for (i =3D 0; i < poolobjs->count; i++) { - virStoragePoolObjPtr poolobj =3D poolobjs->objs[i]; - virStoragePoolObjLock(poolobj); - if ((!filter || filter(conn, poolobj->def)) && - virStoragePoolMatch(poolobj, flags)) { + virStoragePoolObjPtr obj =3D poolobjs->objs[i]; + virStoragePoolObjLock(obj); + if ((!filter || filter(conn, obj->def)) && + virStoragePoolMatch(obj, flags)) { if (pools) { if (!(pool =3D virGetStoragePool(conn, - poolobj->def->name, - poolobj->def->uuid, + obj->def->name, + obj->def->uuid, NULL, NULL))) { - virStoragePoolObjUnlock(poolobj); + virStoragePoolObjUnlock(obj); goto cleanup; } tmp_pools[npools] =3D pool; } npools++; } - virStoragePoolObjUnlock(poolobj); + virStoragePoolObjUnlock(obj); } =20 if (tmp_pools) { diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index 7c11910..494b888 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -71,9 +71,9 @@ typedef bool virStoragePoolDefPtr def); =20 static inline int -virStoragePoolObjIsActive(virStoragePoolObjPtr pool) +virStoragePoolObjIsActive(virStoragePoolObjPtr obj) { - return pool->active; + return obj->active; } =20 int @@ -94,19 +94,19 @@ virStoragePoolObjFindByName(virStoragePoolObjListPtr po= ols, const char *name); =20 virStorageVolDefPtr -virStorageVolDefFindByKey(virStoragePoolObjPtr pool, +virStorageVolDefFindByKey(virStoragePoolObjPtr obj, const char *key); =20 virStorageVolDefPtr -virStorageVolDefFindByPath(virStoragePoolObjPtr pool, +virStorageVolDefFindByPath(virStoragePoolObjPtr obj, const char *path); =20 virStorageVolDefPtr -virStorageVolDefFindByName(virStoragePoolObjPtr pool, +virStorageVolDefFindByName(virStoragePoolObjPtr obj, const char *name); =20 void -virStoragePoolObjClearVols(virStoragePoolObjPtr pool); +virStoragePoolObjClearVols(virStoragePoolObjPtr obj); =20 typedef bool (*virStoragePoolVolumeACLFilter)(virConnectPtr conn, @@ -140,11 +140,11 @@ virStoragePoolObjAssignDef(virStoragePoolObjListPtr p= ools, =20 int virStoragePoolObjSaveDef(virStorageDriverStatePtr driver, - virStoragePoolObjPtr pool, + virStoragePoolObjPtr obj, virStoragePoolDefPtr def); =20 int -virStoragePoolObjDeleteDef(virStoragePoolObjPtr pool); +virStoragePoolObjDeleteDef(virStoragePoolObjPtr obj); =20 typedef bool (*virStoragePoolObjListACLFilter)(virConnectPtr conn, virStoragePoolDefPtr def); @@ -164,14 +164,14 @@ virStoragePoolObjGetNames(virStoragePoolObjListPtr po= ols, int maxnames); =20 void -virStoragePoolObjFree(virStoragePoolObjPtr pool); +virStoragePoolObjFree(virStoragePoolObjPtr obj); =20 void virStoragePoolObjListFree(virStoragePoolObjListPtr pools); =20 void virStoragePoolObjRemove(virStoragePoolObjListPtr pools, - virStoragePoolObjPtr pool); + virStoragePoolObjPtr obj); =20 int virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools, --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343854560450.33610865439437; Tue, 9 May 2017 08:30:54 -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 E7F6B4ACB3; Tue, 9 May 2017 15:30:50 +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 B859B783BD; Tue, 9 May 2017 15:30:50 +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 6038A180BAF6; Tue, 9 May 2017 15:30: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 v49FUbgX002900 for ; Tue, 9 May 2017 11:30:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8741319651; Tue, 9 May 2017 15:30:37 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA3E48AC47 for ; Tue, 9 May 2017 15:30:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E7F6B4ACB3 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E7F6B4ACB3 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:15 -0400 Message-Id: <20170509153026.19767-9-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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 consistent variable names 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.38]); Tue, 09 May 2017 15:30:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A virStoragePoolObjPtr will be an 'obj'. A virStoragePoolPtr will be a 'pool'. A virStorageVolPtr will be a 'vol'. A virStorageVolDefPtr will be a 'voldef'. Signed-off-by: John Ferlan --- src/storage/storage_driver.c | 1158 +++++++++++++++++++++-----------------= ---- src/storage/storage_driver.h | 4 +- 2 files changed, 582 insertions(+), 580 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 2103ed1..6122396 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -87,45 +87,45 @@ static void storageDriverUnlock(void) * pools are removed. */ static void -virStoragePoolUpdateInactive(virStoragePoolObjPtr *poolptr) +virStoragePoolUpdateInactive(virStoragePoolObjPtr *objptr) { - virStoragePoolObjPtr pool =3D *poolptr; + virStoragePoolObjPtr obj =3D *objptr; =20 - if (pool->configFile =3D=3D NULL) { - virStoragePoolObjRemove(&driver->pools, pool); - *poolptr =3D NULL; - } else if (pool->newDef) { - virStoragePoolDefFree(pool->def); - pool->def =3D pool->newDef; - pool->newDef =3D NULL; + if (obj->configFile =3D=3D NULL) { + virStoragePoolObjRemove(&driver->pools, obj); + *objptr =3D NULL; + } else if (obj->newDef) { + virStoragePoolDefFree(obj->def); + obj->def =3D obj->newDef; + obj->newDef =3D NULL; } } =20 =20 static void -storagePoolUpdateState(virStoragePoolObjPtr pool) +storagePoolUpdateState(virStoragePoolObjPtr obj) { bool active =3D false; virStorageBackendPtr backend; char *stateFile; =20 if (!(stateFile =3D virFileBuildPath(driver->stateDir, - pool->def->name, ".xml"))) + obj->def->name, ".xml"))) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(pool->def->type)) =3D=3D NUL= L) { + if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL= ) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing backend %d"), pool->def->type); + _("Missing backend %d"), obj->def->type); goto cleanup; } =20 /* Backends which do not support 'checkPool' are considered * inactive by default. */ if (backend->checkPool && - backend->checkPool(pool, &active) < 0) { + backend->checkPool(obj, &active) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to initialize storage pool '%s': %s"), - pool->def->name, virGetLastErrorMessage()); + obj->def->name, virGetLastErrorMessage()); active =3D false; } =20 @@ -134,21 +134,21 @@ storagePoolUpdateState(virStoragePoolObjPtr pool) * continue with other pools. */ if (active) { - virStoragePoolObjClearVols(pool); - if (backend->refreshPool(NULL, pool) < 0) { + virStoragePoolObjClearVols(obj); + if (backend->refreshPool(NULL, obj) < 0) { if (backend->stopPool) - backend->stopPool(NULL, pool); + backend->stopPool(NULL, obj); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to restart storage pool '%s': %s"), - pool->def->name, virGetLastErrorMessage()); + obj->def->name, virGetLastErrorMessage()); active =3D false; } } =20 - pool->active =3D active; + obj->active =3D active; =20 - if (!pool->active) - virStoragePoolUpdateInactive(&pool); + if (!obj->active) + virStoragePoolUpdateInactive(&obj); =20 cleanup: if (!active && stateFile) @@ -164,11 +164,11 @@ storagePoolUpdateAllState(void) size_t i; =20 for (i =3D 0; i < driver->pools.count; i++) { - virStoragePoolObjPtr pool =3D driver->pools.objs[i]; + virStoragePoolObjPtr obj =3D driver->pools.objs[i]; =20 - virStoragePoolObjLock(pool); - storagePoolUpdateState(pool); - virStoragePoolObjUnlock(pool); + virStoragePoolObjLock(obj); + storagePoolUpdateState(obj); + virStoragePoolObjUnlock(obj); } } =20 @@ -186,24 +186,24 @@ storageDriverAutostart(void) /* Ignoring NULL conn - let backends decide */ =20 for (i =3D 0; i < driver->pools.count; i++) { - virStoragePoolObjPtr pool =3D driver->pools.objs[i]; + virStoragePoolObjPtr obj =3D driver->pools.objs[i]; virStorageBackendPtr backend; bool started =3D false; =20 - virStoragePoolObjLock(pool); - if ((backend =3D virStorageBackendForType(pool->def->type)) =3D=3D= NULL) { - virStoragePoolObjUnlock(pool); + virStoragePoolObjLock(obj); + if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D = NULL) { + virStoragePoolObjUnlock(obj); continue; } =20 - if (pool->autostart && - !virStoragePoolObjIsActive(pool)) { + if (obj->autostart && + !virStoragePoolObjIsActive(obj)) { if (backend->startPool && - backend->startPool(conn, pool) < 0) { + backend->startPool(conn, obj) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart storage pool '%s': %= s"), - pool->def->name, virGetLastErrorMessage()); - virStoragePoolObjUnlock(pool); + obj->def->name, virGetLastErrorMessage()); + virStoragePoolObjUnlock(obj); continue; } started =3D true; @@ -212,25 +212,25 @@ storageDriverAutostart(void) if (started) { char *stateFile; =20 - virStoragePoolObjClearVols(pool); + virStoragePoolObjClearVols(obj); stateFile =3D virFileBuildPath(driver->stateDir, - pool->def->name, ".xml"); + obj->def->name, ".xml"); if (!stateFile || - virStoragePoolSaveState(stateFile, pool->def) < 0 || - backend->refreshPool(conn, pool) < 0) { + virStoragePoolSaveState(stateFile, obj->def) < 0 || + backend->refreshPool(conn, obj) < 0) { if (stateFile) unlink(stateFile); if (backend->stopPool) - backend->stopPool(conn, pool); + backend->stopPool(conn, obj); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart storage pool '%s': %= s"), - pool->def->name, virGetLastErrorMessage()); + obj->def->name, virGetLastErrorMessage()); } else { - pool->active =3D true; + obj->active =3D true; } VIR_FREE(stateFile); } - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); } =20 virObjectUnref(conn); @@ -391,10 +391,10 @@ static virStoragePoolObjPtr storagePoolObjFindByUUID(const unsigned char *uuid, const char *name) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 - if (!(pool =3D virStoragePoolObjFindByUUID(&driver->pools, uuid))) { + if (!(obj =3D virStoragePoolObjFindByUUID(&driver->pools, uuid))) { virUUIDFormat(uuid, uuidstr); if (name) virReportError(VIR_ERR_NO_STORAGE_POOL, @@ -406,7 +406,7 @@ storagePoolObjFindByUUID(const unsigned char *uuid, uuidstr); } =20 - return pool; + return obj; } =20 =20 @@ -426,15 +426,15 @@ virStoragePoolObjFromStoragePool(virStoragePoolPtr po= ol) static virStoragePoolObjPtr storagePoolObjFindByName(const char *name) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; =20 storageDriverLock(); - if (!(pool =3D virStoragePoolObjFindByName(&driver->pools, name))) + if (!(obj =3D virStoragePoolObjFindByName(&driver->pools, name))) virReportError(VIR_ERR_NO_STORAGE_POOL, _("no storage pool with matching name '%s'"), name); storageDriverUnlock(); =20 - return pool; + return obj; } =20 =20 @@ -442,65 +442,63 @@ static virStoragePoolPtr storagePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { - virStoragePoolObjPtr pool; - virStoragePoolPtr ret =3D NULL; + virStoragePoolObjPtr obj; + virStoragePoolPtr pool =3D NULL; =20 storageDriverLock(); - pool =3D storagePoolObjFindByUUID(uuid, NULL); + obj =3D storagePoolObjFindByUUID(uuid, NULL); storageDriverUnlock(); - if (!pool) + if (!obj) return NULL; =20 - if (virStoragePoolLookupByUUIDEnsureACL(conn, pool->def) < 0) + if (virStoragePoolLookupByUUIDEnsureACL(conn, obj->def) < 0) goto cleanup; =20 - ret =3D virGetStoragePool(conn, pool->def->name, pool->def->uuid, - NULL, NULL); + pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); =20 cleanup: - virStoragePoolObjUnlock(pool); - return ret; + virStoragePoolObjUnlock(obj); + return pool; } =20 static virStoragePoolPtr storagePoolLookupByName(virConnectPtr conn, const char *name) { - virStoragePoolObjPtr pool; - virStoragePoolPtr ret =3D NULL; + virStoragePoolObjPtr obj; + virStoragePoolPtr pool =3D NULL; =20 - if (!(pool =3D storagePoolObjFindByName(name))) + if (!(obj =3D storagePoolObjFindByName(name))) return NULL; =20 - if (virStoragePoolLookupByNameEnsureACL(conn, pool->def) < 0) + if (virStoragePoolLookupByNameEnsureACL(conn, obj->def) < 0) goto cleanup; =20 - ret =3D virGetStoragePool(conn, pool->def->name, pool->def->uuid, - NULL, NULL); + pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); =20 cleanup: - virStoragePoolObjUnlock(pool); - return ret; + virStoragePoolObjUnlock(obj); + return pool; } =20 static virStoragePoolPtr storagePoolLookupByVolume(virStorageVolPtr vol) { - virStoragePoolObjPtr pool; - virStoragePoolPtr ret =3D NULL; + virStoragePoolObjPtr obj; + virStoragePoolPtr pool =3D NULL; =20 - if (!(pool =3D storagePoolObjFindByName(vol->pool))) + if (!(obj =3D storagePoolObjFindByName(vol->pool))) return NULL; =20 - if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, pool->def) < 0) + if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, obj->def) < 0) goto cleanup; =20 - ret =3D virGetStoragePool(vol->conn, pool->def->name, pool->def->uuid, - NULL, NULL); + pool =3D virGetStoragePool(vol->conn, obj->def->name, obj->def->uuid, + NULL, NULL); =20 cleanup: - virStoragePoolObjUnlock(pool); - return ret; + virStoragePoolObjUnlock(obj); + return pool; } =20 static int @@ -613,7 +611,8 @@ storageConnectFindStoragePoolSources(virConnectPtr conn, } =20 =20 -static int storagePoolIsActive(virStoragePoolPtr pool) +static int +storagePoolIsActive(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; int ret =3D -1; @@ -631,7 +630,9 @@ static int storagePoolIsActive(virStoragePoolPtr pool) return ret; } =20 -static int storagePoolIsPersistent(virStoragePoolPtr pool) + +static int +storagePoolIsPersistent(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; int ret =3D -1; @@ -656,8 +657,8 @@ storagePoolCreateXML(virConnectPtr conn, unsigned int flags) { virStoragePoolDefPtr def; - virStoragePoolObjPtr pool =3D NULL; - virStoragePoolPtr ret =3D NULL; + virStoragePoolObjPtr obj =3D NULL; + virStoragePoolPtr pool =3D NULL; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; char *stateFile =3D NULL; @@ -686,7 +687,7 @@ storagePoolCreateXML(virConnectPtr conn, if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 - if (!(pool =3D virStoragePoolObjAssignDef(&driver->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, def))) goto cleanup; def =3D NULL; =20 @@ -698,56 +699,55 @@ storagePoolCreateXML(virConnectPtr conn, =20 if (build_flags || (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) { - if (backend->buildPool(conn, pool, build_flags) < 0) { - virStoragePoolObjRemove(&driver->pools, pool); - pool =3D NULL; + if (backend->buildPool(conn, obj, build_flags) < 0) { + virStoragePoolObjRemove(&driver->pools, obj); + obj =3D NULL; goto cleanup; } } } =20 if (backend->startPool && - backend->startPool(conn, pool) < 0) { - virStoragePoolObjRemove(&driver->pools, pool); - pool =3D NULL; + backend->startPool(conn, obj) < 0) { + virStoragePoolObjRemove(&driver->pools, obj); + obj =3D NULL; goto cleanup; } =20 stateFile =3D virFileBuildPath(driver->stateDir, - pool->def->name, ".xml"); + obj->def->name, ".xml"); =20 - virStoragePoolObjClearVols(pool); - if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 || - backend->refreshPool(conn, pool) < 0) { + virStoragePoolObjClearVols(obj); + if (!stateFile || virStoragePoolSaveState(stateFile, obj->def) < 0 || + backend->refreshPool(conn, obj) < 0) { if (stateFile) unlink(stateFile); if (backend->stopPool) - backend->stopPool(conn, pool); - virStoragePoolObjRemove(&driver->pools, pool); - pool =3D NULL; + backend->stopPool(conn, obj); + virStoragePoolObjRemove(&driver->pools, obj); + obj =3D NULL; goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(pool->def->name, - pool->def->uuid, + event =3D virStoragePoolEventLifecycleNew(obj->def->name, + obj->def->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 - VIR_INFO("Creating storage pool '%s'", pool->def->name); - pool->active =3D true; + VIR_INFO("Creating storage pool '%s'", obj->def->name); + obj->active =3D true; =20 - ret =3D virGetStoragePool(conn, pool->def->name, pool->def->uuid, - NULL, NULL); + pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); =20 cleanup: VIR_FREE(stateFile); virStoragePoolDefFree(def); if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); storageDriverUnlock(); - return ret; + return pool; } =20 static virStoragePoolPtr @@ -756,8 +756,8 @@ storagePoolDefineXML(virConnectPtr conn, unsigned int flags) { virStoragePoolDefPtr def; - virStoragePoolObjPtr pool =3D NULL; - virStoragePoolPtr ret =3D NULL; + virStoragePoolObjPtr obj =3D NULL; + virStoragePoolPtr pool =3D NULL; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, NULL); @@ -781,13 +781,13 @@ storagePoolDefineXML(virConnectPtr conn, if (virStorageBackendForType(def->type) =3D=3D NULL) goto cleanup; =20 - if (!(pool =3D virStoragePoolObjAssignDef(&driver->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, def))) goto cleanup; =20 - if (virStoragePoolObjSaveDef(driver, pool, def) < 0) { - virStoragePoolObjRemove(&driver->pools, pool); + if (virStoragePoolObjSaveDef(driver, obj, def) < 0) { + virStoragePoolObjRemove(&driver->pools, obj); def =3D NULL; - pool =3D NULL; + obj =3D NULL; goto cleanup; } =20 @@ -797,86 +797,85 @@ storagePoolDefineXML(virConnectPtr conn, =20 def =3D NULL; =20 - VIR_INFO("Defining storage pool '%s'", pool->def->name); - ret =3D virGetStoragePool(conn, pool->def->name, pool->def->uuid, - NULL, NULL); + VIR_INFO("Defining storage pool '%s'", obj->def->name); + pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); =20 cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); virStoragePoolDefFree(def); - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); storageDriverUnlock(); - return ret; + return pool; } =20 static int -storagePoolUndefine(virStoragePoolPtr obj) +storagePoolUndefine(virStoragePoolPtr pool) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virObjectEventPtr event =3D NULL; int ret =3D -1; =20 storageDriverLock(); - if (!(pool =3D storagePoolObjFindByUUID(obj->uuid, obj->name))) + if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; =20 - if (virStoragePoolUndefineEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolUndefineEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if (virStoragePoolObjIsActive(pool)) { + if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is still active"), - pool->def->name); + obj->def->name); goto cleanup; } =20 - if (pool->asyncjobs > 0) { + if (obj->asyncjobs > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - pool->def->name); + obj->def->name); goto cleanup; } =20 - if (virStoragePoolObjDeleteDef(pool) < 0) + if (virStoragePoolObjDeleteDef(obj) < 0) goto cleanup; =20 - if (unlink(pool->autostartLink) < 0 && + if (unlink(obj->autostartLink) < 0 && errno !=3D ENOENT && errno !=3D ENOTDIR) { char ebuf[1024]; VIR_ERROR(_("Failed to delete autostart link '%s': %s"), - pool->autostartLink, virStrerror(errno, ebuf, sizeof(ebu= f))); + obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf= ))); } =20 - VIR_FREE(pool->configFile); - VIR_FREE(pool->autostartLink); + VIR_FREE(obj->configFile); + VIR_FREE(obj->autostartLink); =20 - event =3D virStoragePoolEventLifecycleNew(pool->def->name, - pool->def->uuid, + event =3D virStoragePoolEventLifecycleNew(obj->def->name, + obj->def->uuid, VIR_STORAGE_POOL_EVENT_UNDEFIN= ED, 0); =20 - VIR_INFO("Undefining storage pool '%s'", pool->def->name); - virStoragePoolObjRemove(&driver->pools, pool); - pool =3D NULL; + VIR_INFO("Undefining storage pool '%s'", obj->def->name); + virStoragePoolObjRemove(&driver->pools, obj); + obj =3D NULL; ret =3D 0; =20 cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); storageDriverUnlock(); return ret; } =20 static int -storagePoolCreate(virStoragePoolPtr obj, +storagePoolCreate(virStoragePoolPtr pool, unsigned int flags) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; int ret =3D -1; @@ -890,19 +889,19 @@ storagePoolCreate(virStoragePoolPtr obj, VIR_EXCLUSIVE_FLAGS_RET(VIR_STORAGE_POOL_BUILD_OVERWRITE, VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, -1); =20 - if (!(pool =3D virStoragePoolObjFromStoragePool(obj))) + if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; =20 - if (virStoragePoolCreateEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolCreateEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(pool->def->type)) =3D=3D NUL= L) + if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) goto cleanup; =20 - if (virStoragePoolObjIsActive(pool)) { + if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is already active"), - pool->def->name); + obj->def->name); goto cleanup; } =20 @@ -914,117 +913,117 @@ storagePoolCreate(virStoragePoolPtr obj, =20 if (build_flags || (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) { - if (backend->buildPool(obj->conn, pool, build_flags) < 0) + if (backend->buildPool(pool->conn, obj, build_flags) < 0) goto cleanup; } } =20 - VIR_INFO("Starting up storage pool '%s'", pool->def->name); + VIR_INFO("Starting up storage pool '%s'", obj->def->name); if (backend->startPool && - backend->startPool(obj->conn, pool) < 0) + backend->startPool(pool->conn, obj) < 0) goto cleanup; =20 stateFile =3D virFileBuildPath(driver->stateDir, - pool->def->name, ".xml"); + obj->def->name, ".xml"); =20 - virStoragePoolObjClearVols(pool); - if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 || - backend->refreshPool(obj->conn, pool) < 0) { + virStoragePoolObjClearVols(obj); + if (!stateFile || virStoragePoolSaveState(stateFile, obj->def) < 0 || + backend->refreshPool(pool->conn, obj) < 0) { if (stateFile) unlink(stateFile); if (backend->stopPool) - backend->stopPool(obj->conn, pool); + backend->stopPool(pool->conn, obj); goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(pool->def->name, - pool->def->uuid, + event =3D virStoragePoolEventLifecycleNew(obj->def->name, + obj->def->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 - pool->active =3D true; + obj->active =3D true; ret =3D 0; =20 cleanup: VIR_FREE(stateFile); if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); return ret; } =20 static int -storagePoolBuild(virStoragePoolPtr obj, +storagePoolBuild(virStoragePoolPtr pool, unsigned int flags) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStorageBackendPtr backend; int ret =3D -1; =20 - if (!(pool =3D virStoragePoolObjFromStoragePool(obj))) + if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; =20 - if (virStoragePoolBuildEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolBuildEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(pool->def->type)) =3D=3D NUL= L) + if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) goto cleanup; =20 - if (virStoragePoolObjIsActive(pool)) { + if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is already active"), - pool->def->name); + obj->def->name); goto cleanup; } =20 if (backend->buildPool && - backend->buildPool(obj->conn, pool, flags) < 0) + backend->buildPool(pool->conn, obj, flags) < 0) goto cleanup; ret =3D 0; =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); return ret; } =20 =20 static int -storagePoolDestroy(virStoragePoolPtr obj) +storagePoolDestroy(virStoragePoolPtr pool) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; char *stateFile =3D NULL; int ret =3D -1; =20 storageDriverLock(); - if (!(pool =3D storagePoolObjFindByUUID(obj->uuid, obj->name))) + if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; =20 - if (virStoragePoolDestroyEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolDestroyEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(pool->def->type)) =3D=3D NUL= L) + if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) goto cleanup; =20 - VIR_INFO("Destroying storage pool '%s'", pool->def->name); + VIR_INFO("Destroying storage pool '%s'", obj->def->name); =20 - if (!virStoragePoolObjIsActive(pool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->def->na= me); + _("storage pool '%s' is not active"), obj->def->nam= e); goto cleanup; } =20 - if (pool->asyncjobs > 0) { + if (obj->asyncjobs > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - pool->def->name); + obj->def->name); goto cleanup; } =20 if (!(stateFile =3D virFileBuildPath(driver->stateDir, - pool->def->name, + obj->def->name, ".xml"))) goto cleanup; =20 @@ -1032,67 +1031,67 @@ storagePoolDestroy(virStoragePoolPtr obj) VIR_FREE(stateFile); =20 if (backend->stopPool && - backend->stopPool(obj->conn, pool) < 0) + backend->stopPool(pool->conn, obj) < 0) goto cleanup; =20 - virStoragePoolObjClearVols(pool); + virStoragePoolObjClearVols(obj); =20 - event =3D virStoragePoolEventLifecycleNew(pool->def->name, - pool->def->uuid, + event =3D virStoragePoolEventLifecycleNew(obj->def->name, + obj->def->uuid, VIR_STORAGE_POOL_EVENT_STOPPED, 0); =20 - pool->active =3D false; + obj->active =3D false; =20 - virStoragePoolUpdateInactive(&pool); + virStoragePoolUpdateInactive(&obj); =20 ret =3D 0; =20 cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); storageDriverUnlock(); return ret; } =20 static int -storagePoolDelete(virStoragePoolPtr obj, +storagePoolDelete(virStoragePoolPtr pool, unsigned int flags) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStorageBackendPtr backend; char *stateFile =3D NULL; int ret =3D -1; =20 - if (!(pool =3D virStoragePoolObjFromStoragePool(obj))) + if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; =20 - if (virStoragePoolDeleteEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolDeleteEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(pool->def->type)) =3D=3D NUL= L) + if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) goto cleanup; =20 - VIR_INFO("Deleting storage pool '%s'", pool->def->name); + VIR_INFO("Deleting storage pool '%s'", obj->def->name); =20 - if (virStoragePoolObjIsActive(pool)) { + if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is still active"), - pool->def->name); + obj->def->name); goto cleanup; } =20 - if (pool->asyncjobs > 0) { + if (obj->asyncjobs > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - pool->def->name); + obj->def->name); goto cleanup; } =20 if (!(stateFile =3D virFileBuildPath(driver->stateDir, - pool->def->name, + obj->def->name, ".xml"))) goto cleanup; =20 @@ -1104,22 +1103,22 @@ storagePoolDelete(virStoragePoolPtr obj, "%s", _("pool does not support pool deletion")); goto cleanup; } - if (backend->deletePool(obj->conn, pool, flags) < 0) + if (backend->deletePool(pool->conn, obj, flags) < 0) goto cleanup; =20 ret =3D 0; =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); return ret; } =20 =20 static int -storagePoolRefresh(virStoragePoolPtr obj, +storagePoolRefresh(virStoragePoolPtr pool, unsigned int flags) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStorageBackendPtr backend; int ret =3D -1; virObjectEventPtr event =3D NULL; @@ -1127,165 +1126,165 @@ storagePoolRefresh(virStoragePoolPtr obj, virCheckFlags(0, -1); =20 storageDriverLock(); - if (!(pool =3D storagePoolObjFindByUUID(obj->uuid, obj->name))) + if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; =20 - if (virStoragePoolRefreshEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolRefreshEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(pool->def->type)) =3D=3D NUL= L) + if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) goto cleanup; =20 - if (!virStoragePoolObjIsActive(pool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->def->na= me); + _("storage pool '%s' is not active"), obj->def->nam= e); goto cleanup; } =20 - if (pool->asyncjobs > 0) { + if (obj->asyncjobs > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - pool->def->name); + obj->def->name); goto cleanup; } =20 - virStoragePoolObjClearVols(pool); - if (backend->refreshPool(obj->conn, pool) < 0) { + virStoragePoolObjClearVols(obj); + if (backend->refreshPool(pool->conn, obj) < 0) { if (backend->stopPool) - backend->stopPool(obj->conn, pool); + backend->stopPool(pool->conn, obj); =20 - event =3D virStoragePoolEventLifecycleNew(pool->def->name, - pool->def->uuid, + event =3D virStoragePoolEventLifecycleNew(obj->def->name, + obj->def->uuid, VIR_STORAGE_POOL_EVENT_STO= PPED, 0); - pool->active =3D false; + obj->active =3D false; =20 - virStoragePoolUpdateInactive(&pool); + virStoragePoolUpdateInactive(&obj); =20 goto cleanup; } =20 - event =3D virStoragePoolEventRefreshNew(pool->def->name, - pool->def->uuid); + event =3D virStoragePoolEventRefreshNew(obj->def->name, + obj->def->uuid); ret =3D 0; =20 cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); storageDriverUnlock(); return ret; } =20 =20 static int -storagePoolGetInfo(virStoragePoolPtr obj, +storagePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; int ret =3D -1; =20 - if (!(pool =3D virStoragePoolObjFromStoragePool(obj))) + if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; =20 - if (virStoragePoolGetInfoEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolGetInfoEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if (virStorageBackendForType(pool->def->type) =3D=3D NULL) + if (virStorageBackendForType(obj->def->type) =3D=3D NULL) goto cleanup; =20 memset(info, 0, sizeof(virStoragePoolInfo)); - if (pool->active) + if (obj->active) info->state =3D VIR_STORAGE_POOL_RUNNING; else info->state =3D VIR_STORAGE_POOL_INACTIVE; - info->capacity =3D pool->def->capacity; - info->allocation =3D pool->def->allocation; - info->available =3D pool->def->available; + info->capacity =3D obj->def->capacity; + info->allocation =3D obj->def->allocation; + info->available =3D obj->def->available; ret =3D 0; =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); return ret; } =20 static char * -storagePoolGetXMLDesc(virStoragePoolPtr obj, +storagePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStoragePoolDefPtr def; char *ret =3D NULL; =20 virCheckFlags(VIR_STORAGE_XML_INACTIVE, NULL); =20 - if (!(pool =3D virStoragePoolObjFromStoragePool(obj))) + if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return NULL; =20 - if (virStoragePoolGetXMLDescEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolGetXMLDescEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if ((flags & VIR_STORAGE_XML_INACTIVE) && pool->newDef) - def =3D pool->newDef; + if ((flags & VIR_STORAGE_XML_INACTIVE) && obj->newDef) + def =3D obj->newDef; else - def =3D pool->def; + def =3D obj->def; =20 ret =3D virStoragePoolDefFormat(def); =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); return ret; } =20 static int -storagePoolGetAutostart(virStoragePoolPtr obj, +storagePoolGetAutostart(virStoragePoolPtr pool, int *autostart) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; int ret =3D -1; =20 - if (!(pool =3D virStoragePoolObjFromStoragePool(obj))) + if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; =20 - if (virStoragePoolGetAutostartEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolGetAutostartEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if (!pool->configFile) { + if (!obj->configFile) { *autostart =3D 0; } else { - *autostart =3D pool->autostart; + *autostart =3D obj->autostart; } + ret =3D 0; =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); return ret; } =20 static int -storagePoolSetAutostart(virStoragePoolPtr obj, +storagePoolSetAutostart(virStoragePoolPtr pool, int autostart) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; int ret =3D -1; =20 storageDriverLock(); - if (!(pool =3D storagePoolObjFindByUUID(obj->uuid, obj->name))) + if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; =20 - if (virStoragePoolSetAutostartEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolSetAutostartEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if (!pool->configFile) { + if (!obj->configFile) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("pool has no config file")); - goto cleanup; } =20 autostart =3D (autostart !=3D 0); =20 - if (pool->autostart !=3D autostart) { + if (obj->autostart !=3D autostart) { if (autostart) { if (virFileMakePath(driver->autostartDir) < 0) { virReportSystemError(errno, @@ -1294,85 +1293,86 @@ storagePoolSetAutostart(virStoragePoolPtr obj, goto cleanup; } =20 - if (symlink(pool->configFile, pool->autostartLink) < 0) { + if (symlink(obj->configFile, obj->autostartLink) < 0) { virReportSystemError(errno, _("Failed to create symlink '%s' to '= %s'"), - pool->autostartLink, pool->configFile= ); + obj->autostartLink, obj->configFile); goto cleanup; } } else { - if (unlink(pool->autostartLink) < 0 && + if (unlink(obj->autostartLink) < 0 && errno !=3D ENOENT && errno !=3D ENOTDIR) { virReportSystemError(errno, _("Failed to delete symlink '%s'"), - pool->autostartLink); + obj->autostartLink); goto cleanup; } } - pool->autostart =3D autostart; + obj->autostart =3D autostart; } + ret =3D 0; =20 cleanup: - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); storageDriverUnlock(); return ret; } =20 =20 static int -storagePoolNumOfVolumes(virStoragePoolPtr obj) +storagePoolNumOfVolumes(virStoragePoolPtr pool) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; int ret =3D -1; =20 - if (!(pool =3D virStoragePoolObjFromStoragePool(obj))) + if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; =20 - if (virStoragePoolNumOfVolumesEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolNumOfVolumesEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if (!virStoragePoolObjIsActive(pool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->def->na= me); + _("storage pool '%s' is not active"), obj->def->nam= e); goto cleanup; } =20 - ret =3D virStoragePoolObjNumOfVolumes(&pool->volumes, obj->conn, pool-= >def, + ret =3D virStoragePoolObjNumOfVolumes(&obj->volumes, pool->conn, obj->= def, virStoragePoolNumOfVolumesCheckACL= ); =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); return ret; } =20 =20 static int -storagePoolListVolumes(virStoragePoolPtr obj, +storagePoolListVolumes(virStoragePoolPtr pool, char **const names, int maxnames) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; int n =3D -1; =20 - if (!(pool =3D virStoragePoolObjFromStoragePool(obj))) + if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; =20 - if (virStoragePoolListVolumesEnsureACL(obj->conn, pool->def) < 0) + if (virStoragePoolListVolumesEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if (!virStoragePoolObjIsActive(pool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->def->na= me); + _("storage pool '%s' is not active"), obj->def->nam= e); goto cleanup; } =20 - n =3D virStoragePoolObjVolumeGetNames(&pool->volumes, obj->conn, pool-= >def, + n =3D virStoragePoolObjVolumeGetNames(&obj->volumes, pool->conn, obj->= def, virStoragePoolListVolumesCheckACL, names, maxnames); cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); return n; } =20 @@ -1411,40 +1411,40 @@ storagePoolListAllVolumes(virStoragePoolPtr pool, } =20 static virStorageVolPtr -storageVolLookupByName(virStoragePoolPtr obj, +storageVolLookupByName(virStoragePoolPtr pool, const char *name) { - virStoragePoolObjPtr pool; - virStorageVolDefPtr vol; - virStorageVolPtr ret =3D NULL; + virStoragePoolObjPtr obj; + virStorageVolDefPtr voldef; + virStorageVolPtr vol =3D NULL; =20 - if (!(pool =3D virStoragePoolObjFromStoragePool(obj))) + if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return NULL; =20 - if (!virStoragePoolObjIsActive(pool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->def->na= me); + _("storage pool '%s' is not active"), obj->def->nam= e); goto cleanup; } =20 - vol =3D virStorageVolDefFindByName(pool, name); + voldef =3D virStorageVolDefFindByName(obj, name); =20 - if (!vol) { + if (!voldef) { virReportError(VIR_ERR_NO_STORAGE_VOL, _("no storage vol with matching name '%s'"), name); goto cleanup; } =20 - if (virStorageVolLookupByNameEnsureACL(obj->conn, pool->def, vol) < 0) + if (virStorageVolLookupByNameEnsureACL(pool->conn, obj->def, voldef) <= 0) goto cleanup; =20 - ret =3D virGetStorageVol(obj->conn, pool->def->name, vol->name, vol->k= ey, - NULL, NULL); + vol =3D virGetStorageVol(pool->conn, obj->def->name, voldef->name, + voldef->key, NULL, NULL); =20 cleanup: - virStoragePoolObjUnlock(pool); - return ret; + virStoragePoolObjUnlock(obj); + return vol; } =20 =20 @@ -1453,39 +1453,39 @@ storageVolLookupByKey(virConnectPtr conn, const char *key) { size_t i; - virStorageVolPtr ret =3D NULL; + virStorageVolPtr vol =3D NULL; =20 storageDriverLock(); - for (i =3D 0; i < driver->pools.count && !ret; i++) { + for (i =3D 0; i < driver->pools.count && !vol; i++) { virStoragePoolObjLock(driver->pools.objs[i]); if (virStoragePoolObjIsActive(driver->pools.objs[i])) { - virStorageVolDefPtr vol =3D + virStorageVolDefPtr voldef =3D virStorageVolDefFindByKey(driver->pools.objs[i], key); =20 - if (vol) { + if (voldef) { virStoragePoolDefPtr def =3D driver->pools.objs[i]->def; - if (virStorageVolLookupByKeyEnsureACL(conn, def, vol) < 0)= { + if (virStorageVolLookupByKeyEnsureACL(conn, def, voldef) <= 0) { virStoragePoolObjUnlock(driver->pools.objs[i]); goto cleanup; } =20 - ret =3D virGetStorageVol(conn, + vol =3D virGetStorageVol(conn, def->name, - vol->name, - vol->key, + voldef->name, + voldef->key, NULL, NULL); } } virStoragePoolObjUnlock(driver->pools.objs[i]); } =20 - if (!ret) + if (!vol) virReportError(VIR_ERR_NO_STORAGE_VOL, _("no storage vol with matching key %s"), key); =20 cleanup: storageDriverUnlock(); - return ret; + return vol; } =20 static virStorageVolPtr @@ -1493,7 +1493,7 @@ storageVolLookupByPath(virConnectPtr conn, const char *path) { size_t i; - virStorageVolPtr ret =3D NULL; + virStorageVolPtr vol =3D NULL; char *cleanpath; =20 cleanpath =3D virFileSanitizePath(path); @@ -1501,19 +1501,19 @@ storageVolLookupByPath(virConnectPtr conn, return NULL; =20 storageDriverLock(); - for (i =3D 0; i < driver->pools.count && !ret; i++) { - virStoragePoolObjPtr pool =3D driver->pools.objs[i]; - virStorageVolDefPtr vol; + for (i =3D 0; i < driver->pools.count && !vol; i++) { + virStoragePoolObjPtr obj =3D driver->pools.objs[i]; + virStorageVolDefPtr voldef; char *stable_path =3D NULL; =20 - virStoragePoolObjLock(pool); + virStoragePoolObjLock(obj); =20 - if (!virStoragePoolObjIsActive(pool)) { - virStoragePoolObjUnlock(pool); + if (!virStoragePoolObjIsActive(obj)) { + virStoragePoolObjUnlock(obj); continue; } =20 - switch ((virStoragePoolType) pool->def->type) { + switch ((virStoragePoolType) obj->def->type) { case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_FS: case VIR_STORAGE_POOL_NETFS: @@ -1523,7 +1523,7 @@ storageVolLookupByPath(virConnectPtr conn, case VIR_STORAGE_POOL_SCSI: case VIR_STORAGE_POOL_MPATH: case VIR_STORAGE_POOL_VSTORAGE: - stable_path =3D virStorageBackendStablePath(pool, + stable_path =3D virStorageBackendStablePath(obj, cleanpath, false); if (stable_path =3D=3D NULL) { @@ -1531,8 +1531,8 @@ storageVolLookupByPath(virConnectPtr conn, * getting the stable path for some of the pools. */ VIR_WARN("Failed to get stable path for pool '%s'", - pool->def->name); - virStoragePoolObjUnlock(pool); + obj->def->name); + virStoragePoolObjUnlock(obj); continue; } break; @@ -1543,30 +1543,30 @@ storageVolLookupByPath(virConnectPtr conn, case VIR_STORAGE_POOL_ZFS: case VIR_STORAGE_POOL_LAST: if (VIR_STRDUP(stable_path, path) < 0) { - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); goto cleanup; } break; } =20 - vol =3D virStorageVolDefFindByPath(pool, stable_path); + voldef =3D virStorageVolDefFindByPath(obj, stable_path); VIR_FREE(stable_path); =20 - if (vol) { - if (virStorageVolLookupByPathEnsureACL(conn, pool->def, vol) <= 0) { - virStoragePoolObjUnlock(pool); + if (voldef) { + if (virStorageVolLookupByPathEnsureACL(conn, obj->def, voldef)= < 0) { + virStoragePoolObjUnlock(obj); goto cleanup; } =20 - ret =3D virGetStorageVol(conn, pool->def->name, - vol->name, vol->key, + vol =3D virGetStorageVol(conn, obj->def->name, + voldef->name, voldef->key, NULL, NULL); } =20 - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); } =20 - if (!ret) { + if (!vol) { if (STREQ(path, cleanpath)) { virReportError(VIR_ERR_NO_STORAGE_VOL, _("no storage vol with matching path '%s'"), pa= th); @@ -1580,7 +1580,7 @@ storageVolLookupByPath(virConnectPtr conn, cleanup: VIR_FREE(cleanpath); storageDriverUnlock(); - return ret; + return vol; } =20 virStoragePoolPtr @@ -1588,7 +1588,7 @@ storagePoolLookupByTargetPath(virConnectPtr conn, const char *path) { size_t i; - virStoragePoolPtr ret =3D NULL; + virStoragePoolPtr pool =3D NULL; char *cleanpath; =20 cleanpath =3D virFileSanitizePath(path); @@ -1596,49 +1596,49 @@ storagePoolLookupByTargetPath(virConnectPtr conn, return NULL; =20 storageDriverLock(); - for (i =3D 0; i < driver->pools.count && !ret; i++) { - virStoragePoolObjPtr pool =3D driver->pools.objs[i]; + for (i =3D 0; i < driver->pools.count && !pool; i++) { + virStoragePoolObjPtr obj =3D driver->pools.objs[i]; =20 - virStoragePoolObjLock(pool); + virStoragePoolObjLock(obj); =20 - if (!virStoragePoolObjIsActive(pool)) { - virStoragePoolObjUnlock(pool); + if (!virStoragePoolObjIsActive(obj)) { + virStoragePoolObjUnlock(obj); continue; } =20 - if (STREQ(path, pool->def->target.path)) { - ret =3D virGetStoragePool(conn, pool->def->name, pool->def->uu= id, - NULL, NULL); + if (STREQ(path, obj->def->target.path)) { + pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uui= d, + NULL, NULL); } =20 - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); } storageDriverUnlock(); =20 - if (!ret) { + if (!pool) { virReportError(VIR_ERR_NO_STORAGE_VOL, _("no storage pool with matching target path '%s'"), path); } =20 VIR_FREE(cleanpath); - return ret; + return pool; } =20 =20 static void -storageVolRemoveFromPool(virStoragePoolObjPtr pool, - virStorageVolDefPtr vol) +storageVolRemoveFromPool(virStoragePoolObjPtr obj, + virStorageVolDefPtr voldef) { size_t i; =20 - for (i =3D 0; i < pool->volumes.count; i++) { - if (pool->volumes.objs[i] =3D=3D vol) { + for (i =3D 0; i < obj->volumes.count; i++) { + if (obj->volumes.objs[i] =3D=3D voldef) { VIR_INFO("Deleting volume '%s' from storage pool '%s'", - vol->name, pool->def->name); - virStorageVolDefFree(vol); + voldef->name, obj->def->name); + virStorageVolDefFree(voldef); =20 - VIR_DELETE_ELEMENT(pool->volumes.objs, i, pool->volumes.count); + VIR_DELETE_ELEMENT(obj->volumes.objs, i, obj->volumes.count); break; } } @@ -1646,10 +1646,10 @@ storageVolRemoveFromPool(virStoragePoolObjPtr pool, =20 =20 static int -storageVolDeleteInternal(virStorageVolPtr obj, +storageVolDeleteInternal(virStorageVolPtr vol, virStorageBackendPtr backend, - virStoragePoolObjPtr pool, - virStorageVolDefPtr vol, + virStoragePoolObjPtr obj, + virStorageVolDefPtr voldef, unsigned int flags, bool updateMeta) { @@ -1662,7 +1662,7 @@ storageVolDeleteInternal(virStorageVolPtr obj, goto cleanup; } =20 - if (backend->deleteVol(obj->conn, pool, vol, flags) < 0) + if (backend->deleteVol(vol->conn, obj, voldef, flags) < 0) goto cleanup; =20 /* Update pool metadata - don't update meta data from error paths @@ -1670,13 +1670,13 @@ storageVolDeleteInternal(virStorageVolPtr obj, * Ignore the disk backend since it updates the pool values. */ if (updateMeta) { - if (pool->def->type !=3D VIR_STORAGE_POOL_DISK) { - pool->def->allocation -=3D vol->target.allocation; - pool->def->available +=3D vol->target.allocation; + if (obj->def->type !=3D VIR_STORAGE_POOL_DISK) { + obj->def->allocation -=3D voldef->target.allocation; + obj->def->available +=3D voldef->target.allocation; } } =20 - storageVolRemoveFromPool(pool, vol); + storageVolRemoveFromPool(obj, voldef); ret =3D 0; =20 cleanup: @@ -1685,109 +1685,109 @@ storageVolDeleteInternal(virStorageVolPtr obj, =20 =20 static virStorageVolDefPtr -virStorageVolDefFromVol(virStorageVolPtr obj, - virStoragePoolObjPtr *pool, +virStorageVolDefFromVol(virStorageVolPtr vol, + virStoragePoolObjPtr *obj, virStorageBackendPtr *backend) { - virStorageVolDefPtr vol =3D NULL; + virStorageVolDefPtr voldef =3D NULL; =20 - if (!(*pool =3D storagePoolObjFindByName(obj->pool))) + if (!(*obj =3D storagePoolObjFindByName(vol->pool))) return NULL; =20 - if (!virStoragePoolObjIsActive(*pool)) { + if (!virStoragePoolObjIsActive(*obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), - (*pool)->def->name); + (*obj)->def->name); goto error; } =20 - if (!(vol =3D virStorageVolDefFindByName(*pool, obj->name))) { + if (!(voldef =3D virStorageVolDefFindByName(*obj, vol->name))) { virReportError(VIR_ERR_NO_STORAGE_VOL, _("no storage vol with matching name '%s'"), - obj->name); + vol->name); goto error; } =20 if (backend) { - if (!(*backend =3D virStorageBackendForType((*pool)->def->type))) + if (!(*backend =3D virStorageBackendForType((*obj)->def->type))) goto error; } =20 - return vol; + return voldef; =20 error: - virStoragePoolObjUnlock(*pool); - *pool =3D NULL; + virStoragePoolObjUnlock(*obj); + *obj =3D NULL; =20 return NULL; } =20 =20 static int -storageVolDelete(virStorageVolPtr obj, +storageVolDelete(virStorageVolPtr vol, unsigned int flags) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStorageBackendPtr backend; - virStorageVolDefPtr vol =3D NULL; + virStorageVolDefPtr voldef =3D NULL; int ret =3D -1; =20 - if (!(vol =3D virStorageVolDefFromVol(obj, &pool, &backend))) + if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; =20 - if (virStorageVolDeleteEnsureACL(obj->conn, pool->def, vol) < 0) + if (virStorageVolDeleteEnsureACL(vol->conn, obj->def, voldef) < 0) goto cleanup; =20 - if (vol->in_use) { + if (voldef->in_use) { virReportError(VIR_ERR_OPERATION_INVALID, _("volume '%s' is still in use."), - vol->name); + voldef->name); goto cleanup; } =20 - if (vol->building) { + if (voldef->building) { virReportError(VIR_ERR_OPERATION_INVALID, _("volume '%s' is still being allocated."), - vol->name); + voldef->name); goto cleanup; } =20 - if (storageVolDeleteInternal(obj, backend, pool, vol, flags, true) < 0) + if (storageVolDeleteInternal(vol, backend, obj, voldef, flags, true) <= 0) goto cleanup; =20 ret =3D 0; =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); return ret; } =20 =20 static virStorageVolPtr -storageVolCreateXML(virStoragePoolPtr obj, +storageVolCreateXML(virStoragePoolPtr pool, const char *xmldesc, unsigned int flags) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStorageBackendPtr backend; virStorageVolDefPtr voldef =3D NULL; - virStorageVolPtr ret =3D NULL, volobj =3D NULL; + virStorageVolPtr vol =3D NULL, volobj =3D NULL; =20 virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL); =20 - if (!(pool =3D virStoragePoolObjFromStoragePool(obj))) + if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return NULL; =20 - if (!virStoragePoolObjIsActive(pool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->def->na= me); + _("storage pool '%s' is not active"), obj->def->nam= e); goto cleanup; } =20 - if ((backend =3D virStorageBackendForType(pool->def->type)) =3D=3D NUL= L) + if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) goto cleanup; =20 - voldef =3D virStorageVolDefParseString(pool->def, xmldesc, + voldef =3D virStorageVolDefParseString(obj->def, xmldesc, VIR_VOL_XML_PARSE_OPT_CAPACITY); if (voldef =3D=3D NULL) goto cleanup; @@ -1799,10 +1799,10 @@ storageVolCreateXML(virStoragePoolPtr obj, goto cleanup; } =20 - if (virStorageVolCreateXMLEnsureACL(obj->conn, pool->def, voldef) < 0) + if (virStorageVolCreateXMLEnsureACL(pool->conn, obj->def, voldef) < 0) goto cleanup; =20 - if (virStorageVolDefFindByName(pool, voldef->name)) { + if (virStorageVolDefFindByName(obj, voldef->name)) { virReportError(VIR_ERR_STORAGE_VOL_EXIST, _("'%s'"), voldef->name); goto cleanup; @@ -1815,21 +1815,21 @@ storageVolCreateXML(virStoragePoolPtr obj, goto cleanup; } =20 - if (VIR_REALLOC_N(pool->volumes.objs, - pool->volumes.count+1) < 0) + if (VIR_REALLOC_N(obj->volumes.objs, + obj->volumes.count + 1) < 0) goto cleanup; =20 /* Wipe any key the user may have suggested, as volume creation * will generate the canonical key. */ VIR_FREE(voldef->key); - if (backend->createVol(obj->conn, pool, voldef) < 0) + if (backend->createVol(pool->conn, obj, voldef) < 0) goto cleanup; =20 - pool->volumes.objs[pool->volumes.count++] =3D voldef; - volobj =3D virGetStorageVol(obj->conn, pool->def->name, voldef->name, + obj->volumes.objs[obj->volumes.count++] =3D voldef; + volobj =3D virGetStorageVol(pool->conn, obj->def->name, voldef->name, voldef->key, NULL, NULL); if (!volobj) { - pool->volumes.count--; + obj->volumes.count--; goto cleanup; } =20 @@ -1850,24 +1850,24 @@ storageVolCreateXML(virStoragePoolPtr obj, memcpy(buildvoldef, voldef, sizeof(*voldef)); =20 /* Drop the pool lock during volume allocation */ - pool->asyncjobs++; + obj->asyncjobs++; voldef->building =3D true; - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); =20 - buildret =3D backend->buildVol(obj->conn, pool, buildvoldef, flags= ); + buildret =3D backend->buildVol(pool->conn, obj, buildvoldef, flags= ); =20 VIR_FREE(buildvoldef); =20 storageDriverLock(); - virStoragePoolObjLock(pool); + virStoragePoolObjLock(obj); storageDriverUnlock(); =20 voldef->building =3D false; - pool->asyncjobs--; + obj->asyncjobs--; =20 if (buildret < 0) { /* buildVol handles deleting volume on failure */ - storageVolRemoveFromPool(pool, voldef); + storageVolRemoveFromPool(obj, voldef); voldef =3D NULL; goto cleanup; } @@ -1875,8 +1875,8 @@ storageVolCreateXML(virStoragePoolPtr obj, } =20 if (backend->refreshVol && - backend->refreshVol(obj->conn, pool, voldef) < 0) { - storageVolDeleteInternal(volobj, backend, pool, voldef, + backend->refreshVol(pool->conn, obj, voldef) < 0) { + storageVolDeleteInternal(volobj, backend, obj, voldef, 0, false); voldef =3D NULL; goto cleanup; @@ -1885,35 +1885,39 @@ storageVolCreateXML(virStoragePoolPtr obj, /* Update pool metadata ignoring the disk backend since * it updates the pool values. */ - if (pool->def->type !=3D VIR_STORAGE_POOL_DISK) { - pool->def->allocation +=3D voldef->target.allocation; - pool->def->available -=3D voldef->target.allocation; + if (obj->def->type !=3D VIR_STORAGE_POOL_DISK) { + obj->def->allocation +=3D voldef->target.allocation; + obj->def->available -=3D voldef->target.allocation; } =20 VIR_INFO("Creating volume '%s' in storage pool '%s'", - volobj->name, pool->def->name); - ret =3D volobj; + volobj->name, obj->def->name); + vol =3D volobj; volobj =3D NULL; voldef =3D NULL; =20 cleanup: virObjectUnref(volobj); virStorageVolDefFree(voldef); - if (pool) - virStoragePoolObjUnlock(pool); - return ret; + if (obj) + virStoragePoolObjUnlock(obj); + return vol; } =20 static virStorageVolPtr -storageVolCreateXMLFrom(virStoragePoolPtr obj, +storageVolCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc, - virStorageVolPtr vobj, + virStorageVolPtr volsrc, unsigned int flags) { - virStoragePoolObjPtr pool, origpool =3D NULL; + virStoragePoolObjPtr obj; + virStoragePoolObjPtr objsrc =3D NULL; virStorageBackendPtr backend; - virStorageVolDefPtr origvol =3D NULL, newvol =3D NULL, shadowvol =3D N= ULL; - virStorageVolPtr ret =3D NULL, volobj =3D NULL; + virStorageVolDefPtr voldefsrc =3D NULL; + virStorageVolDefPtr voldef =3D NULL; + virStorageVolDefPtr shadowvol =3D NULL; + virStorageVolPtr volobj =3D NULL; + virStorageVolPtr vol =3D NULL; int buildret; =20 virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA | @@ -1921,80 +1925,80 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj, NULL); =20 storageDriverLock(); - pool =3D virStoragePoolObjFindByUUID(&driver->pools, obj->uuid); - if (pool && STRNEQ(obj->name, vobj->pool)) { - virStoragePoolObjUnlock(pool); - origpool =3D virStoragePoolObjFindByName(&driver->pools, vobj->poo= l); - virStoragePoolObjLock(pool); + obj =3D virStoragePoolObjFindByUUID(&driver->pools, pool->uuid); + if (obj && STRNEQ(pool->name, volsrc->pool)) { + virStoragePoolObjUnlock(obj); + objsrc =3D virStoragePoolObjFindByName(&driver->pools, volsrc->poo= l); + virStoragePoolObjLock(obj); } storageDriverUnlock(); - if (!pool) { + if (!obj) { char uuidstr[VIR_UUID_STRING_BUFLEN]; - virUUIDFormat(obj->uuid, uuidstr); + virUUIDFormat(pool->uuid, uuidstr); virReportError(VIR_ERR_NO_STORAGE_POOL, _("no storage pool with matching uuid '%s' (%s)"), - uuidstr, obj->name); + uuidstr, pool->name); goto cleanup; } =20 - if (STRNEQ(obj->name, vobj->pool) && !origpool) { + if (STRNEQ(pool->name, volsrc->pool) && !objsrc) { virReportError(VIR_ERR_NO_STORAGE_POOL, _("no storage pool with matching name '%s'"), - vobj->pool); + volsrc->pool); goto cleanup; } =20 - if (!virStoragePoolObjIsActive(pool)) { + if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), pool->def->na= me); + _("storage pool '%s' is not active"), obj->def->nam= e); goto cleanup; } =20 - if (origpool && !virStoragePoolObjIsActive(origpool)) { + if (objsrc && !virStoragePoolObjIsActive(objsrc)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), - origpool->def->name); + objsrc->def->name); goto cleanup; } =20 - if ((backend =3D virStorageBackendForType(pool->def->type)) =3D=3D NUL= L) + if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) goto cleanup; =20 - origvol =3D virStorageVolDefFindByName(origpool ? - origpool : pool, vobj->name); - if (!origvol) { + voldefsrc =3D virStorageVolDefFindByName(objsrc ? + objsrc : obj, volsrc->name); + if (!voldefsrc) { virReportError(VIR_ERR_NO_STORAGE_VOL, _("no storage vol with matching name '%s'"), - vobj->name); + volsrc->name); goto cleanup; } =20 - newvol =3D virStorageVolDefParseString(pool->def, xmldesc, + voldef =3D virStorageVolDefParseString(obj->def, xmldesc, VIR_VOL_XML_PARSE_NO_CAPACITY); - if (newvol =3D=3D NULL) + if (voldef =3D=3D NULL) goto cleanup; =20 - if (virStorageVolCreateXMLFromEnsureACL(obj->conn, pool->def, newvol) = < 0) + if (virStorageVolCreateXMLFromEnsureACL(pool->conn, obj->def, voldef) = < 0) goto cleanup; =20 - if (virStorageVolDefFindByName(pool, newvol->name)) { + if (virStorageVolDefFindByName(obj, voldef->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("storage volume name '%s' already in use."), - newvol->name); + voldef->name); goto cleanup; } =20 /* Use the original volume's capacity in case the new capacity * is less than that, or it was omitted */ - if (newvol->target.capacity < origvol->target.capacity) - newvol->target.capacity =3D origvol->target.capacity; + if (voldef->target.capacity < voldefsrc->target.capacity) + voldef->target.capacity =3D voldefsrc->target.capacity; =20 /* If the allocation was not provided in the XML, then use capacity * as it's specifically documented "If omitted when creating a volume, * the volume will be fully allocated at time of creation.". This * is especially important for logical volume creation. */ - if (!newvol->target.has_allocation) - newvol->target.allocation =3D newvol->target.capacity; + if (!voldef->target.has_allocation) + voldef->target.allocation =3D voldef->target.capacity; =20 if (!backend->buildVolFrom) { virReportError(VIR_ERR_NO_SUPPORT, @@ -2003,26 +2007,25 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj, goto cleanup; } =20 - if (origvol->building) { + if (voldefsrc->building) { virReportError(VIR_ERR_OPERATION_INVALID, _("volume '%s' is still being allocated."), - origvol->name); + voldefsrc->name); goto cleanup; } =20 if (backend->refreshVol && - backend->refreshVol(obj->conn, pool, origvol) < 0) + backend->refreshVol(pool->conn, obj, voldefsrc) < 0) goto cleanup; =20 - if (VIR_REALLOC_N(pool->volumes.objs, - pool->volumes.count+1) < 0) + if (VIR_REALLOC_N(obj->volumes.objs, obj->volumes.count + 1) < 0) goto cleanup; =20 /* 'Define' the new volume so we get async progress reporting. * Wipe any key the user may have suggested, as volume creation * will generate the canonical key. */ - VIR_FREE(newvol->key); - if (backend->createVol(obj->conn, pool, newvol) < 0) + VIR_FREE(voldef->key); + if (backend->createVol(pool->conn, obj, voldef) < 0) goto cleanup; =20 /* Make a shallow copy of the 'defined' volume definition, since the @@ -2032,103 +2035,103 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj, if (VIR_ALLOC(shadowvol) < 0) goto cleanup; =20 - memcpy(shadowvol, newvol, sizeof(*newvol)); + memcpy(shadowvol, voldef, sizeof(*voldef)); =20 - pool->volumes.objs[pool->volumes.count++] =3D newvol; - volobj =3D virGetStorageVol(obj->conn, pool->def->name, newvol->name, - newvol->key, NULL, NULL); + obj->volumes.objs[obj->volumes.count++] =3D voldef; + volobj =3D virGetStorageVol(pool->conn, obj->def->name, voldef->name, + voldef->key, NULL, NULL); if (!volobj) { - pool->volumes.count--; + obj->volumes.count--; goto cleanup; } =20 /* Drop the pool lock during volume allocation */ - pool->asyncjobs++; - newvol->building =3D true; - origvol->in_use++; - virStoragePoolObjUnlock(pool); + obj->asyncjobs++; + voldef->building =3D true; + voldefsrc->in_use++; + virStoragePoolObjUnlock(obj); =20 - if (origpool) { - origpool->asyncjobs++; - virStoragePoolObjUnlock(origpool); + if (objsrc) { + objsrc->asyncjobs++; + virStoragePoolObjUnlock(objsrc); } =20 - buildret =3D backend->buildVolFrom(obj->conn, pool, shadowvol, origvol= , flags); + buildret =3D backend->buildVolFrom(pool->conn, obj, shadowvol, voldefs= rc, flags); =20 storageDriverLock(); - virStoragePoolObjLock(pool); - if (origpool) - virStoragePoolObjLock(origpool); + virStoragePoolObjLock(obj); + if (objsrc) + virStoragePoolObjLock(objsrc); storageDriverUnlock(); =20 - origvol->in_use--; - newvol->building =3D false; - pool->asyncjobs--; + voldefsrc->in_use--; + voldef->building =3D false; + obj->asyncjobs--; =20 - if (origpool) { - origpool->asyncjobs--; - virStoragePoolObjUnlock(origpool); - origpool =3D NULL; + if (objsrc) { + objsrc->asyncjobs--; + virStoragePoolObjUnlock(objsrc); + objsrc =3D NULL; } =20 if (buildret < 0 || (backend->refreshVol && - backend->refreshVol(obj->conn, pool, newvol) < 0)) { - storageVolDeleteInternal(volobj, backend, pool, newvol, 0, false); - newvol =3D NULL; + backend->refreshVol(pool->conn, obj, voldef) < 0)) { + storageVolDeleteInternal(volobj, backend, obj, voldef, 0, false); + voldef =3D NULL; goto cleanup; } =20 /* Updating pool metadata ignoring the disk backend since * it updates the pool values */ - if (pool->def->type !=3D VIR_STORAGE_POOL_DISK) { - pool->def->allocation +=3D newvol->target.allocation; - pool->def->available -=3D newvol->target.allocation; + if (obj->def->type !=3D VIR_STORAGE_POOL_DISK) { + obj->def->allocation +=3D voldef->target.allocation; + obj->def->available -=3D voldef->target.allocation; } =20 VIR_INFO("Creating volume '%s' in storage pool '%s'", - volobj->name, pool->def->name); - ret =3D volobj; + volobj->name, obj->def->name); + vol =3D volobj; volobj =3D NULL; - newvol =3D NULL; + voldef =3D NULL; =20 cleanup: virObjectUnref(volobj); - virStorageVolDefFree(newvol); + virStorageVolDefFree(voldef); VIR_FREE(shadowvol); - if (pool) - virStoragePoolObjUnlock(pool); - if (origpool) - virStoragePoolObjUnlock(origpool); - return ret; + if (obj) + virStoragePoolObjUnlock(obj); + if (objsrc) + virStoragePoolObjUnlock(objsrc); + return vol; } =20 =20 static int -storageVolDownload(virStorageVolPtr obj, +storageVolDownload(virStorageVolPtr vol, virStreamPtr stream, unsigned long long offset, unsigned long long length, unsigned int flags) { virStorageBackendPtr backend; - virStoragePoolObjPtr pool =3D NULL; - virStorageVolDefPtr vol =3D NULL; + virStoragePoolObjPtr obj =3D NULL; + virStorageVolDefPtr voldef =3D NULL; int ret =3D -1; =20 virCheckFlags(0, -1); =20 - if (!(vol =3D virStorageVolDefFromVol(obj, &pool, &backend))) + if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; =20 - if (virStorageVolDownloadEnsureACL(obj->conn, pool->def, vol) < 0) + if (virStorageVolDownloadEnsureACL(vol->conn, obj->def, voldef) < 0) goto cleanup; =20 - if (vol->building) { + if (voldef->building) { virReportError(VIR_ERR_OPERATION_INVALID, _("volume '%s' is still being allocated."), - vol->name); + voldef->name); goto cleanup; } =20 @@ -2138,11 +2141,11 @@ storageVolDownload(virStorageVolPtr obj, goto cleanup; } =20 - ret =3D backend->downloadVol(obj->conn, pool, vol, stream, + ret =3D backend->downloadVol(vol->conn, obj, voldef, stream, offset, length, flags); =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); =20 return ret; } @@ -2215,7 +2218,7 @@ virStorageVolPoolRefreshThread(void *opaque) { =20 virStorageVolStreamInfoPtr cbdata =3D opaque; - virStoragePoolObjPtr pool =3D NULL; + virStoragePoolObjPtr obj =3D NULL; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; =20 @@ -2224,25 +2227,25 @@ virStorageVolPoolRefreshThread(void *opaque) if (virStorageBackendPloopRestoreDesc(cbdata->vol_path) < 0) goto cleanup; } - if (!(pool =3D virStoragePoolObjFindByName(&driver->pools, - cbdata->pool_name))) + if (!(obj =3D virStoragePoolObjFindByName(&driver->pools, + cbdata->pool_name))) goto cleanup; =20 - if (!(backend =3D virStorageBackendForType(pool->def->type))) + if (!(backend =3D virStorageBackendForType(obj->def->type))) goto cleanup; =20 - virStoragePoolObjClearVols(pool); - if (backend->refreshPool(NULL, pool) < 0) + virStoragePoolObjClearVols(obj); + if (backend->refreshPool(NULL, obj) < 0) VIR_DEBUG("Failed to refresh storage pool"); =20 - event =3D virStoragePoolEventRefreshNew(pool->def->name, - pool->def->uuid); + event =3D virStoragePoolEventRefreshNew(obj->def->name, + obj->def->uuid); =20 cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (pool) - virStoragePoolObjUnlock(pool); + if (obj) + virStoragePoolObjUnlock(obj); storageDriverUnlock(); virStorageVolPoolRefreshDataFree(cbdata); } @@ -2273,37 +2276,37 @@ virStorageVolFDStreamCloseCb(virStreamPtr st ATTRIB= UTE_UNUSED, } =20 static int -storageVolUpload(virStorageVolPtr obj, +storageVolUpload(virStorageVolPtr vol, virStreamPtr stream, unsigned long long offset, unsigned long long length, unsigned int flags) { virStorageBackendPtr backend; - virStoragePoolObjPtr pool =3D NULL; - virStorageVolDefPtr vol =3D NULL; + virStoragePoolObjPtr obj =3D NULL; + virStorageVolDefPtr voldef =3D NULL; virStorageVolStreamInfoPtr cbdata =3D NULL; int ret =3D -1; =20 virCheckFlags(0, -1); =20 - if (!(vol =3D virStorageVolDefFromVol(obj, &pool, &backend))) + if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; =20 - if (virStorageVolUploadEnsureACL(obj->conn, pool->def, vol) < 0) + if (virStorageVolUploadEnsureACL(vol->conn, obj->def, voldef) < 0) goto cleanup; =20 - if (vol->in_use) { + if (voldef->in_use) { virReportError(VIR_ERR_OPERATION_INVALID, _("volume '%s' is still in use."), - vol->name); + voldef->name); goto cleanup; } =20 - if (vol->building) { + if (voldef->building) { virReportError(VIR_ERR_OPERATION_INVALID, _("volume '%s' is still being allocated."), - vol->name); + voldef->name); goto cleanup; } =20 @@ -2320,13 +2323,13 @@ storageVolUpload(virStorageVolPtr obj, * routine in order to call the refresh API. */ if (VIR_ALLOC(cbdata) < 0 || - VIR_STRDUP(cbdata->pool_name, pool->def->name) < 0) + VIR_STRDUP(cbdata->pool_name, obj->def->name) < 0) goto cleanup; - if (vol->type =3D=3D VIR_STORAGE_VOL_PLOOP && - VIR_STRDUP(cbdata->vol_path, vol->target.path) < 0) + if (voldef->type =3D=3D VIR_STORAGE_VOL_PLOOP && + VIR_STRDUP(cbdata->vol_path, voldef->target.path) < 0) goto cleanup; =20 - if ((ret =3D backend->uploadVol(obj->conn, pool, vol, stream, + if ((ret =3D backend->uploadVol(vol->conn, obj, voldef, stream, offset, length, flags)) < 0) goto cleanup; =20 @@ -2339,7 +2342,7 @@ storageVolUpload(virStorageVolPtr obj, cbdata =3D NULL; =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); if (cbdata) virStorageVolPoolRefreshDataFree(cbdata); =20 @@ -2347,13 +2350,13 @@ storageVolUpload(virStorageVolPtr obj, } =20 static int -storageVolResize(virStorageVolPtr obj, +storageVolResize(virStorageVolPtr vol, unsigned long long capacity, unsigned int flags) { virStorageBackendPtr backend; - virStoragePoolObjPtr pool =3D NULL; - virStorageVolDefPtr vol =3D NULL; + virStoragePoolObjPtr obj =3D NULL; + virStorageVolDefPtr voldef =3D NULL; unsigned long long abs_capacity, delta =3D 0; int ret =3D -1; =20 @@ -2361,44 +2364,44 @@ storageVolResize(virStorageVolPtr obj, VIR_STORAGE_VOL_RESIZE_DELTA | VIR_STORAGE_VOL_RESIZE_SHRINK, -1); =20 - if (!(vol =3D virStorageVolDefFromVol(obj, &pool, &backend))) + if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; =20 - if (virStorageVolResizeEnsureACL(obj->conn, pool->def, vol) < 0) + if (virStorageVolResizeEnsureACL(vol->conn, obj->def, voldef) < 0) goto cleanup; =20 - if (vol->in_use) { + if (voldef->in_use) { virReportError(VIR_ERR_OPERATION_INVALID, _("volume '%s' is still in use."), - vol->name); + voldef->name); goto cleanup; } =20 - if (vol->building) { + if (voldef->building) { virReportError(VIR_ERR_OPERATION_INVALID, _("volume '%s' is still being allocated."), - vol->name); + voldef->name); goto cleanup; } =20 if (flags & VIR_STORAGE_VOL_RESIZE_DELTA) { if (flags & VIR_STORAGE_VOL_RESIZE_SHRINK) - abs_capacity =3D vol->target.capacity - MIN(capacity, vol->tar= get.capacity); + abs_capacity =3D voldef->target.capacity - MIN(capacity, volde= f->target.capacity); else - abs_capacity =3D vol->target.capacity + capacity; + abs_capacity =3D voldef->target.capacity + capacity; flags &=3D ~VIR_STORAGE_VOL_RESIZE_DELTA; } else { abs_capacity =3D capacity; } =20 - if (abs_capacity < vol->target.allocation) { + if (abs_capacity < voldef->target.allocation) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("can't shrink capacity below " "existing allocation")); goto cleanup; } =20 - if (abs_capacity < vol->target.capacity && + if (abs_capacity < voldef->target.capacity && !(flags & VIR_STORAGE_VOL_RESIZE_SHRINK)) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("Can't shrink capacity below current " @@ -2407,9 +2410,9 @@ storageVolResize(virStorageVolPtr obj, } =20 if (flags & VIR_STORAGE_VOL_RESIZE_ALLOCATE) - delta =3D abs_capacity - vol->target.allocation; + delta =3D abs_capacity - voldef->target.allocation; =20 - if (delta > pool->def->available) { + if (delta > obj->def->available) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("Not enough space left in storage pool")); goto cleanup; @@ -2422,37 +2425,37 @@ storageVolResize(virStorageVolPtr obj, goto cleanup; } =20 - if (backend->resizeVol(obj->conn, pool, vol, abs_capacity, flags) < 0) + if (backend->resizeVol(vol->conn, obj, voldef, abs_capacity, flags) < = 0) goto cleanup; =20 - vol->target.capacity =3D abs_capacity; + voldef->target.capacity =3D abs_capacity; /* Only update the allocation and pool values if we actually did the * allocation; otherwise, this is akin to a create operation with a * capacity value different and potentially much larger than available */ if (flags & VIR_STORAGE_VOL_RESIZE_ALLOCATE) { - vol->target.allocation =3D abs_capacity; - pool->def->allocation +=3D delta; - pool->def->available -=3D delta; + voldef->target.allocation =3D abs_capacity; + obj->def->allocation +=3D delta; + obj->def->available -=3D delta; } =20 ret =3D 0; =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); =20 return ret; } =20 =20 static int -storageVolWipePattern(virStorageVolPtr obj, +storageVolWipePattern(virStorageVolPtr vol, unsigned int algorithm, unsigned int flags) { virStorageBackendPtr backend; - virStoragePoolObjPtr pool =3D NULL; - virStorageVolDefPtr vol =3D NULL; + virStoragePoolObjPtr obj =3D NULL; + virStorageVolDefPtr voldef =3D NULL; int ret =3D -1; =20 virCheckFlags(0, -1); @@ -2464,24 +2467,23 @@ storageVolWipePattern(virStorageVolPtr obj, return -1; } =20 - if (!(vol =3D virStorageVolDefFromVol(obj, &pool, &backend))) + if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; =20 - - if (virStorageVolWipePatternEnsureACL(obj->conn, pool->def, vol) < 0) + if (virStorageVolWipePatternEnsureACL(vol->conn, obj->def, voldef) < 0) goto cleanup; =20 - if (vol->in_use) { + if (voldef->in_use) { virReportError(VIR_ERR_OPERATION_INVALID, _("volume '%s' is still in use."), - vol->name); + voldef->name); goto cleanup; } =20 - if (vol->building) { + if (voldef->building) { virReportError(VIR_ERR_OPERATION_INVALID, _("volume '%s' is still being allocated."), - vol->name); + voldef->name); goto cleanup; } =20 @@ -2491,120 +2493,120 @@ storageVolWipePattern(virStorageVolPtr obj, goto cleanup; } =20 - if (backend->wipeVol(obj->conn, pool, vol, algorithm, flags) < 0) + if (backend->wipeVol(vol->conn, obj, voldef, algorithm, flags) < 0) goto cleanup; =20 if (backend->refreshVol && - backend->refreshVol(obj->conn, pool, vol) < 0) + backend->refreshVol(vol->conn, obj, voldef) < 0) goto cleanup; =20 ret =3D 0; =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); =20 return ret; } =20 static int -storageVolWipe(virStorageVolPtr obj, +storageVolWipe(virStorageVolPtr vol, unsigned int flags) { - return storageVolWipePattern(obj, VIR_STORAGE_VOL_WIPE_ALG_ZERO, flags= ); + return storageVolWipePattern(vol, VIR_STORAGE_VOL_WIPE_ALG_ZERO, flags= ); } =20 =20 static int -storageVolGetInfoFlags(virStorageVolPtr obj, +storageVolGetInfoFlags(virStorageVolPtr vol, virStorageVolInfoPtr info, unsigned int flags) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStorageBackendPtr backend; - virStorageVolDefPtr vol; + virStorageVolDefPtr voldef; int ret =3D -1; =20 virCheckFlags(VIR_STORAGE_VOL_GET_PHYSICAL, -1); =20 - if (!(vol =3D virStorageVolDefFromVol(obj, &pool, &backend))) + if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return -1; =20 - if (virStorageVolGetInfoFlagsEnsureACL(obj->conn, pool->def, vol) < 0) + if (virStorageVolGetInfoFlagsEnsureACL(vol->conn, obj->def, voldef) < = 0) goto cleanup; =20 if (backend->refreshVol && - backend->refreshVol(obj->conn, pool, vol) < 0) + backend->refreshVol(vol->conn, obj, voldef) < 0) goto cleanup; =20 memset(info, 0, sizeof(*info)); - info->type =3D vol->type; - info->capacity =3D vol->target.capacity; + info->type =3D voldef->type; + info->capacity =3D voldef->target.capacity; if (flags & VIR_STORAGE_VOL_GET_PHYSICAL) - info->allocation =3D vol->target.physical; + info->allocation =3D voldef->target.physical; else - info->allocation =3D vol->target.allocation; + info->allocation =3D voldef->target.allocation; ret =3D 0; =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); return ret; } =20 =20 static int -storageVolGetInfo(virStorageVolPtr obj, +storageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info) { - return storageVolGetInfoFlags(obj, info, 0); + return storageVolGetInfoFlags(vol, info, 0); } =20 =20 static char * -storageVolGetXMLDesc(virStorageVolPtr obj, +storageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; virStorageBackendPtr backend; - virStorageVolDefPtr vol; + virStorageVolDefPtr voldef; char *ret =3D NULL; =20 virCheckFlags(0, NULL); =20 - if (!(vol =3D virStorageVolDefFromVol(obj, &pool, &backend))) + if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, &backend))) return NULL; =20 - if (virStorageVolGetXMLDescEnsureACL(obj->conn, pool->def, vol) < 0) + if (virStorageVolGetXMLDescEnsureACL(vol->conn, obj->def, voldef) < 0) goto cleanup; =20 if (backend->refreshVol && - backend->refreshVol(obj->conn, pool, vol) < 0) + backend->refreshVol(vol->conn, obj, voldef) < 0) goto cleanup; =20 - ret =3D virStorageVolDefFormat(pool->def, vol); + ret =3D virStorageVolDefFormat(obj->def, voldef); =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); =20 return ret; } =20 static char * -storageVolGetPath(virStorageVolPtr obj) +storageVolGetPath(virStorageVolPtr vol) { - virStoragePoolObjPtr pool; - virStorageVolDefPtr vol; + virStoragePoolObjPtr obj; + virStorageVolDefPtr voldef; char *ret =3D NULL; =20 - if (!(vol =3D virStorageVolDefFromVol(obj, &pool, NULL))) + if (!(voldef =3D virStorageVolDefFromVol(vol, &obj, NULL))) return NULL; =20 - if (virStorageVolGetPathEnsureACL(obj->conn, pool->def, vol) < 0) + if (virStorageVolGetPathEnsureACL(vol->conn, obj->def, voldef) < 0) goto cleanup; =20 - ignore_value(VIR_STRDUP(ret, vol->target.path)); + ignore_value(VIR_STRDUP(ret, voldef->target.path)); =20 cleanup: - virStoragePoolObjUnlock(pool); + virStoragePoolObjUnlock(obj); return ret; } =20 @@ -3531,18 +3533,18 @@ virStorageTranslateDiskSourcePool(virConnectPtr con= n, virStoragePoolObjPtr virStoragePoolObjFindPoolByUUID(const unsigned char *uuid) { - virStoragePoolObjPtr pool; + virStoragePoolObjPtr obj; =20 storageDriverLock(); - pool =3D virStoragePoolObjFindByUUID(&driver->pools, uuid); + obj =3D virStoragePoolObjFindByUUID(&driver->pools, uuid); storageDriverUnlock(); - return pool; + return obj; } =20 =20 /* * virStoragePoolObjBuildTempFilePath - * @pool: pool object pointer + * @obj: pool object pointer * @vol: volume definition * * Generate a name for a temporary file using the driver stateDir @@ -3552,13 +3554,13 @@ virStoragePoolObjFindPoolByUUID(const unsigned char= *uuid) * Returns a string pointer on success, NULL on failure */ char * -virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr pool, - virStorageVolDefPtr vol) +virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr obj, + virStorageVolDefPtr voldef) =20 { char *tmp =3D NULL; =20 ignore_value(virAsprintf(&tmp, "%s/%s.%s.secret.XXXXXX", - driver->stateDir, pool->def->name, vol->name)= ); + driver->stateDir, obj->def->name, voldef->nam= e)); return tmp; } diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h index 530bc33..67aaa82 100644 --- a/src/storage/storage_driver.h +++ b/src/storage/storage_driver.h @@ -65,8 +65,8 @@ storagePoolLookupByTargetPath(virConnectPtr conn, const char *path) ATTRIBUTE_NONNULL(2); =20 -char *virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr pool, - virStorageVolDefPtr vol) +char *virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr obj, + virStorageVolDefPtr voldef) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; =20 int storageRegister(void); --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343856290397.89690186556516; Tue, 9 May 2017 08:30:56 -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 67E0A7F4A1; Tue, 9 May 2017 15:30:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3F1E58AC49; Tue, 9 May 2017 15:30: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 E0C82180BAF6; Tue, 9 May 2017 15:30:52 +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 v49FUb4D002905 for ; Tue, 9 May 2017 11:30:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id E5D368AC43; Tue, 9 May 2017 15:30:37 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6CFD19651 for ; Tue, 9 May 2017 15:30:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 67E0A7F4A1 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 67E0A7F4A1 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:16 -0400 Message-Id: <20170509153026.19767-10-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Alter volume num, name, and export API's to just take obj 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, 09 May 2017 15:30:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Alter the virStoragePoolObjNumOfVolumes, virStoragePoolObjVolumeGetNames, and virStoragePoolObjVolumeListExport APIs to take a virStoragePoolObjPtr instead of the &obj->volumes and obj->def. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 15 +++++++++------ src/conf/virstorageobj.h | 9 +++------ src/storage/storage_driver.c | 7 +++---- src/test/test_driver.c | 9 +++------ 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 74a9c67..23346f3 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -196,11 +196,12 @@ virStorageVolDefFindByName(virStoragePoolObjPtr obj, =20 =20 int -virStoragePoolObjNumOfVolumes(virStorageVolDefListPtr volumes, +virStoragePoolObjNumOfVolumes(virStoragePoolObjPtr obj, virConnectPtr conn, - virStoragePoolDefPtr pooldef, virStoragePoolVolumeACLFilter aclfilter) { + virStoragePoolDefPtr pooldef =3D obj->def; + virStorageVolDefListPtr volumes =3D &obj->volumes; int nvolumes =3D 0; size_t i; =20 @@ -216,13 +217,14 @@ virStoragePoolObjNumOfVolumes(virStorageVolDefListPtr= volumes, =20 =20 int -virStoragePoolObjVolumeGetNames(virStorageVolDefListPtr volumes, +virStoragePoolObjVolumeGetNames(virStoragePoolObjPtr obj, virConnectPtr conn, - virStoragePoolDefPtr pooldef, virStoragePoolVolumeACLFilter aclfilter, char **const names, int maxnames) { + virStoragePoolDefPtr pooldef =3D obj->def; + virStorageVolDefListPtr volumes =3D &obj->volumes; int nnames =3D 0; size_t i; =20 @@ -247,11 +249,12 @@ virStoragePoolObjVolumeGetNames(virStorageVolDefListP= tr volumes, =20 int virStoragePoolObjVolumeListExport(virConnectPtr conn, - virStorageVolDefListPtr volumes, - virStoragePoolDefPtr pooldef, + virStoragePoolObjPtr obj, virStorageVolPtr **vols, virStoragePoolVolumeACLFilter aclfilter) { + virStoragePoolDefPtr pooldef =3D obj->def; + virStorageVolDefListPtr volumes =3D &obj->volumes; int ret =3D -1; size_t i; virStorageVolPtr *tmp_vols =3D NULL; diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index 494b888..5a61b2a 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -114,23 +114,20 @@ typedef bool virStorageVolDefPtr def); =20 int -virStoragePoolObjNumOfVolumes(virStorageVolDefListPtr volumes, +virStoragePoolObjNumOfVolumes(virStoragePoolObjPtr obj, virConnectPtr conn, - virStoragePoolDefPtr pooldef, virStoragePoolVolumeACLFilter aclfilter); =20 int -virStoragePoolObjVolumeGetNames(virStorageVolDefListPtr volumes, +virStoragePoolObjVolumeGetNames(virStoragePoolObjPtr obj, virConnectPtr conn, - virStoragePoolDefPtr pooldef, virStoragePoolVolumeACLFilter aclfilter, char **const names, int maxnames); =20 int virStoragePoolObjVolumeListExport(virConnectPtr conn, - virStorageVolDefListPtr volumes, - virStoragePoolDefPtr pooldef, + virStoragePoolObjPtr obj, virStorageVolPtr **vols, virStoragePoolVolumeACLFilter aclfilter); =20 diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 6122396..6289314 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1339,7 +1339,7 @@ storagePoolNumOfVolumes(virStoragePoolPtr pool) goto cleanup; } =20 - ret =3D virStoragePoolObjNumOfVolumes(&obj->volumes, pool->conn, obj->= def, + ret =3D virStoragePoolObjNumOfVolumes(obj, pool->conn, virStoragePoolNumOfVolumesCheckACL= ); =20 cleanup: @@ -1368,7 +1368,7 @@ storagePoolListVolumes(virStoragePoolPtr pool, goto cleanup; } =20 - n =3D virStoragePoolObjVolumeGetNames(&obj->volumes, pool->conn, obj->= def, + n =3D virStoragePoolObjVolumeGetNames(obj, pool->conn, virStoragePoolListVolumesCheckACL, names, maxnames); cleanup: @@ -1399,8 +1399,7 @@ storagePoolListAllVolumes(virStoragePoolPtr pool, goto cleanup; } =20 - ret =3D virStoragePoolObjVolumeListExport(pool->conn, &obj->volumes, - obj->def, vols, + ret =3D virStoragePoolObjVolumeListExport(pool->conn, obj, vols, virStoragePoolListAllVolumesCh= eckACL); =20 =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 8d03bdb..68f1412 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4738,8 +4738,7 @@ testStoragePoolNumOfVolumes(virStoragePoolPtr pool) if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) return -1; =20 - ret =3D virStoragePoolObjNumOfVolumes(&obj->volumes, pool->conn, - obj->def, NULL); + ret =3D virStoragePoolObjNumOfVolumes(obj, pool->conn, NULL); =20 virStoragePoolObjUnlock(obj); return ret; @@ -4758,8 +4757,7 @@ testStoragePoolListVolumes(virStoragePoolPtr pool, if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) return -1; =20 - n =3D virStoragePoolObjVolumeGetNames(&obj->volumes, pool->conn, - obj->def, NULL, names, maxnames); + n =3D virStoragePoolObjVolumeGetNames(obj, pool->conn, NULL, names, ma= xnames); =20 virStoragePoolObjUnlock(obj); return n; @@ -4786,8 +4784,7 @@ testStoragePoolListAllVolumes(virStoragePoolPtr pool, goto cleanup; } =20 - ret =3D virStoragePoolObjVolumeListExport(pool->conn, &obj->volumes, - obj->def, vols, NULL); + ret =3D virStoragePoolObjVolumeListExport(pool->conn, obj, vols, NULL); =20 cleanup: virStoragePoolObjUnlock(obj); --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343885345789.0522893564832; Tue, 9 May 2017 08:31:25 -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 8EE784E8AB; Tue, 9 May 2017 15:31:23 +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 6485A7DEDD; Tue, 9 May 2017 15:31:23 +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 5CACB1800C8A; Tue, 9 May 2017 15:30:57 +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 v49FUce7002910 for ; Tue, 9 May 2017 11:30:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 598F68AC43; Tue, 9 May 2017 15:30:38 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A23A19651 for ; Tue, 9 May 2017 15:30:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8EE784E8AB 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8EE784E8AB From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:17 -0400 Message-Id: <20170509153026.19767-11-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Create accessor API's for virStoragePoolObj X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 09 May 2017 15:31:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In preparation for making a private object, create accessor API's for consumer storage functions to use: virStoragePoolObjGetDef virStoragePoolObjGetNewDef virStoragePoolObjStealNewDef virStoragePoolObjGetConfigFile virStoragePoolObjSetConfigFile virStoragePoolObjIsActive virStoragePoolObjSetActive virStoragePoolObjGetAsyncjobs virStoragePoolObjIncrAsyncjobs virStoragePoolObjDecrAsyncjobs Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 74 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/conf/virstorageobj.h | 36 +++++++++++++++++++---- src/libvirt_private.syms | 10 +++++++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 23346f3..7d6b311 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -37,6 +37,80 @@ VIR_LOG_INIT("conf.virstorageobj"); =20 =20 +virStoragePoolDefPtr +virStoragePoolObjGetDef(virStoragePoolObjPtr obj) +{ + return obj->def; +} + + +virStoragePoolDefPtr +virStoragePoolObjGetNewDef(virStoragePoolObjPtr obj) +{ + return obj->newDef; +} + + +void +virStoragePoolObjStealNewDef(virStoragePoolObjPtr obj) +{ + virStoragePoolDefFree(obj->def); + obj->def =3D obj->newDef; + obj->newDef =3D NULL; +} + + +char * +virStoragePoolObjGetConfigFile(virStoragePoolObjPtr obj) +{ + return obj->configFile; +} + + +void +virStoragePoolObjSetConfigFile(virStoragePoolObjPtr obj, + char *configFile) +{ + obj->configFile =3D configFile; +} + + +bool +virStoragePoolObjIsActive(virStoragePoolObjPtr obj) +{ + return obj->active; +} + + +void +virStoragePoolObjSetActive(virStoragePoolObjPtr obj, + bool active) +{ + obj->active =3D active; +} + + +unsigned int +virStoragePoolObjGetAsyncjobs(virStoragePoolObjPtr obj) +{ + return obj->asyncjobs; +} + + +void +virStoragePoolObjIncrAsyncjobs(virStoragePoolObjPtr obj) +{ + obj->asyncjobs++; +} + + +void +virStoragePoolObjDecrAsyncjobs(virStoragePoolObjPtr obj) +{ + obj->asyncjobs--; +} + + void virStoragePoolObjFree(virStoragePoolObjPtr obj) { diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index 5a61b2a..d47b233 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -70,11 +70,37 @@ typedef bool (*virStoragePoolObjListFilter)(virConnectPtr conn, virStoragePoolDefPtr def); =20 -static inline int -virStoragePoolObjIsActive(virStoragePoolObjPtr obj) -{ - return obj->active; -} +virStoragePoolDefPtr +virStoragePoolObjGetDef(virStoragePoolObjPtr obj); + +virStoragePoolDefPtr +virStoragePoolObjGetNewDef(virStoragePoolObjPtr obj); + +void +virStoragePoolObjStealNewDef(virStoragePoolObjPtr obj); + +char * +virStoragePoolObjGetConfigFile(virStoragePoolObjPtr obj); + +void +virStoragePoolObjSetConfigFile(virStoragePoolObjPtr obj, + char *configFile); + +bool +virStoragePoolObjIsActive(virStoragePoolObjPtr obj); + +void +virStoragePoolObjSetActive(virStoragePoolObjPtr obj, + bool active); + +unsigned int +virStoragePoolObjGetAsyncjobs(virStoragePoolObjPtr obj); + +void +virStoragePoolObjIncrAsyncjobs(virStoragePoolObjPtr obj); + +void +virStoragePoolObjDecrAsyncjobs(virStoragePoolObjPtr obj); =20 int virStoragePoolObjLoadAllConfigs(virStoragePoolObjListPtr pools, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4cca0ca..edd3174 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1009,10 +1009,17 @@ virSecretObjSetValueSize; # conf/virstorageobj.h virStoragePoolObjAssignDef; virStoragePoolObjClearVols; +virStoragePoolObjDecrAsyncjobs; virStoragePoolObjDeleteDef; virStoragePoolObjFindByName; virStoragePoolObjFindByUUID; +virStoragePoolObjGetAsyncjobs; +virStoragePoolObjGetConfigFile; +virStoragePoolObjGetDef; virStoragePoolObjGetNames; +virStoragePoolObjGetNewDef; +virStoragePoolObjIncrAsyncjobs; +virStoragePoolObjIsActive; virStoragePoolObjIsDuplicate; virStoragePoolObjListExport; virStoragePoolObjListFree; @@ -1023,7 +1030,10 @@ virStoragePoolObjNumOfStoragePools; virStoragePoolObjNumOfVolumes; virStoragePoolObjRemove; virStoragePoolObjSaveDef; +virStoragePoolObjSetActive; +virStoragePoolObjSetConfigFile; virStoragePoolObjSourceFindDuplicate; +virStoragePoolObjStealNewDef; virStoragePoolObjUnlock; virStoragePoolObjVolumeGetNames; virStoragePoolObjVolumeListExport; --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343863930964.1562812203775; Tue, 9 May 2017 08:31:03 -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 5640CC05490A; Tue, 9 May 2017 15:31:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D579783C5; Tue, 9 May 2017 15:31: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 098F25EC76; Tue, 9 May 2017 15:31:00 +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 v49FUcBL002918 for ; Tue, 9 May 2017 11:30:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id D74641964E; Tue, 9 May 2017 15:30:38 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 976EE19651 for ; Tue, 9 May 2017 15:30:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5640CC05490A 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5640CC05490A From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:18 -0400 Message-Id: <20170509153026.19767-12-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Introduce virStoragePoolObjNew 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.32]); Tue, 09 May 2017 15:31:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Create/use a helper to perform object allocation. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 7d6b311..0079472 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -37,6 +37,27 @@ VIR_LOG_INIT("conf.virstorageobj"); =20 =20 +static virStoragePoolObjPtr +virStoragePoolObjNew(virStoragePoolDefPtr def) +{ + virStoragePoolObjPtr obj; + + if (VIR_ALLOC(obj) < 0) + return NULL; + + if (virMutexInit(&obj->lock) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot initialize mutex")); + VIR_FREE(obj); + return NULL; + } + virStoragePoolObjLock(obj); + obj->active =3D 0; + obj->def =3D def; + return obj; +} + + virStoragePoolDefPtr virStoragePoolObjGetDef(virStoragePoolObjPtr obj) { @@ -386,24 +407,15 @@ virStoragePoolObjAssignDef(virStoragePoolObjListPtr p= ools, return obj; } =20 - if (VIR_ALLOC(obj) < 0) + if (!(obj =3D virStoragePoolObjNew(def))) return NULL; =20 - if (virMutexInit(&obj->lock) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot initialize mutex")); - VIR_FREE(obj); - return NULL; - } - virStoragePoolObjLock(obj); - obj->active =3D 0; - if (VIR_APPEND_ELEMENT_COPY(pools->objs, pools->count, obj) < 0) { + obj->def =3D NULL; virStoragePoolObjUnlock(obj); virStoragePoolObjFree(obj); return NULL; } - obj->def =3D def; =20 return obj; } --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 149434389643244.13296656606349; Tue, 9 May 2017 08:31:36 -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 D745180472; Tue, 9 May 2017 15:31: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 B46C6179FD; Tue, 9 May 2017 15:31:34 +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 327A21800C94; Tue, 9 May 2017 15:31:01 +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 v49FUdZh002931 for ; Tue, 9 May 2017 11:30:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 67A7D1964E; Tue, 9 May 2017 15:30:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 289888D568 for ; Tue, 9 May 2017 15:30:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D745180472 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D745180472 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:19 -0400 Message-Id: <20170509153026.19767-13-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Introduce virStoragePoolObj{Get|Set}Autostart 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.28]); Tue, 09 May 2017 15:31:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than have the logic in the storage driver, move it to virstorageobj. NB: virStoragePoolObjGetAutostart can take liberties with not needing the same if...else construct. Also pass a NULL for testStoragePoolSetAutostart to avoid the autostartLink setup using the autostartDir for the test driver. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 57 ++++++++++++++++++++++++++++++++++++++++= ++++ src/conf/virstorageobj.h | 8 +++++++ src/libvirt_private.syms | 2 ++ src/storage/storage_driver.c | 41 +++---------------------------- src/test/test_driver.c | 13 ++-------- 5 files changed, 72 insertions(+), 49 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 0079472..9ce3840 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -111,6 +111,63 @@ virStoragePoolObjSetActive(virStoragePoolObjPtr obj, } =20 =20 +int +virStoragePoolObjGetAutostart(virStoragePoolObjPtr obj) +{ + if (!obj->configFile) + return 0; + + return obj->autostart; +} + + +int +virStoragePoolObjSetAutostart(virStoragePoolObjPtr obj, + const char *autostartDir, + int autostart) +{ + obj->autostart =3D autostart; + + if (!obj->configFile) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("pool has no config file")); + return -1; + } + + autostart =3D (autostart !=3D 0); + + if (obj->autostart !=3D autostart) { + if (autostart && autostartDir) { + if (virFileMakePath(autostartDir) < 0) { + virReportSystemError(errno, + _("cannot create autostart directory = %s"), + autostartDir); + return -1; + } + + if (symlink(obj->configFile, obj->autostartLink) < 0) { + virReportSystemError(errno, + _("Failed to create symlink '%s' to '= %s'"), + obj->autostartLink, obj->configFile); + return -1; + } + } else { + if (unlink(obj->autostartLink) < 0 && + errno !=3D ENOENT && errno !=3D ENOTDIR) { + virReportSystemError(errno, + _("Failed to delete symlink '%s'"), + obj->autostartLink); + return -1; + } + } + + obj->autostart =3D autostart; + } + + return 0; +} + + unsigned int virStoragePoolObjGetAsyncjobs(virStoragePoolObjPtr obj) { diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index d47b233..3b6e395 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -93,6 +93,14 @@ void virStoragePoolObjSetActive(virStoragePoolObjPtr obj, bool active); =20 +int +virStoragePoolObjGetAutostart(virStoragePoolObjPtr obj); + +int +virStoragePoolObjSetAutostart(virStoragePoolObjPtr obj, + const char *autostartDir, + int autostart); + unsigned int virStoragePoolObjGetAsyncjobs(virStoragePoolObjPtr obj); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index edd3174..e8b4eda 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1014,6 +1014,7 @@ virStoragePoolObjDeleteDef; virStoragePoolObjFindByName; virStoragePoolObjFindByUUID; virStoragePoolObjGetAsyncjobs; +virStoragePoolObjGetAutostart; virStoragePoolObjGetConfigFile; virStoragePoolObjGetDef; virStoragePoolObjGetNames; @@ -1031,6 +1032,7 @@ virStoragePoolObjNumOfVolumes; virStoragePoolObjRemove; virStoragePoolObjSaveDef; virStoragePoolObjSetActive; +virStoragePoolObjSetAutostart; virStoragePoolObjSetConfigFile; virStoragePoolObjSourceFindDuplicate; virStoragePoolObjStealNewDef; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 6289314..c4e4e7b 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1250,11 +1250,7 @@ storagePoolGetAutostart(virStoragePoolPtr pool, if (virStoragePoolGetAutostartEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if (!obj->configFile) { - *autostart =3D 0; - } else { - *autostart =3D obj->autostart; - } + *autostart =3D virStoragePoolObjGetAutostart(obj); =20 ret =3D 0; =20 @@ -1277,39 +1273,8 @@ storagePoolSetAutostart(virStoragePoolPtr pool, if (virStoragePoolSetAutostartEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if (!obj->configFile) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("pool has no config file")); - } - - autostart =3D (autostart !=3D 0); - - if (obj->autostart !=3D autostart) { - if (autostart) { - if (virFileMakePath(driver->autostartDir) < 0) { - virReportSystemError(errno, - _("cannot create autostart directory = %s"), - driver->autostartDir); - goto cleanup; - } - - if (symlink(obj->configFile, obj->autostartLink) < 0) { - virReportSystemError(errno, - _("Failed to create symlink '%s' to '= %s'"), - obj->autostartLink, obj->configFile); - goto cleanup; - } - } else { - if (unlink(obj->autostartLink) < 0 && - errno !=3D ENOENT && errno !=3D ENOTDIR) { - virReportSystemError(errno, - _("Failed to delete symlink '%s'"), - obj->autostartLink); - goto cleanup; - } - } - obj->autostart =3D autostart; - } + if (virStoragePoolObjSetAutostart(obj, driver->autostartDir, autostart= ) < 0) + goto cleanup; =20 ret =3D 0; =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 68f1412..d68a18d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4690,11 +4690,7 @@ testStoragePoolGetAutostart(virStoragePoolPtr pool, if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) return -1; =20 - if (!obj->configFile) { - *autostart =3D 0; - } else { - *autostart =3D obj->autostart; - } + *autostart =3D virStoragePoolObjGetAutostart(obj); =20 virStoragePoolObjUnlock(obj); return 0; @@ -4712,14 +4708,9 @@ testStoragePoolSetAutostart(virStoragePoolPtr pool, if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) return -1; =20 - if (!obj->configFile) { - virReportError(VIR_ERR_INVALID_ARG, - "%s", _("pool has no config file")); + if (virStoragePoolObjSetAutostart(obj, NULL, autostart) < 0) goto cleanup; - } =20 - autostart =3D (autostart !=3D 0); - obj->autostart =3D autostart; ret =3D 0; =20 cleanup: --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343875232121.88719649758275; Tue, 9 May 2017 08:31:15 -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 CD3193D957; Tue, 9 May 2017 15:31:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AACF78852B; Tue, 9 May 2017 15:31:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CBF535ED67; Tue, 9 May 2017 15:31:03 +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 v49FUdcR002941 for ; Tue, 9 May 2017 11:30:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id CE9F01964E; Tue, 9 May 2017 15:30:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 905F45C7BF for ; Tue, 9 May 2017 15:30:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CD3193D957 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CD3193D957 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:20 -0400 Message-Id: <20170509153026.19767-14-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Move autostartLink deletion to virstorageobj 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, 09 May 2017 15:31:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The virStoragePoolObjDeleteDef already dealt with the configFile - just add in the autostartLink as well. If there is no autostartLink defined, then no need to attempt unlink - which also allows removal of one errno check in moved function. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 11 +++++++++++ src/storage/storage_driver.c | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 9ce3840..69ed66d 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -696,6 +696,17 @@ virStoragePoolObjDeleteDef(virStoragePoolObjPtr obj) obj->def->name); return -1; } + VIR_FREE(obj->configFile); + + if (!obj->autostartLink) + return 0; + + if (unlink(obj->autostartLink) < 0 && errno !=3D ENOTDIR) { + char ebuf[1024]; + VIR_ERROR(_("Failed to delete autostart link '%s': %s"), + obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf= ))); + } + VIR_FREE(obj->autostartLink); =20 return 0; } diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index c4e4e7b..c4650cd 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -841,17 +841,6 @@ storagePoolUndefine(virStoragePoolPtr pool) if (virStoragePoolObjDeleteDef(obj) < 0) goto cleanup; =20 - if (unlink(obj->autostartLink) < 0 && - errno !=3D ENOENT && - errno !=3D ENOTDIR) { - char ebuf[1024]; - VIR_ERROR(_("Failed to delete autostart link '%s': %s"), - obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf= ))); - } - - VIR_FREE(obj->configFile); - VIR_FREE(obj->autostartLink); - event =3D virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uuid, VIR_STORAGE_POOL_EVENT_UNDEFIN= ED, --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343857045483.2456018100703; Tue, 9 May 2017 08:30:57 -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 7AF1D80474; Tue, 9 May 2017 15:30:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4236877542; Tue, 9 May 2017 15:30:55 +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 EE23A5EC67; Tue, 9 May 2017 15:30:54 +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 v49FUeTh002948 for ; Tue, 9 May 2017 11:30:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 41B228AC43; Tue, 9 May 2017 15:30:40 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 023091964E for ; Tue, 9 May 2017 15:30:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7AF1D80474 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7AF1D80474 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:21 -0400 Message-Id: <20170509153026.19767-15-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Introduce storage volume add, delete, count 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 09 May 2017 15:30:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Create/use virStoragePoolObjAddVol in order to add volumes onto list. Create/use virStoragePoolObjRemoveVol in order to remove volumes from list. Create/use virStoragePoolObjGetVolumesCount to get count of volumes on list. For the storage driver, the logic alters when the volumes.obj list grows to after we've fetched the volobj. This is an optimization of sorts, but also doesn't "needlessly" grow the volumes.objs list and then just decr the count if the virGetStorageVol fails. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 37 ++++++++++++++++++++++++ src/conf/virstorageobj.h | 11 +++++++ src/libvirt_private.syms | 3 ++ src/storage/storage_backend_disk.c | 5 ++-- src/storage/storage_backend_gluster.c | 3 +- src/storage/storage_backend_logical.c | 3 +- src/storage/storage_backend_mpath.c | 3 +- src/storage/storage_backend_rbd.c | 4 +-- src/storage/storage_backend_sheepdog.c | 4 +-- src/storage/storage_backend_zfs.c | 5 +--- src/storage/storage_driver.c | 53 +++++++++---------------------= ---- src/storage/storage_util.c | 4 +-- src/test/test_driver.c | 18 ++++-------- 13 files changed, 81 insertions(+), 72 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 69ed66d..cc3464e 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -305,6 +305,43 @@ virStoragePoolObjClearVols(virStoragePoolObjPtr obj) } =20 =20 +int +virStoragePoolObjAddVol(virStoragePoolObjPtr obj, + virStorageVolDefPtr voldef) +{ + if (VIR_APPEND_ELEMENT(obj->volumes.objs, obj->volumes.count, voldef) = < 0) + return -1; + return 0; +} + + +void +virStoragePoolObjRemoveVol(virStoragePoolObjPtr obj, + virStorageVolDefPtr voldef) +{ + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); + size_t i; + + for (i =3D 0; i < obj->volumes.count; i++) { + if (obj->volumes.objs[i] =3D=3D voldef) { + VIR_INFO("Deleting volume '%s' from storage pool '%s'", + voldef->name, def->name); + virStorageVolDefFree(voldef); + + VIR_DELETE_ELEMENT(obj->volumes.objs, i, obj->volumes.count); + return; + } + } +} + + +size_t +virStoragePoolObjGetVolumesCount(virStoragePoolObjPtr obj) +{ + return obj->volumes.count; +} + + virStorageVolDefPtr virStorageVolDefFindByKey(virStoragePoolObjPtr obj, const char *key) diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index 3b6e395..d27ff57 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -127,6 +127,17 @@ virStoragePoolObjPtr virStoragePoolObjFindByName(virStoragePoolObjListPtr pools, const char *name); =20 +int +virStoragePoolObjAddVol(virStoragePoolObjPtr obj, + virStorageVolDefPtr voldef); + +void +virStoragePoolObjRemoveVol(virStoragePoolObjPtr obj, + virStorageVolDefPtr voldef); + +size_t +virStoragePoolObjGetVolumesCount(virStoragePoolObjPtr obj); + virStorageVolDefPtr virStorageVolDefFindByKey(virStoragePoolObjPtr obj, const char *key); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e8b4eda..03777a3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1007,6 +1007,7 @@ virSecretObjSetValueSize; =20 =20 # conf/virstorageobj.h +virStoragePoolObjAddVol; virStoragePoolObjAssignDef; virStoragePoolObjClearVols; virStoragePoolObjDecrAsyncjobs; @@ -1019,6 +1020,7 @@ virStoragePoolObjGetConfigFile; virStoragePoolObjGetDef; virStoragePoolObjGetNames; virStoragePoolObjGetNewDef; +virStoragePoolObjGetVolumesCount; virStoragePoolObjIncrAsyncjobs; virStoragePoolObjIsActive; virStoragePoolObjIsDuplicate; @@ -1030,6 +1032,7 @@ virStoragePoolObjLock; virStoragePoolObjNumOfStoragePools; virStoragePoolObjNumOfVolumes; virStoragePoolObjRemove; +virStoragePoolObjRemoveVol; virStoragePoolObjSaveDef; virStoragePoolObjSetActive; virStoragePoolObjSetAutostart; diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index e8f67bb..0bf5567 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -65,8 +65,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr poo= l, if (VIR_ALLOC(vol) < 0) return -1; if (VIR_STRDUP(vol->name, partname) < 0 || - VIR_APPEND_ELEMENT_COPY(pool->volumes.objs, - pool->volumes.count, vol) < 0) { + virStoragePoolObjAddVol(pool, vol) < 0) { virStorageVolDefFree(vol); return -1; } @@ -595,7 +594,7 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr po= ol, break; } } - if (i =3D=3D pool->volumes.count) { + if (i =3D=3D virStoragePoolObjGetVolumesCount(pool)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no extended partition found an= d no primary partition available")); return -1; diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 93dce40..afd93b7 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -385,8 +385,7 @@ virStorageBackendGlusterRefreshPool(virConnectPtr conn = ATTRIBUTE_UNUSED, =20 if (okay < 0) goto cleanup; - if (vol && VIR_APPEND_ELEMENT(pool->volumes.objs, pool->volumes.co= unt, - vol) < 0) + if (vol && virStoragePoolObjAddVol(pool, vol) < 0) goto cleanup; } if (errno) { diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 67f70e5..2f2782c 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -356,8 +356,7 @@ virStorageBackendLogicalMakeVol(char **const groups, if (virStorageBackendLogicalParseVolExtents(vol, groups) < 0) goto cleanup; =20 - if (is_new_vol && - VIR_APPEND_ELEMENT(pool->volumes.objs, pool->volumes.count, vol) <= 0) + if (is_new_vol && virStoragePoolObjAddVol(pool, vol) < 0) goto cleanup; =20 ret =3D 0; diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_back= end_mpath.c index 606b399..fcaaa0e 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -71,8 +71,9 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool, if (VIR_STRDUP(vol->key, vol->target.path) < 0) goto cleanup; =20 - if (VIR_APPEND_ELEMENT_COPY(pool->volumes.objs, pool->volumes.count, v= ol) < 0) + if (virStoragePoolObjAddVol(pool, vol) < 0) goto cleanup; + pool->def->capacity +=3D vol->target.capacity; pool->def->allocation +=3D vol->target.allocation; ret =3D 0; diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 7b8887b..6731677 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -506,7 +506,7 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn, goto cleanup; } =20 - if (VIR_APPEND_ELEMENT(pool->volumes.objs, pool->volumes.count, vo= l) < 0) { + if (virStoragePoolObjAddVol(pool, vol) < 0) { virStorageVolDefFree(vol); virStoragePoolObjClearVols(pool); goto cleanup; @@ -514,7 +514,7 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn, } =20 VIR_DEBUG("Found %zu images in RBD pool %s", - pool->volumes.count, pool->def->source.name); + virStoragePoolObjGetVolumesCount(pool), pool->def->source.na= me); =20 ret =3D 0; =20 diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_b= ackend_sheepdog.c index b55d96a..e72dcda 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -130,11 +130,9 @@ virStorageBackendSheepdogAddVolume(virConnectPtr conn = ATTRIBUTE_UNUSED, if (virStorageBackendSheepdogRefreshVol(conn, pool, vol) < 0) goto error; =20 - if (VIR_EXPAND_N(pool->volumes.objs, pool->volumes.count, 1) < 0) + if (virStoragePoolObjAddVol(pool, vol) < 0) goto error; =20 - pool->volumes.objs[pool->volumes.count - 1] =3D vol; - return 0; =20 error: diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index c6dae71..c063090 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -161,10 +161,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, if (volume->target.allocation < volume->target.capacity) volume->target.sparse =3D true; =20 - if (is_new_vol && - VIR_APPEND_ELEMENT(pool->volumes.objs, - pool->volumes.count, - volume) < 0) + if (is_new_vol && virStoragePoolObjAddVol(pool, volume) < 0) goto cleanup; =20 ret =3D 0; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index c4650cd..fc393dd 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1579,25 +1579,6 @@ storagePoolLookupByTargetPath(virConnectPtr conn, } =20 =20 -static void -storageVolRemoveFromPool(virStoragePoolObjPtr obj, - virStorageVolDefPtr voldef) -{ - size_t i; - - for (i =3D 0; i < obj->volumes.count; i++) { - if (obj->volumes.objs[i] =3D=3D voldef) { - VIR_INFO("Deleting volume '%s' from storage pool '%s'", - voldef->name, obj->def->name); - virStorageVolDefFree(voldef); - - VIR_DELETE_ELEMENT(obj->volumes.objs, i, obj->volumes.count); - break; - } - } -} - - static int storageVolDeleteInternal(virStorageVolPtr vol, virStorageBackendPtr backend, @@ -1629,7 +1610,7 @@ storageVolDeleteInternal(virStorageVolPtr vol, } } =20 - storageVolRemoveFromPool(obj, voldef); + virStoragePoolObjRemoveVol(obj, voldef); ret =3D 0; =20 cleanup: @@ -1768,24 +1749,19 @@ storageVolCreateXML(virStoragePoolPtr pool, goto cleanup; } =20 - if (VIR_REALLOC_N(obj->volumes.objs, - obj->volumes.count + 1) < 0) - goto cleanup; - /* Wipe any key the user may have suggested, as volume creation * will generate the canonical key. */ VIR_FREE(voldef->key); if (backend->createVol(pool->conn, obj, voldef) < 0) goto cleanup; =20 - obj->volumes.objs[obj->volumes.count++] =3D voldef; - volobj =3D virGetStorageVol(pool->conn, obj->def->name, voldef->name, - voldef->key, NULL, NULL); - if (!volobj) { - obj->volumes.count--; + if (!(volobj =3D virGetStorageVol(pool->conn, obj->def->name, voldef->= name, + voldef->key, NULL, NULL))) goto cleanup; - } =20 + /* NB: Upon success voldef "owned" by storage pool for deletion purpos= es */ + if (virStoragePoolObjAddVol(obj, voldef) < 0) + goto cleanup; =20 if (backend->buildVol) { int buildret; @@ -1820,7 +1796,7 @@ storageVolCreateXML(virStoragePoolPtr pool, =20 if (buildret < 0) { /* buildVol handles deleting volume on failure */ - storageVolRemoveFromPool(obj, voldef); + virStoragePoolObjRemoveVol(obj, voldef); voldef =3D NULL; goto cleanup; } @@ -1971,9 +1947,6 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, backend->refreshVol(pool->conn, obj, voldefsrc) < 0) goto cleanup; =20 - if (VIR_REALLOC_N(obj->volumes.objs, obj->volumes.count + 1) < 0) - goto cleanup; - /* 'Define' the new volume so we get async progress reporting. * Wipe any key the user may have suggested, as volume creation * will generate the canonical key. */ @@ -1990,13 +1963,13 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, =20 memcpy(shadowvol, voldef, sizeof(*voldef)); =20 - obj->volumes.objs[obj->volumes.count++] =3D voldef; - volobj =3D virGetStorageVol(pool->conn, obj->def->name, voldef->name, - voldef->key, NULL, NULL); - if (!volobj) { - obj->volumes.count--; + if (!(volobj =3D virGetStorageVol(pool->conn, obj->def->name, voldef->= name, + voldef->key, NULL, NULL))) + goto cleanup; + + /* NB: Upon success voldef "owned" by storage pool for deletion purpos= es */ + if (virStoragePoolObjAddVol(obj, voldef) < 0) goto cleanup; - } =20 /* Drop the pool lock during volume allocation */ obj->asyncjobs++; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 08dca94..8d9dd3f 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -3595,7 +3595,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, * An error message was raised, but we just continue. */ } =20 - if (VIR_APPEND_ELEMENT(pool->volumes.objs, pool->volumes.count, vo= l) < 0) + if (virStoragePoolObjAddVol(pool, vol) < 0) goto cleanup; } if (direrr < 0) @@ -3783,7 +3783,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, pool->def->capacity +=3D vol->target.capacity; pool->def->allocation +=3D vol->target.allocation; =20 - if (VIR_APPEND_ELEMENT(pool->volumes.objs, pool->volumes.count, vol) <= 0) + if (virStoragePoolObjAddVol(pool, vol) < 0) goto cleanup; =20 vol =3D NULL; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index d68a18d..6ea3a5b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1075,7 +1075,8 @@ testOpenVolumesForPool(const char *file, =20 if (!def->key && VIR_STRDUP(def->key, def->target.path) < 0) goto error; - if (VIR_APPEND_ELEMENT_COPY(obj->volumes.objs, obj->volumes.count,= def) < 0) + + if (virStoragePoolObjAddVol(obj, def) < 0) goto error; =20 obj->def->allocation +=3D def->target.allocation; @@ -4937,8 +4938,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool, goto cleanup; =20 if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || - VIR_APPEND_ELEMENT_COPY(obj->volumes.objs, - obj->volumes.count, privvol) < 0) + virStoragePoolObjAddVol(obj, privvol) < 0) goto cleanup; =20 obj->def->allocation +=3D privvol->target.allocation; @@ -5005,8 +5005,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, goto cleanup; =20 if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || - VIR_APPEND_ELEMENT_COPY(obj->volumes.objs, - obj->volumes.count, privvol) < 0) + virStoragePoolObjAddVol(obj, privvol) < 0) goto cleanup; =20 obj->def->allocation +=3D privvol->target.allocation; @@ -5031,7 +5030,6 @@ testStorageVolDelete(virStorageVolPtr vol, testDriverPtr privconn =3D vol->conn->privateData; virStoragePoolObjPtr obj; virStorageVolDefPtr privvol; - size_t i; int ret =3D -1; =20 virCheckFlags(0, -1); @@ -5045,14 +5043,8 @@ testStorageVolDelete(virStorageVolPtr vol, obj->def->allocation -=3D privvol->target.allocation; obj->def->available =3D (obj->def->capacity - obj->def->allocation); =20 - for (i =3D 0; i < obj->volumes.count; i++) { - if (obj->volumes.objs[i] =3D=3D privvol) { - virStorageVolDefFree(privvol); + virStoragePoolObjRemoveVol(obj, privvol); =20 - VIR_DELETE_ELEMENT(obj->volumes.objs, i, obj->volumes.count); - break; - } - } ret =3D 0; =20 cleanup: --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343886659391.56567224939283; Tue, 9 May 2017 08:31:26 -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 DAF4E4E024; Tue, 9 May 2017 15:31:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B657788530; Tue, 9 May 2017 15:31: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 7FDCE5ED6D; Tue, 9 May 2017 15:31:07 +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 v49FUeYm002961 for ; Tue, 9 May 2017 11:30:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id A850F5C7BF; Tue, 9 May 2017 15:30:40 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68F4219651 for ; Tue, 9 May 2017 15:30:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DAF4E4E024 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DAF4E4E024 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:22 -0400 Message-Id: <20170509153026.19767-16-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Introduce virStoragePoolObjForEachVolume 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.38]); Tue, 09 May 2017 15:31:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Create/Use API to "walk" the storage pool object volume list. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 10 ++++++++++ src/conf/virstorageobj.h | 4 ++++ src/libvirt_private.syms | 1 + src/storage/storage_backend_disk.c | 26 +++++++++++++++----------- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index cc3464e..14feecb 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -343,6 +343,16 @@ virStoragePoolObjGetVolumesCount(virStoragePoolObjPtr = obj) =20 =20 virStorageVolDefPtr +virStoragePoolObjForEachVolume(virStoragePoolObjPtr obj, + size_t curidx) +{ + if (curidx < obj->volumes.count) + return obj->volumes.objs[curidx]; + return NULL; +} + + +virStorageVolDefPtr virStorageVolDefFindByKey(virStoragePoolObjPtr obj, const char *key) { diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index d27ff57..df0b4ae 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -139,6 +139,10 @@ size_t virStoragePoolObjGetVolumesCount(virStoragePoolObjPtr obj); =20 virStorageVolDefPtr +virStoragePoolObjForEachVolume(virStoragePoolObjPtr obj, + size_t curidx); + +virStorageVolDefPtr virStorageVolDefFindByKey(virStoragePoolObjPtr obj, const char *key); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 03777a3..fe0e203 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1014,6 +1014,7 @@ virStoragePoolObjDecrAsyncjobs; virStoragePoolObjDeleteDef; virStoragePoolObjFindByName; virStoragePoolObjFindByUUID; +virStoragePoolObjForEachVolume; virStoragePoolObjGetAsyncjobs; virStoragePoolObjGetAutostart; virStoragePoolObjGetConfigFile; diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index 0bf5567..0ec601e 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -192,12 +192,11 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr= pool, /* Find the extended partition and increase the allocation value */ if (vol->source.partType =3D=3D VIR_STORAGE_VOL_DISK_TYPE_LOGICAL) { size_t i; + virStorageVolDefPtr voldef; =20 - for (i =3D 0; i < pool->volumes.count; i++) { - if (pool->volumes.objs[i]->source.partType =3D=3D - VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) { - pool->volumes.objs[i]->target.allocation +=3D - vol->target.allocation; + for (i =3D 0; (voldef =3D virStoragePoolObjForEachVolume(pool, i))= ; i++) { + if (voldef->source.partType =3D=3D VIR_STORAGE_VOL_DISK_TYPE_E= XTENDED) { + voldef->target.allocation +=3D vol->target.allocation; break; } } @@ -533,8 +532,10 @@ virStorageBackendDiskPartTypeToCreate(virStoragePoolOb= jPtr pool) can't be more than 3 to create a new primary partition */ size_t i; int count =3D 0; - for (i =3D 0; i < pool->volumes.count; i++) { - int partType =3D pool->volumes.objs[i]->source.partType; + virStorageVolDefPtr voldef; + + for (i =3D 0; (voldef =3D virStoragePoolObjForEachVolume(pool, i))= ; i++) { + int partType =3D voldef->source.partType; if (partType =3D=3D VIR_STORAGE_VOL_DISK_TYPE_PRIMARY || partType =3D=3D VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) count++; @@ -553,6 +554,8 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr po= ol, char** partFormat) { size_t i; + virStorageVolDefPtr voldef; + if (pool->def->source.format =3D=3D VIR_STORAGE_POOL_DISK_DOS) { const char *partedFormat; partedFormat =3D virStoragePartedFsTypeToString(vol->target.format= ); @@ -563,8 +566,8 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr po= ol, } if (vol->target.format =3D=3D VIR_STORAGE_VOL_DISK_EXTENDED) { /* make sure we don't have an extended partition already */ - for (i =3D 0; i < pool->volumes.count; i++) { - if (pool->volumes.objs[i]->source.partType =3D=3D + for (i =3D 0; (voldef =3D virStoragePoolObjForEachVolume(pool,= i)); i++) { + if (voldef->source.partType =3D=3D VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("extended partition already exists")); @@ -585,8 +588,9 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr po= ol, break; case VIR_STORAGE_VOL_DISK_TYPE_LOGICAL: /* make sure we have an extended partition */ - for (i =3D 0; i < pool->volumes.count; i++) { - if (pool->volumes.objs[i]->source.partType =3D=3D + for (i =3D 0; (voldef =3D virStoragePoolObjForEachVolume(p= ool, i)); + i++) { + if (voldef->source.partType =3D=3D VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) { if (virAsprintf(partFormat, "logical %s", partedFormat) < 0) --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343891604837.1097709639668; Tue, 9 May 2017 08:31:31 -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 E2D6E7F4BB; Tue, 9 May 2017 15:31:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5A877DEE3; Tue, 9 May 2017 15:31:29 +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 476F05ED72; Tue, 9 May 2017 15:31: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 v49FUfkJ002966 for ; Tue, 9 May 2017 11:30:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD19819651; Tue, 9 May 2017 15:30:41 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFCF45C7BF for ; Tue, 9 May 2017 15:30:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E2D6E7F4BB 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E2D6E7F4BB From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:23 -0400 Message-Id: <20170509153026.19767-17-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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 virStoragePoolObj accessors 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 09 May 2017 15:31:30 +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 accessors. Perform some minor code cleanup along the w/r/t spacing, line wraps, etc. Signed-off-by: John Ferlan --- src/storage/storage_driver.c | 426 ++++++++++++++++++++++++---------------= ---- 1 file changed, 242 insertions(+), 184 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index fc393dd..7d491bf 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -90,14 +90,14 @@ static void virStoragePoolUpdateInactive(virStoragePoolObjPtr *objptr) { virStoragePoolObjPtr obj =3D *objptr; + virStoragePoolDefPtr newDef =3D virStoragePoolObjGetNewDef(obj); + char *configFile =3D virStoragePoolObjGetConfigFile(obj); =20 - if (obj->configFile =3D=3D NULL) { + if (!configFile) { virStoragePoolObjRemove(&driver->pools, obj); *objptr =3D NULL; - } else if (obj->newDef) { - virStoragePoolDefFree(obj->def); - obj->def =3D obj->newDef; - obj->newDef =3D NULL; + } else if (newDef) { + virStoragePoolObjStealNewDef(obj); } } =20 @@ -105,17 +105,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 @@ -125,7 +125,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 @@ -140,14 +140,14 @@ 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; } } =20 - obj->active =3D active; + virStoragePoolObjSetActive(obj, active); =20 - if (!obj->active) + if (!virStoragePoolObjIsActive(obj)) virStoragePoolUpdateInactive(&obj); =20 cleanup: @@ -187,22 +187,23 @@ 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; } =20 - if (obj->autostart && + if (virStoragePoolObjGetAutostart(obj) && !virStoragePoolObjIsActive(obj)) { if (backend->startPool && 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; } @@ -213,10 +214,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); @@ -224,9 +224,9 @@ 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 { - obj->active =3D true; + virStoragePoolObjSetActive(obj, true); } VIR_FREE(stateFile); } @@ -443,6 +443,7 @@ storagePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; =20 storageDriverLock(); @@ -450,11 +451,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); @@ -466,15 +468,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); @@ -485,16 +489,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); @@ -615,12 +620,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); @@ -635,15 +642,17 @@ 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 obj->configFile ? 1 : 0; + ret =3D virStoragePoolObjGetConfigFile(obj) ? 1 : 0; =20 cleanup: virStoragePoolObjUnlock(obj); @@ -658,6 +667,7 @@ storagePoolCreateXML(virConnectPtr conn, { virStoragePoolDefPtr def; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr objdef; virStoragePoolPtr pool =3D NULL; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; @@ -690,6 +700,7 @@ storagePoolCreateXML(virConnectPtr conn, if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, def))) goto cleanup; def =3D NULL; + objdef =3D virStoragePoolObjGetDef(obj); =20 if (backend->buildPool) { if (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE) @@ -714,11 +725,10 @@ storagePoolCreateXML(virConnectPtr conn, goto cleanup; } =20 - stateFile =3D virFileBuildPath(driver->stateDir, - obj->def->name, ".xml"); + stateFile =3D virFileBuildPath(driver->stateDir, objdef->name, ".xml"); =20 virStoragePoolObjClearVols(obj); - if (!stateFile || virStoragePoolSaveState(stateFile, obj->def) < 0 || + if (!stateFile || virStoragePoolSaveState(stateFile, objdef) < 0 || backend->refreshPool(conn, obj) < 0) { if (stateFile) unlink(stateFile); @@ -729,15 +739,15 @@ storagePoolCreateXML(virConnectPtr conn, goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(objdef->name, + objdef->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 - VIR_INFO("Creating storage pool '%s'", obj->def->name); - obj->active =3D true; + VIR_INFO("Creating storage pool '%s'", objdef->name); + virStoragePoolObjSetActive(obj, true); =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + pool =3D virGetStoragePool(conn, objdef->name, objdef->uuid, NULL, NUL= L); =20 cleanup: VIR_FREE(stateFile); @@ -757,6 +767,7 @@ storagePoolDefineXML(virConnectPtr conn, { virStoragePoolDefPtr def; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr objdef; virStoragePoolPtr pool =3D NULL; virObjectEventPtr event =3D NULL; =20 @@ -783,22 +794,21 @@ storagePoolDefineXML(virConnectPtr conn, =20 if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, def))) goto cleanup; + def =3D NULL; + objdef =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolObjSaveDef(driver, obj, def) < 0) { + if (virStoragePoolObjSaveDef(driver, obj, objdef) < 0) { virStoragePoolObjRemove(&driver->pools, obj); - def =3D NULL; obj =3D NULL; goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(def->name, def->uuid, + event =3D virStoragePoolEventLifecycleNew(objdef->name, objdef->uuid, 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'", objdef->name); + pool =3D virGetStoragePool(conn, objdef->name, objdef->uuid, NULL, NUL= L); =20 cleanup: if (event) @@ -814,39 +824,41 @@ static int storagePoolUndefine(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virObjectEventPtr event =3D NULL; int ret =3D -1; =20 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 (obj->asyncjobs > 0) { + if (virStoragePoolObjGetAsyncjobs(obj) > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - obj->def->name); + def->name); goto cleanup; } =20 if (virStoragePoolObjDeleteDef(obj) < 0) goto cleanup; =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; @@ -865,6 +877,7 @@ storagePoolCreate(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; int ret =3D -1; @@ -880,17 +893,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 @@ -907,16 +921,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); @@ -925,12 +938,12 @@ 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 - obj->active =3D true; + virStoragePoolObjSetActive(obj, true); ret =3D 0; =20 cleanup: @@ -947,22 +960,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 @@ -981,6 +996,7 @@ static int storagePoolDestroy(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; char *stateFile =3D NULL; @@ -989,31 +1005,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 (obj->asyncjobs > 0) { + 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); @@ -1025,12 +1040,12 @@ 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 - obj->active =3D false; + virStoragePoolObjSetActive(obj, false); =20 virStoragePoolUpdateInactive(&obj); =20 @@ -1050,38 +1065,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 (obj->asyncjobs > 0) { + 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); @@ -1108,6 +1123,7 @@ storagePoolRefresh(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; int ret =3D -1; virObjectEventPtr event =3D NULL; @@ -1117,23 +1133,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 (obj->asyncjobs > 0) { + if (virStoragePoolObjGetAsyncjobs(obj) > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - obj->def->name); + def->name); goto cleanup; } =20 @@ -1142,19 +1159,19 @@ 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); - obj->active =3D false; + virStoragePoolObjSetActive(obj, false); =20 virStoragePoolUpdateInactive(&obj); =20 goto cleanup; } =20 - event =3D virStoragePoolEventRefreshNew(obj->def->name, - obj->def->uuid); + event =3D virStoragePoolEventRefreshNew(def->name, + def->uuid); ret =3D 0; =20 cleanup: @@ -1172,25 +1189,27 @@ 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)); - if (obj->active) + 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; ret =3D 0; =20 cleanup: @@ -1203,6 +1222,8 @@ storagePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr objdef; + virStoragePoolDefPtr newDef; virStoragePoolDefPtr def; char *ret =3D NULL; =20 @@ -1210,14 +1231,16 @@ storagePoolGetXMLDesc(virStoragePoolPtr pool, =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return NULL; + objdef =3D virStoragePoolObjGetDef(obj); + newDef =3D virStoragePoolObjGetNewDef(obj); =20 - if (virStoragePoolGetXMLDescEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolGetXMLDescEnsureACL(pool->conn, objdef) < 0) goto cleanup; =20 - if ((flags & VIR_STORAGE_XML_INACTIVE) && obj->newDef) - def =3D obj->newDef; + if ((flags & VIR_STORAGE_XML_INACTIVE) && newDef) + def =3D newDef; else - def =3D obj->def; + def =3D objdef; =20 ret =3D virStoragePoolDefFormat(def); =20 @@ -1236,7 +1259,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 virStoragePoolObjGetAutostart(obj); @@ -1259,7 +1283,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 (virStoragePoolObjSetAutostart(obj, driver->autostartDir, autostart= ) < 0) @@ -1279,17 +1304,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 @@ -1308,17 +1335,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 @@ -1337,19 +1366,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 @@ -1368,15 +1399,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 @@ -1389,10 +1422,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: @@ -1410,26 +1443,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) @@ -1456,17 +1489,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: @@ -1484,7 +1519,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; } @@ -1506,12 +1541,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); } @@ -1551,18 +1586,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); } @@ -1587,6 +1622,7 @@ storageVolDeleteInternal(virStorageVolPtr vol, unsigned int flags, bool updateMeta) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); int ret =3D -1; =20 if (!backend->deleteVol) { @@ -1604,9 +1640,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 @@ -1624,14 +1660,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 @@ -1643,7 +1681,7 @@ virStorageVolDefFromVol(virStorageVolPtr vol, } =20 if (backend) { - if (!(*backend =3D virStorageBackendForType((*obj)->def->type))) + if (!(*backend =3D virStorageBackendForType(def->type))) goto error; } =20 @@ -1669,7 +1707,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) { @@ -1703,6 +1742,7 @@ storageVolCreateXML(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virStorageVolDefPtr voldef =3D NULL; virStorageVolPtr vol =3D NULL, volobj =3D NULL; @@ -1711,17 +1751,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; @@ -1733,7 +1774,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)) { @@ -1755,7 +1796,7 @@ storageVolCreateXML(virStoragePoolPtr pool, if (backend->createVol(pool->conn, obj, voldef) < 0) goto cleanup; =20 - if (!(volobj =3D virGetStorageVol(pool->conn, obj->def->name, voldef->= name, + if (!(volobj =3D virGetStorageVol(pool->conn, def->name, voldef->name, voldef->key, NULL, NULL))) goto cleanup; =20 @@ -1779,7 +1820,7 @@ storageVolCreateXML(virStoragePoolPtr pool, memcpy(buildvoldef, voldef, sizeof(*voldef)); =20 /* Drop the pool lock during volume allocation */ - obj->asyncjobs++; + virStoragePoolObjIncrAsyncjobs(obj); voldef->building =3D true; virStoragePoolObjUnlock(obj); =20 @@ -1792,7 +1833,7 @@ storageVolCreateXML(virStoragePoolPtr pool, storageDriverUnlock(); =20 voldef->building =3D false; - obj->asyncjobs--; + virStoragePoolObjDecrAsyncjobs(obj); =20 if (buildret < 0) { /* buildVol handles deleting volume on failure */ @@ -1814,13 +1855,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'", - volobj->name, obj->def->name); + volobj->name, def->name); vol =3D volobj; volobj =3D NULL; voldef =3D NULL; @@ -1840,6 +1881,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolObjPtr objsrc =3D NULL; virStorageBackendPtr backend; virStorageVolDefPtr voldefsrc =3D NULL; @@ -1869,6 +1911,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, @@ -1879,18 +1922,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 ? @@ -1902,12 +1946,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)) { @@ -1963,7 +2007,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, =20 memcpy(shadowvol, voldef, sizeof(*voldef)); =20 - if (!(volobj =3D virGetStorageVol(pool->conn, obj->def->name, voldef->= name, + if (!(volobj =3D virGetStorageVol(pool->conn, def->name, voldef->name, voldef->key, NULL, NULL))) goto cleanup; =20 @@ -1972,13 +2016,13 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, goto cleanup; =20 /* Drop the pool lock during volume allocation */ - obj->asyncjobs++; + virStoragePoolObjIncrAsyncjobs(obj); voldef->building =3D true; voldefsrc->in_use++; virStoragePoolObjUnlock(obj); =20 if (objsrc) { - objsrc->asyncjobs++; + virStoragePoolObjIncrAsyncjobs(objsrc); virStoragePoolObjUnlock(objsrc); } =20 @@ -1992,10 +2036,10 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, =20 voldefsrc->in_use--; voldef->building =3D false; - obj->asyncjobs--; + virStoragePoolObjDecrAsyncjobs(obj); =20 if (objsrc) { - objsrc->asyncjobs--; + virStoragePoolObjDecrAsyncjobs(objsrc); virStoragePoolObjUnlock(objsrc); objsrc =3D NULL; } @@ -2011,13 +2055,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'", - volobj->name, obj->def->name); + volobj->name, def->name); vol =3D volobj; volobj =3D NULL; voldef =3D NULL; @@ -2051,7 +2095,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) { @@ -2145,6 +2190,7 @@ virStorageVolPoolRefreshThread(void *opaque) =20 virStorageVolStreamInfoPtr cbdata =3D opaque; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; =20 @@ -2156,16 +2202,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) @@ -2210,6 +2256,7 @@ storageVolUpload(virStorageVolPtr vol, { virStorageBackendPtr backend; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStorageVolDefPtr voldef =3D NULL; virStorageVolStreamInfoPtr cbdata =3D NULL; int ret =3D -1; @@ -2218,8 +2265,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) { @@ -2249,7 +2297,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) @@ -2282,6 +2330,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; @@ -2292,8 +2341,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) { @@ -2338,7 +2388,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; @@ -2361,8 +2411,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; @@ -2396,7 +2446,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) { @@ -2457,7 +2509,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 && @@ -2492,6 +2546,7 @@ storageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virStorageVolDefPtr voldef; char *ret =3D NULL; @@ -2500,15 +2555,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); @@ -2526,7 +2582,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)); @@ -3484,9 +3541,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.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 149434390835035.057873853850765; Tue, 9 May 2017 08:31:48 -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 96AE33DBC4; Tue, 9 May 2017 15:31:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 123577CE1A; Tue, 9 May 2017 15:31:46 +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 B8FDD5ED66; Tue, 9 May 2017 15:31:14 +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 v49FUgfN002971 for ; Tue, 9 May 2017 11:30:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 620FE8AC43; Tue, 9 May 2017 15:30:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EC2D5C7BF for ; Tue, 9 May 2017 15:30:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 96AE33DBC4 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 96AE33DBC4 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:24 -0400 Message-Id: <20170509153026.19767-18-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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 virStoragePoolObj accessors for storage test API's 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.30]); Tue, 09 May 2017 15:31:47 +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 accessors. Perform some minor code cleanup along the w/r/t spacing, line wraps, etc. Signed-off-by: John Ferlan --- src/test/test_driver.c | 186 ++++++++++++++++++++++++++++-----------------= ---- 1 file changed, 107 insertions(+), 79 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6ea3a5b..af5955d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1042,6 +1042,7 @@ testOpenVolumesForPool(const char *file, virStoragePoolObjPtr obj, int objidx) { + virStoragePoolDefPtr objdef =3D virStoragePoolObjGetDef(obj); char *vol_xpath; size_t i; int num, ret =3D -1; @@ -1063,13 +1064,13 @@ testOpenVolumesForPool(const char *file, if (!node) goto error; =20 - def =3D virStorageVolDefParseNode(obj->def, ctxt->doc, node, 0); + def =3D virStorageVolDefParseNode(objdef, ctxt->doc, node, 0); if (!def) goto error; =20 if (def->target.path =3D=3D NULL) { if (virAsprintf(&def->target.path, "%s/%s", - obj->def->target.path, def->name) < 0) + objdef->target.path, def->name) < 0) goto error; } =20 @@ -1079,8 +1080,8 @@ testOpenVolumesForPool(const char *file, if (virStoragePoolObjAddVol(obj, def) < 0) goto error; =20 - obj->def->allocation +=3D def->target.allocation; - obj->def->available =3D (obj->def->capacity - obj->def->allocation= ); + objdef->allocation +=3D def->target.allocation; + objdef->available =3D (objdef->capacity - objdef->allocation); def =3D NULL; } =20 @@ -1127,7 +1128,7 @@ testParseStorage(testDriverPtr privconn, virStoragePoolObjUnlock(obj); goto error; } - obj->active =3D 1; + virStoragePoolObjSetActive(obj, true); =20 /* Find storage volumes */ if (testOpenVolumesForPool(file, ctxt, obj, i+1) < 0) { @@ -4001,12 +4002,18 @@ testInterfaceDestroy(virInterfacePtr iface, static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj) { + char *configFile; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); + + def->capacity =3D defaultPoolCap; + def->allocation =3D defaultPoolAlloc; + def->available =3D defaultPoolCap - defaultPoolAlloc; =20 - obj->def->capacity =3D defaultPoolCap; - obj->def->allocation =3D defaultPoolAlloc; - obj->def->available =3D defaultPoolCap - defaultPoolAlloc; + if (VIR_STRDUP(configFile, "") < 0) + return -1; =20 - return VIR_STRDUP(obj->configFile, ""); + virStoragePoolObjSetConfigFile(obj, configFile); + return 0; } =20 =20 @@ -4097,13 +4104,14 @@ testStoragePoolLookupByUUID(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr ret =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindByUUID(privconn, uuid))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - ret =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, - NULL, NULL); + ret =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 virStoragePoolObjUnlock(obj); return ret; @@ -4116,13 +4124,14 @@ testStoragePoolLookupByName(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr ret =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindByName(privconn, name))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - ret =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, - NULL, NULL); + ret =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 virStoragePoolObjUnlock(obj); return ret; @@ -4248,7 +4257,7 @@ testStoragePoolIsPersistent(virStoragePoolPtr pool) if (!(obj =3D testStoragePoolObjFindByUUID(privconn, pool->uuid))) return -1; =20 - ret =3D obj->configFile ? 1 : 0; + ret =3D virStoragePoolObjGetConfigFile(obj) ? 1 : 0; =20 virStoragePoolObjUnlock(obj); return ret; @@ -4268,7 +4277,7 @@ testStoragePoolCreate(virStoragePoolPtr pool, if (!(obj =3D testStoragePoolObjFindInactiveByName(privconn, pool->nam= e))) return -1; =20 - obj->active =3D 1; + virStoragePoolObjSetActive(obj, true); =20 event =3D virStoragePoolEventLifecycleNew(pool->name, pool->uuid, VIR_STORAGE_POOL_EVENT_STARTED, @@ -4369,6 +4378,8 @@ testStoragePoolCreateXML(virConnectPtr conn, testDriverPtr privconn =3D conn->privateData; virStoragePoolDefPtr def; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr objdef; + char *configFile; virStoragePoolPtr ret =3D NULL; virObjectEventPtr event =3D NULL; =20 @@ -4390,15 +4401,16 @@ testStoragePoolCreateXML(virConnectPtr conn, if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, def))) goto cleanup; def =3D NULL; + objdef =3D virStoragePoolObjGetDef(obj); =20 - if (obj->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_H= OST) { + if (objdef->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOS= T) { /* 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= ) { + objdef->source.adapter.data.fchost.wwnn, + objdef->source.adapter.data.fchost.wwpn) < 0) { virStoragePoolObjRemove(&privconn->pools, obj); obj =3D NULL; goto cleanup; @@ -4414,16 +4426,17 @@ testStoragePoolCreateXML(virConnectPtr conn, /* *SetDefaults fills this in for the persistent pools, but this * would be a transient pool so remove it; otherwise, the Destroy * code will not Remove the pool */ - VIR_FREE(obj->configFile); + configFile =3D virStoragePoolObjGetConfigFile(obj); + VIR_FREE(configFile); + virStoragePoolObjSetConfigFile(obj, NULL); =20 - obj->active =3D 1; + virStoragePoolObjSetActive(obj, true); =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uu= id, + event =3D virStoragePoolEventLifecycleNew(objdef->name, objdef->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 - ret =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, - NULL, NULL); + ret =3D virGetStoragePool(conn, objdef->name, objdef->uuid, NULL, NULL= ); =20 cleanup: virStoragePoolDefFree(def); @@ -4443,6 +4456,7 @@ testStoragePoolDefineXML(virConnectPtr conn, testDriverPtr privconn =3D conn->privateData; virStoragePoolDefPtr def; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr objdef; virStoragePoolPtr ret =3D NULL; virObjectEventPtr event =3D NULL; =20 @@ -4459,8 +4473,9 @@ testStoragePoolDefineXML(virConnectPtr conn, if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, def))) goto cleanup; def =3D NULL; + objdef =3D virStoragePoolObjGetDef(obj); =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uu= id, + event =3D virStoragePoolEventLifecycleNew(objdef->name, objdef->uuid, VIR_STORAGE_POOL_EVENT_DEFINED, 0); =20 @@ -4470,8 +4485,7 @@ testStoragePoolDefineXML(virConnectPtr conn, goto cleanup; } =20 - ret =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, - NULL, NULL); + ret =3D virGetStoragePool(conn, objdef->name, objdef->uuid, NULL, NULL= ); =20 cleanup: virStoragePoolDefFree(def); @@ -4564,28 +4578,29 @@ 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 - obj->active =3D 0; + 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 - if (obj->configFile =3D=3D NULL) { + if (!(virStoragePoolObjGetConfigFile(obj))) { virStoragePoolObjRemove(&privconn->pools, obj); obj =3D NULL; } @@ -4643,18 +4658,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 (obj->active) + 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; @@ -4674,7 +4691,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; @@ -4806,16 +4823,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 @@ -4835,22 +4854,23 @@ testStorageVolLookupByKey(virConnectPtr conn, =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); + virStoragePoolObjPtr obj =3D privconn->pools.objs[i]; + virStoragePoolDefPtr def; + + virStoragePoolObjLock(obj); + def =3D virStoragePoolObjGetDef(obj); + if (virStoragePoolObjIsActive(obj)) { + virStorageVolDefPtr privvol =3D virStorageVolDefFindByKey(obj,= key); =20 if (privvol) { - ret =3D virGetStorageVol(conn, - privconn->pools.objs[i]->def->name, - privvol->name, - privvol->key, + ret =3D virGetStorageVol(conn, 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 @@ -4872,22 +4892,23 @@ testStorageVolLookupByPath(virConnectPtr conn, =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); + virStoragePoolObjPtr obj =3D privconn->pools.objs[i]; + virStoragePoolDefPtr def; + + virStoragePoolObjLock(obj); + def =3D virStoragePoolObjGetDef(obj); + if (virStoragePoolObjIsActive(obj)) { + virStorageVolDefPtr privvol =3D virStorageVolDefFindByPath(obj= , path); =20 if (privvol) { - ret =3D virGetStorageVol(conn, - privconn->pools.objs[i]->def->name, - privvol->name, - privvol->key, + ret =3D virGetStorageVol(conn, 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 @@ -4906,6 +4927,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageVolDefPtr privvol =3D NULL; virStorageVolPtr ret =3D NULL; =20 @@ -4913,8 +4935,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 @@ -4925,8 +4948,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); @@ -4934,17 +4957,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; @@ -4964,6 +4987,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 @@ -4971,8 +4995,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 @@ -4991,27 +5016,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; @@ -5029,6 +5053,7 @@ testStorageVolDelete(virStorageVolPtr vol, { testDriverPtr privconn =3D vol->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageVolDefPtr privvol; int ret =3D -1; =20 @@ -5036,12 +5061,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 @@ -5074,17 +5100,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; @@ -5112,7 +5140,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.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343910249125.83830740905341; Tue, 9 May 2017 08:31:50 -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 9C7CD81127; Tue, 9 May 2017 15:31:47 +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 1D2934F9F8; Tue, 9 May 2017 15:31:47 +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 EC92B1841B10; Tue, 9 May 2017 15:31: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 v49FUjVp003015 for ; Tue, 9 May 2017 11:30:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3501F8AC51; Tue, 9 May 2017 15:30:45 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD5068AC4D for ; Tue, 9 May 2017 15:30:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9C7CD81127 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9C7CD81127 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:25 -0400 Message-Id: <20170509153026.19767-19-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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: Use virStoragePoolObj accessors 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 09 May 2017 15:31:48 +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 accessors. Perform some minor code cleanup along the w/r/t spacing, line wraps, etc. 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 8d9dd3f..63ffc53 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)) { @@ -2767,6 +2772,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; @@ -2774,12 +2780,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 @@ -2795,11 +2801,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; @@ -2807,10 +2813,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 @@ -2835,14 +2841,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 @@ -3522,6 +3530,7 @@ int virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); DIR *dir; struct dirent *ent; struct statvfs sb; @@ -3531,15 +3540,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 @@ -3552,8 +3561,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, vol->type =3D VIR_STORAGE_VOL_FILE; vol->target.format =3D VIR_STORAGE_FILE_RAW; /* Real value is fill= ed in during probe */ 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) @@ -3606,17 +3614,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 @@ -3624,24 +3632,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; @@ -3711,6 +3719,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; @@ -3722,12 +3731,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 @@ -3761,11 +3770,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; @@ -3780,8 +3789,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; @@ -4058,6 +4067,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"; @@ -4099,7 +4109,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.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 13:57:32 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.zoho.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 1494343922125469.9992982595552; Tue, 9 May 2017 08:32:02 -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 75CC97F7D4; Tue, 9 May 2017 15:32:00 +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 38A7E9653E; Tue, 9 May 2017 15:32:00 +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 1FEE7180BAFC; Tue, 9 May 2017 15:31:10 +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 v49FUnci003037 for ; Tue, 9 May 2017 11:30:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7081D19651; Tue, 9 May 2017 15:30:49 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B4C28AC45 for ; Tue, 9 May 2017 15:30:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 75CC97F7D4 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 75CC97F7D4 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 9 May 2017 11:30:26 -0400 Message-Id: <20170509153026.19767-20-jferlan@redhat.com> In-Reply-To: <20170509153026.19767-1-jferlan@redhat.com> References: <20170509153026.19767-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.28]); Tue, 09 May 2017 15:32:01 +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 63ffc53..ad05cbf 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, @@ -2441,7 +2441,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, @@ -2738,7 +2738,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) @@ -2762,7 +2762,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 @@ -2770,9 +2770,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; @@ -2830,7 +2830,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 * @@ -2838,10 +2838,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 @@ -3528,9 +3528,9 @@ storageBackendProbeTarget(virStorageSourcePtr target, */ 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; @@ -3603,7 +3603,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, * An error message was raised, but we just continue. */ } =20 - if (virStoragePoolObjAddVol(pool, vol) < 0) + if (virStoragePoolObjAddVol(obj, vol) < 0) goto cleanup; } if (direrr < 0) @@ -3659,7 +3659,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, virStorageVolDefFree(vol); virStorageSourceFree(target); if (ret < 0) - virStoragePoolObjClearVols(pool); + virStoragePoolObjClearVols(obj); return ret; } =20 @@ -3712,14 +3712,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; @@ -3764,7 +3764,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; @@ -3792,7 +3792,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; =20 vol =3D NULL; @@ -4011,7 +4011,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, @@ -4046,7 +4046,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", @@ -4064,10 +4064,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"; @@ -4095,7 +4095,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 a05c35d..106a3ae 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,20 +78,20 @@ 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 virStorageBackendRefreshLocal(virConnectPtr conn, - virStoragePoolObjPtr pool); + virStoragePoolObjPtr obj); =20 int virStorageUtilGlusterExtractPoolSources(const char *host, const char *xml, @@ -150,13 +150,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, @@ -164,7 +164,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.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list