From nobody Fri May 3 23:01:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1507238124209636.3280817693243; Thu, 5 Oct 2017 14:15:24 -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 23BF27F3F3; Thu, 5 Oct 2017 21:15: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 02A0D600C4; Thu, 5 Oct 2017 21:15: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 B99D218355C9; Thu, 5 Oct 2017 21:15:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v95KNJXI001865 for ; Thu, 5 Oct 2017 16:23:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF0BB60618; Thu, 5 Oct 2017 20:23:19 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-132.phx2.redhat.com [10.3.117.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id B602560603 for ; Thu, 5 Oct 2017 20:23:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 23BF27F3F3 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 5 Oct 2017 16:23:10 -0400 Message-Id: <20171005202315.356-2-jferlan@redhat.com> In-Reply-To: <20171005202315.356-1-jferlan@redhat.com> References: <20171005202315.356-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 1/6] conf: Fix prototype/definition for virStoragePoolObj get functions X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 05 Oct 2017 21:15:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Modify virStoragePoolObjGetAutostartLink and virStoragePoolObjGetConfigFile to return "const char *" since that's how both are used and to ensure no one tries to VIR_FREE the result. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 4 ++-- src/conf/virstorageobj.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 1364bddd15..ff04c9efe4 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -89,7 +89,7 @@ virStoragePoolObjDefUseNewDef(virStoragePoolObjPtr obj) } =20 =20 -char * +const char * virStoragePoolObjGetConfigFile(virStoragePoolObjPtr obj) { return obj->configFile; @@ -105,7 +105,7 @@ virStoragePoolObjSetConfigFile(virStoragePoolObjPtr obj, } =20 =20 -char * +const char * virStoragePoolObjGetAutostartLink(virStoragePoolObjPtr obj) { return obj->autostartLink; diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index b65b16019c..cf7ee06cd1 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -86,14 +86,14 @@ virStoragePoolObjGetNewDef(virStoragePoolObjPtr obj); void virStoragePoolObjDefUseNewDef(virStoragePoolObjPtr obj); =20 -char * +const char * virStoragePoolObjGetConfigFile(virStoragePoolObjPtr obj); =20 void virStoragePoolObjSetConfigFile(virStoragePoolObjPtr obj, char *configFile); =20 -char * +const char * virStoragePoolObjGetAutostartLink(virStoragePoolObjPtr obj); =20 bool --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 23:01:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15072360474918.238496497049823; Thu, 5 Oct 2017 13:40:47 -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 A5EFD2C9746; Thu, 5 Oct 2017 20:40:45 +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 3CFDD60C94; Thu, 5 Oct 2017 20:40:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EA27F1800C89; Thu, 5 Oct 2017 20:40:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v95KNKUh001870 for ; Thu, 5 Oct 2017 16:23:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 540A460618; Thu, 5 Oct 2017 20:23:20 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-132.phx2.redhat.com [10.3.117.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D73F60603 for ; Thu, 5 Oct 2017 20:23:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A5EFD2C9746 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 5 Oct 2017 16:23:11 -0400 Message-Id: <20171005202315.356-3-jferlan@redhat.com> In-Reply-To: <20171005202315.356-1-jferlan@redhat.com> References: <20171005202315.356-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 2/6] tests: Fix possible NULL deref X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 05 Oct 2017 20:40:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Ferlan --- tests/storagevolxml2argvtest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c index 1b3003216d..73d9c4bc6b 100644 --- a/tests/storagevolxml2argvtest.c +++ b/tests/storagevolxml2argvtest.c @@ -110,7 +110,8 @@ testCompareXMLToArgvFiles(bool shouldFail, virStorageVolDefFree(inputvol); virCommandFree(cmd); VIR_FREE(actualCmdline); - virStoragePoolObjUnlock(obj); + if (obj) + virStoragePoolObjUnlock(obj); virStoragePoolObjFree(obj); virObjectUnref(conn); return ret; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 23:01:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1507236081987378.3436479200125; Thu, 5 Oct 2017 13:41:21 -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 A546E2CE931; Thu, 5 Oct 2017 20:41:20 +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 7802C5D769; Thu, 5 Oct 2017 20:41:20 +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 0FE2618355C7; Thu, 5 Oct 2017 20:41:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v95KNLAX001875 for ; Thu, 5 Oct 2017 16:23:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 25A4E60603; Thu, 5 Oct 2017 20:23:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-132.phx2.redhat.com [10.3.117.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD9F960618 for ; Thu, 5 Oct 2017 20:23:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A546E2CE931 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 5 Oct 2017 16:23:12 -0400 Message-Id: <20171005202315.356-4-jferlan@redhat.com> In-Reply-To: <20171005202315.356-1-jferlan@redhat.com> References: <20171005202315.356-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 3/6] storage: Use virStoragePoolObjGetDef accessor for 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 05 Oct 2017 20:41:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In preparation for privatizing the object, use the accessor to fetch the obj->def instead of the direct reference. Signed-off-by: John Ferlan --- src/storage/storage_driver.c | 411 ++++++++++++++++++++++++---------------= ---- 1 file changed, 234 insertions(+), 177 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index d08dedd879..b0edf9f885 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -104,17 +104,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 @@ -124,7 +124,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 @@ -139,7 +139,7 @@ storagePoolUpdateState(virStoragePoolObjPtr obj) backend->stopPool(NULL, obj); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to restart storage pool '%s': %s"), - obj->def->name, virGetLastErrorMessage()); + def->name, virGetLastErrorMessage()); active =3D false; } } @@ -186,11 +186,12 @@ storageDriverAutostart(void) =20 for (i =3D 0; i < driver->pools.count; i++) { virStoragePoolObjPtr obj =3D driver->pools.objs[i]; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); virStorageBackendPtr backend; bool started =3D false; =20 virStoragePoolObjLock(obj); - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D = NULL) { + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL)= { virStoragePoolObjUnlock(obj); continue; } @@ -201,7 +202,7 @@ storageDriverAutostart(void) backend->startPool(conn, obj) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart storage pool '%s': %= s"), - obj->def->name, virGetLastErrorMessage()); + def->name, virGetLastErrorMessage()); virStoragePoolObjUnlock(obj); continue; } @@ -212,10 +213,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); @@ -223,7 +223,7 @@ storageDriverAutostart(void) backend->stopPool(conn, obj); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart storage pool '%s': %= s"), - obj->def->name, virGetLastErrorMessage()); + def->name, virGetLastErrorMessage()); } else { virStoragePoolObjSetActive(obj, true); } @@ -442,6 +442,7 @@ storagePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; =20 storageDriverLock(); @@ -449,11 +450,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); @@ -465,15 +467,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); @@ -484,16 +488,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); @@ -614,12 +619,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); @@ -634,12 +641,14 @@ static int storagePoolIsPersistent(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; int ret =3D -1; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolIsPersistentEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolIsPersistentEnsureACL(pool->conn, def) < 0) goto cleanup; =20 ret =3D virStoragePoolObjGetConfigFile(obj) ? 1 : 0; @@ -655,8 +664,9 @@ storagePoolCreateXML(virConnectPtr conn, const char *xml, unsigned int flags) { - virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; @@ -671,24 +681,25 @@ storagePoolCreateXML(virConnectPtr conn, VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, NULL); =20 storageDriverLock(); - if (!(def =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - if (virStoragePoolCreateXMLEnsureACL(conn, def) < 0) + if (virStoragePoolCreateXMLEnsureACL(conn, newDef) < 0) goto cleanup; =20 - if (virStoragePoolObjIsDuplicate(&driver->pools, def, 1) < 0) + if (virStoragePoolObjIsDuplicate(&driver->pools, newDef, 1) < 0) goto cleanup; =20 - if (virStoragePoolObjSourceFindDuplicate(conn, &driver->pools, def) < = 0) + if (virStoragePoolObjSourceFindDuplicate(conn, &driver->pools, newDef)= < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(newDef->type)) =3D=3D NULL) goto cleanup; =20 - if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, newDef))) goto cleanup; - def =3D NULL; + newDef =3D NULL; + def =3D virStoragePoolObjGetDef(obj); =20 if (backend->buildPool) { if (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE) @@ -713,11 +724,10 @@ storagePoolCreateXML(virConnectPtr conn, goto cleanup; } =20 - stateFile =3D virFileBuildPath(driver->stateDir, - obj->def->name, ".xml"); + stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xml"); =20 virStoragePoolObjClearVols(obj); - if (!stateFile || virStoragePoolSaveState(stateFile, obj->def) < 0 || + if (!stateFile || virStoragePoolSaveState(stateFile, def) < 0 || backend->refreshPool(conn, obj) < 0) { if (stateFile) unlink(stateFile); @@ -728,19 +738,19 @@ storagePoolCreateXML(virConnectPtr conn, goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 - VIR_INFO("Creating storage pool '%s'", obj->def->name); + VIR_INFO("Creating storage pool '%s'", def->name); virStoragePoolObjSetActive(obj, true); =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: VIR_FREE(stateFile); - virStoragePoolDefFree(def); + virStoragePoolDefFree(newDef); if (event) virObjectEventStateQueue(driver->storageEventState, event); if (obj) @@ -754,38 +764,40 @@ storagePoolDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) { - virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, NULL); =20 storageDriverLock(); - if (!(def =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - if (virXMLCheckIllegalChars("name", def->name, "\n") < 0) + if (virXMLCheckIllegalChars("name", newDef->name, "\n") < 0) goto cleanup; =20 - if (virStoragePoolDefineXMLEnsureACL(conn, def) < 0) + if (virStoragePoolDefineXMLEnsureACL(conn, newDef) < 0) goto cleanup; =20 - if (virStoragePoolObjIsDuplicate(&driver->pools, def, 0) < 0) + if (virStoragePoolObjIsDuplicate(&driver->pools, newDef, 0) < 0) goto cleanup; =20 - if (virStoragePoolObjSourceFindDuplicate(conn, &driver->pools, def) < = 0) + if (virStoragePoolObjSourceFindDuplicate(conn, &driver->pools, newDef)= < 0) goto cleanup; =20 - if (virStorageBackendForType(def->type) =3D=3D NULL) + if (virStorageBackendForType(newDef->type) =3D=3D NULL) goto cleanup; =20 - if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&driver->pools, newDef))) goto cleanup; + newDef =3D NULL; + def =3D virStoragePoolObjGetDef(obj); =20 if (virStoragePoolObjSaveDef(driver, obj, def) < 0) { virStoragePoolObjRemove(&driver->pools, obj); - def =3D NULL; obj =3D NULL; goto cleanup; } @@ -794,15 +806,13 @@ storagePoolDefineXML(virConnectPtr conn, VIR_STORAGE_POOL_EVENT_DEFINED, 0); =20 - def =3D NULL; - - VIR_INFO("Defining storage pool '%s'", obj->def->name); - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + VIR_INFO("Defining storage pool '%s'", def->name); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - virStoragePoolDefFree(def); + virStoragePoolDefFree(newDef); if (obj) virStoragePoolObjUnlock(obj); storageDriverUnlock(); @@ -813,6 +823,7 @@ static int storagePoolUndefine(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; const char *autostartLink; virObjectEventPtr event =3D NULL; int ret =3D -1; @@ -820,21 +831,22 @@ storagePoolUndefine(virStoragePoolPtr pool) storageDriverLock(); if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolUndefineEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolUndefineEnsureACL(pool->conn, def) < 0) goto cleanup; =20 if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is still active"), - obj->def->name); + def->name); goto cleanup; } =20 if (virStoragePoolObjGetAsyncjobs(obj) > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - obj->def->name); + def->name); goto cleanup; } =20 @@ -849,13 +861,12 @@ storagePoolUndefine(virStoragePoolPtr pool) autostartLink, virStrerror(errno, ebuf, sizeof(ebuf))); } =20 - - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_UNDEFIN= ED, 0); =20 - VIR_INFO("Undefining storage pool '%s'", obj->def->name); + VIR_INFO("Undefining storage pool '%s'", def->name); virStoragePoolObjRemove(&driver->pools, obj); obj =3D NULL; ret =3D 0; @@ -874,6 +885,7 @@ storagePoolCreate(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; int ret =3D -1; @@ -889,17 +901,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 @@ -916,16 +929,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); @@ -934,8 +946,8 @@ storagePoolCreate(virStoragePoolPtr pool, goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 @@ -956,23 +968,25 @@ storagePoolBuild(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; 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 @@ -999,6 +1013,7 @@ static int storagePoolDestroy(virStoragePoolPtr pool) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; char *stateFile =3D NULL; @@ -1007,31 +1022,30 @@ storagePoolDestroy(virStoragePoolPtr pool) storageDriverLock(); if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolDestroyEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolDestroyEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 - VIR_INFO("Destroying storage pool '%s'", obj->def->name); + VIR_INFO("Destroying storage pool '%s'", def->name); =20 if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), obj->def->nam= e); + _("storage pool '%s' is not active"), def->name); goto cleanup; } =20 if (virStoragePoolObjGetAsyncjobs(obj) > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - obj->def->name); + def->name); goto cleanup; } =20 - if (!(stateFile =3D virFileBuildPath(driver->stateDir, - obj->def->name, - ".xml"))) + if (!(stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xm= l"))) goto cleanup; =20 unlink(stateFile); @@ -1043,8 +1057,8 @@ storagePoolDestroy(virStoragePoolPtr pool) =20 virStoragePoolObjClearVols(obj); =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_STOPPED, 0); =20 @@ -1068,6 +1082,7 @@ storagePoolDelete(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; char *stateFile =3D NULL; @@ -1075,32 +1090,31 @@ storagePoolDelete(virStoragePoolPtr pool, =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolDeleteEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolDeleteEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 - VIR_INFO("Deleting storage pool '%s'", obj->def->name); + VIR_INFO("Deleting storage pool '%s'", def->name); =20 if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is still active"), - obj->def->name); + def->name); goto cleanup; } =20 if (virStoragePoolObjGetAsyncjobs(obj) > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - obj->def->name); + def->name); goto cleanup; } =20 - if (!(stateFile =3D virFileBuildPath(driver->stateDir, - obj->def->name, - ".xml"))) + if (!(stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xm= l"))) goto cleanup; =20 unlink(stateFile); @@ -1134,6 +1148,7 @@ storagePoolRefresh(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; int ret =3D -1; virObjectEventPtr event =3D NULL; @@ -1143,23 +1158,24 @@ storagePoolRefresh(virStoragePoolPtr pool, storageDriverLock(); if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolRefreshEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolRefreshEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if ((backend =3D virStorageBackendForType(obj->def->type)) =3D=3D NULL) + if ((backend =3D virStorageBackendForType(def->type)) =3D=3D NULL) goto cleanup; =20 if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool '%s' is not active"), obj->def->nam= e); + _("storage pool '%s' is not active"), def->name); goto cleanup; } =20 if (virStoragePoolObjGetAsyncjobs(obj) > 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pool '%s' has asynchronous jobs running."), - obj->def->name); + def->name); goto cleanup; } =20 @@ -1168,8 +1184,8 @@ storagePoolRefresh(virStoragePoolPtr pool, if (backend->stopPool) backend->stopPool(pool->conn, obj); =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_STO= PPED, 0); virStoragePoolObjSetActive(obj, false); @@ -1179,8 +1195,8 @@ storagePoolRefresh(virStoragePoolPtr pool, goto cleanup; } =20 - event =3D virStoragePoolEventRefreshNew(obj->def->name, - obj->def->uuid); + event =3D virStoragePoolEventRefreshNew(def->name, + def->uuid); ret =3D 0; =20 cleanup: @@ -1198,15 +1214,17 @@ storagePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; int ret =3D -1; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 - if (virStoragePoolGetInfoEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolGetInfoEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if (virStorageBackendForType(obj->def->type) =3D=3D NULL) + if (virStorageBackendForType(def->type) =3D=3D NULL) goto cleanup; =20 memset(info, 0, sizeof(virStoragePoolInfo)); @@ -1214,9 +1232,9 @@ storagePoolGetInfo(virStoragePoolPtr pool, info->state =3D VIR_STORAGE_POOL_RUNNING; else info->state =3D VIR_STORAGE_POOL_INACTIVE; - info->capacity =3D obj->def->capacity; - info->allocation =3D obj->def->allocation; - info->available =3D obj->def->available; + info->capacity =3D def->capacity; + info->allocation =3D def->allocation; + info->available =3D def->available; ret =3D 0; =20 cleanup: @@ -1230,22 +1248,26 @@ storagePoolGetXMLDesc(virStoragePoolPtr pool, { virStoragePoolObjPtr obj; virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; + virStoragePoolDefPtr curDef; char *ret =3D NULL; =20 virCheckFlags(VIR_STORAGE_XML_INACTIVE, NULL); =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return NULL; + def =3D virStoragePoolObjGetDef(obj); + newDef =3D virStoragePoolObjGetNewDef(obj); =20 - if (virStoragePoolGetXMLDescEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolGetXMLDescEnsureACL(pool->conn, def) < 0) goto cleanup; =20 - if ((flags & VIR_STORAGE_XML_INACTIVE) && obj->newDef) - def =3D obj->newDef; + if ((flags & VIR_STORAGE_XML_INACTIVE) && newDef) + curDef =3D newDef; else - def =3D obj->def; + curDef =3D def; =20 - ret =3D virStoragePoolDefFormat(def); + ret =3D virStoragePoolDefFormat(curDef); =20 cleanup: virStoragePoolObjUnlock(obj); @@ -1262,7 +1284,8 @@ storagePoolGetAutostart(virStoragePoolPtr pool, if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) return -1; =20 - if (virStoragePoolGetAutostartEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolGetAutostartEnsureACL(pool->conn, + virStoragePoolObjGetDef(obj)) = < 0) goto cleanup; =20 *autostart =3D virStoragePoolObjIsAutostart(obj) ? 1 : 0; @@ -1289,7 +1312,8 @@ storagePoolSetAutostart(virStoragePoolPtr pool, if (!(obj =3D storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; =20 - if (virStoragePoolSetAutostartEnsureACL(pool->conn, obj->def) < 0) + if (virStoragePoolSetAutostartEnsureACL(pool->conn, + virStoragePoolObjGetDef(obj)) = < 0) goto cleanup; =20 if (!(configFile =3D virStoragePoolObjGetConfigFile(obj))) { @@ -1343,17 +1367,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 @@ -1372,17 +1398,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 @@ -1401,19 +1429,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 @@ -1432,15 +1462,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 @@ -1453,10 +1485,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: @@ -1474,26 +1506,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) @@ -1520,17 +1552,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: @@ -1548,7 +1582,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; } @@ -1570,12 +1604,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); } @@ -1615,18 +1649,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); } @@ -1651,6 +1685,7 @@ storageVolDeleteInternal(virStorageVolPtr vol, unsigned int flags, bool updateMeta) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); int ret =3D -1; =20 if (!backend->deleteVol) { @@ -1668,9 +1703,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 @@ -1688,14 +1723,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 @@ -1707,7 +1744,7 @@ virStorageVolDefFromVol(virStorageVolPtr vol, } =20 if (backend) { - if (!(*backend =3D virStorageBackendForType((*obj)->def->type))) + if (!(*backend =3D virStorageBackendForType(def->type))) goto error; } =20 @@ -1733,7 +1770,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) { @@ -1767,6 +1805,7 @@ storageVolCreateXML(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virStorageVolDefPtr voldef =3D NULL; virStorageVolPtr vol =3D NULL, newvol =3D NULL; @@ -1775,17 +1814,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; @@ -1797,7 +1837,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)) { @@ -1819,7 +1859,7 @@ storageVolCreateXML(virStoragePoolPtr pool, if (backend->createVol(pool->conn, obj, voldef) < 0) goto cleanup; =20 - if (!(newvol =3D virGetStorageVol(pool->conn, obj->def->name, voldef->= name, + if (!(newvol =3D virGetStorageVol(pool->conn, def->name, voldef->name, voldef->key, NULL, NULL))) goto cleanup; =20 @@ -1878,13 +1918,13 @@ storageVolCreateXML(virStoragePoolPtr pool, /* Update pool metadata ignoring the disk backend since * it updates the pool values. */ - if (obj->def->type !=3D VIR_STORAGE_POOL_DISK) { - obj->def->allocation +=3D voldef->target.allocation; - obj->def->available -=3D voldef->target.allocation; + if (def->type !=3D VIR_STORAGE_POOL_DISK) { + def->allocation +=3D voldef->target.allocation; + def->available -=3D voldef->target.allocation; } =20 VIR_INFO("Creating volume '%s' in storage pool '%s'", - newvol->name, obj->def->name); + newvol->name, def->name); vol =3D newvol; newvol =3D NULL; voldef =3D NULL; @@ -1904,6 +1944,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolObjPtr objsrc =3D NULL; virStorageBackendPtr backend; virStorageVolDefPtr voldefsrc =3D NULL; @@ -1933,6 +1974,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, @@ -1943,18 +1985,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 ? @@ -1966,12 +2009,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)) { @@ -2027,7 +2070,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, =20 memcpy(shadowvol, voldef, sizeof(*voldef)); =20 - if (!(newvol =3D virGetStorageVol(pool->conn, obj->def->name, voldef->= name, + if (!(newvol =3D virGetStorageVol(pool->conn, def->name, voldef->name, voldef->key, NULL, NULL))) goto cleanup; =20 @@ -2075,13 +2118,13 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, /* Updating pool metadata ignoring the disk backend since * it updates the pool values */ - if (obj->def->type !=3D VIR_STORAGE_POOL_DISK) { - obj->def->allocation +=3D voldef->target.allocation; - obj->def->available -=3D voldef->target.allocation; + if (def->type !=3D VIR_STORAGE_POOL_DISK) { + def->allocation +=3D voldef->target.allocation; + def->available -=3D voldef->target.allocation; } =20 VIR_INFO("Creating volume '%s' in storage pool '%s'", - newvol->name, obj->def->name); + newvol->name, def->name); vol =3D newvol; newvol =3D NULL; voldef =3D NULL; @@ -2115,7 +2158,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) { @@ -2209,6 +2253,7 @@ virStorageVolPoolRefreshThread(void *opaque) =20 virStorageVolStreamInfoPtr cbdata =3D opaque; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virObjectEventPtr event =3D NULL; =20 @@ -2220,16 +2265,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) @@ -2274,6 +2319,7 @@ storageVolUpload(virStorageVolPtr vol, { virStorageBackendPtr backend; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStorageVolDefPtr voldef =3D NULL; virStorageVolStreamInfoPtr cbdata =3D NULL; int ret =3D -1; @@ -2282,8 +2328,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) { @@ -2313,7 +2360,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) @@ -2346,6 +2393,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; @@ -2356,8 +2404,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) { @@ -2402,7 +2451,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; @@ -2425,8 +2474,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; @@ -2460,7 +2509,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) { @@ -2524,7 +2575,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 && @@ -2559,6 +2612,7 @@ storageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) { virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageBackendPtr backend; virStorageVolDefPtr voldef; char *ret =3D NULL; @@ -2567,15 +2621,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); @@ -2593,7 +2648,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)); @@ -3043,9 +3099,10 @@ virStoragePoolObjBuildTempFilePath(virStoragePoolObj= Ptr obj, virStorageVolDefPtr voldef) =20 { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); char *tmp =3D NULL; =20 ignore_value(virAsprintf(&tmp, "%s/%s.%s.secret.XXXXXX", - driver->stateDir, obj->def->name, voldef->nam= e)); + driver->stateDir, def->name, voldef->name)); return tmp; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 23:01:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1507236102616554.8006483631663; Thu, 5 Oct 2017 13:41:42 -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 08694C059B8D; Thu, 5 Oct 2017 20:41:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D5EC060BE4; Thu, 5 Oct 2017 20:41:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9C9B6410B3; Thu, 5 Oct 2017 20:41:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v95KNLho001883 for ; Thu, 5 Oct 2017 16:23:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7CB6560618; Thu, 5 Oct 2017 20:23:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-132.phx2.redhat.com [10.3.117.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4425D60603 for ; Thu, 5 Oct 2017 20:23:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 08694C059B8D Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 5 Oct 2017 16:23:13 -0400 Message-Id: <20171005202315.356-5-jferlan@redhat.com> In-Reply-To: <20171005202315.356-1-jferlan@redhat.com> References: <20171005202315.356-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 4/6] test: Rename @vol to @volDef in testOpenVolumesForPool X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 05 Oct 2017 20:41:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make it more obvious as we're about to need to change how obj->def gets referenced. Perform a couple of minor cleanups along the way too. Signed-off-by: John Ferlan --- src/test/test_driver.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e92768a975..a1a74b8bd1 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1041,7 +1041,7 @@ testOpenVolumesForPool(const char *file, size_t i; int num, ret =3D -1; xmlNodePtr *nodes =3D NULL; - virStorageVolDefPtr def =3D NULL; + virStorageVolDefPtr volDef =3D NULL; =20 /* Find storage volumes */ if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0) @@ -1058,30 +1058,29 @@ testOpenVolumesForPool(const char *file, if (!node) goto error; =20 - def =3D virStorageVolDefParseNode(obj->def, ctxt->doc, node, 0); - if (!def) + if (!(volDef =3D virStorageVolDefParseNode(obj->def, ctxt->doc, no= de, 0))) goto error; =20 - if (def->target.path =3D=3D NULL) { - if (virAsprintf(&def->target.path, "%s/%s", - obj->def->target.path, def->name) < 0) + if (!volDef->target.path) { + if (virAsprintf(&volDef->target.path, "%s/%s", + obj->def->target.path, volDef->name) < 0) goto error; } =20 - if (!def->key && VIR_STRDUP(def->key, def->target.path) < 0) + if (!volDef->key && VIR_STRDUP(volDef->key, volDef->target.path) <= 0) goto error; =20 - if (virStoragePoolObjAddVol(obj, def) < 0) + if (virStoragePoolObjAddVol(obj, volDef) < 0) goto error; =20 - obj->def->allocation +=3D def->target.allocation; + obj->def->allocation +=3D volDef->target.allocation; obj->def->available =3D (obj->def->capacity - obj->def->allocation= ); - def =3D NULL; + volDef =3D NULL; } =20 ret =3D 0; error: - virStorageVolDefFree(def); + virStorageVolDefFree(volDef); VIR_FREE(nodes); return ret; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 23:01:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1507238145277218.4267870806092; Thu, 5 Oct 2017 14:15:45 -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 18191883A5; Thu, 5 Oct 2017 21:15:44 +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 E14C260C96; Thu, 5 Oct 2017 21:15:43 +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 A2EDF18355CA; Thu, 5 Oct 2017 21:15:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v95KNL8r001896 for ; Thu, 5 Oct 2017 16:23:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id D64AE60618; Thu, 5 Oct 2017 20:23:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-132.phx2.redhat.com [10.3.117.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F75C60603 for ; Thu, 5 Oct 2017 20:23:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 18191883A5 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 5 Oct 2017 16:23:14 -0400 Message-Id: <20171005202315.356-6-jferlan@redhat.com> In-Reply-To: <20171005202315.356-1-jferlan@redhat.com> References: <20171005202315.356-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 5/6] test: Create local virStoragePoolObjPtr VolLookup APIs X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 05 Oct 2017 21:15:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than accessing privconn->pools.objs[i] in the for loop, let's use an @obj variable to make it easier to read the code. Signed-off-by: John Ferlan --- src/test/test_driver.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index a1a74b8bd1..e84acf3228 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4905,27 +4905,28 @@ testStorageVolLookupByKey(virConnectPtr conn, const char *key) { testDriverPtr privconn =3D conn->privateData; + virStoragePoolObjPtr obj; size_t i; virStorageVolPtr ret =3D NULL; =20 testDriverLock(privconn); for (i =3D 0; i < privconn->pools.count; i++) { - virStoragePoolObjLock(privconn->pools.objs[i]); - if (virStoragePoolObjIsActive(privconn->pools.objs[i])) { - virStorageVolDefPtr privvol =3D - virStorageVolDefFindByKey(privconn->pools.objs[i], key); + obj =3D privconn->pools.objs[i]; + virStoragePoolObjLock(obj); + if (virStoragePoolObjIsActive(obj)) { + virStorageVolDefPtr privvol =3D virStorageVolDefFindByKey(obj,= key); =20 if (privvol) { ret =3D virGetStorageVol(conn, - privconn->pools.objs[i]->def->name, + obj->def->name, privvol->name, privvol->key, NULL, NULL); - virStoragePoolObjUnlock(privconn->pools.objs[i]); + virStoragePoolObjUnlock(obj); break; } } - virStoragePoolObjUnlock(privconn->pools.objs[i]); + virStoragePoolObjUnlock(obj); } testDriverUnlock(privconn); =20 @@ -4942,27 +4943,28 @@ testStorageVolLookupByPath(virConnectPtr conn, const char *path) { testDriverPtr privconn =3D conn->privateData; + virStoragePoolObjPtr obj; size_t i; virStorageVolPtr ret =3D NULL; =20 testDriverLock(privconn); for (i =3D 0; i < privconn->pools.count; i++) { - virStoragePoolObjLock(privconn->pools.objs[i]); - if (virStoragePoolObjIsActive(privconn->pools.objs[i])) { - virStorageVolDefPtr privvol =3D - virStorageVolDefFindByPath(privconn->pools.objs[i], path); + obj =3D privconn->pools.objs[i]; + virStoragePoolObjLock(obj); + if (virStoragePoolObjIsActive(obj)) { + virStorageVolDefPtr privvol =3D virStorageVolDefFindByPath(obj= , path); =20 if (privvol) { ret =3D virGetStorageVol(conn, - privconn->pools.objs[i]->def->name, + obj->def->name, privvol->name, privvol->key, NULL, NULL); - virStoragePoolObjUnlock(privconn->pools.objs[i]); + virStoragePoolObjUnlock(obj); break; } } - virStoragePoolObjUnlock(privconn->pools.objs[i]); + virStoragePoolObjUnlock(obj); } testDriverUnlock(privconn); =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 23:01:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1507236123127690.9729666905353; Thu, 5 Oct 2017 13:42: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 09BCE2C974D; Thu, 5 Oct 2017 20:42:02 +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 D60E660618; Thu, 5 Oct 2017 20:42:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9A37818355C9; Thu, 5 Oct 2017 20:42:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v95KNMu1001901 for ; Thu, 5 Oct 2017 16:23:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3D01460618; Thu, 5 Oct 2017 20:23:22 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-132.phx2.redhat.com [10.3.117.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 036EA60603 for ; Thu, 5 Oct 2017 20:23:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 09BCE2C974D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 5 Oct 2017 16:23:15 -0400 Message-Id: <20171005202315.356-7-jferlan@redhat.com> In-Reply-To: <20171005202315.356-1-jferlan@redhat.com> References: <20171005202315.356-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST 6/6] test: Use virStoragePoolObjGetDef accessor X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 05 Oct 2017 20:42:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In preparation for privatizing the object, use the accessor. Signed-off-by: John Ferlan --- src/test/test_driver.c | 162 +++++++++++++++++++++++++++------------------= ---- 1 file changed, 91 insertions(+), 71 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e84acf3228..1c48347994 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1037,6 +1037,7 @@ testOpenVolumesForPool(const char *file, virStoragePoolObjPtr obj, int objidx) { + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); char *vol_xpath; size_t i; int num, ret =3D -1; @@ -1058,12 +1059,12 @@ testOpenVolumesForPool(const char *file, if (!node) goto error; =20 - if (!(volDef =3D virStorageVolDefParseNode(obj->def, ctxt->doc, no= de, 0))) + if (!(volDef =3D virStorageVolDefParseNode(def, ctxt->doc, node, 0= ))) goto error; =20 if (!volDef->target.path) { if (virAsprintf(&volDef->target.path, "%s/%s", - obj->def->target.path, volDef->name) < 0) + def->target.path, volDef->name) < 0) goto error; } =20 @@ -1073,8 +1074,8 @@ testOpenVolumesForPool(const char *file, if (virStoragePoolObjAddVol(obj, volDef) < 0) goto error; =20 - obj->def->allocation +=3D volDef->target.allocation; - obj->def->available =3D (obj->def->capacity - obj->def->allocation= ); + def->allocation +=3D volDef->target.allocation; + def->available =3D (def->capacity - def->allocation); volDef =3D NULL; } =20 @@ -4056,10 +4057,11 @@ static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj) { char *configFile; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); =20 - obj->def->capacity =3D defaultPoolCap; - obj->def->allocation =3D defaultPoolAlloc; - obj->def->available =3D defaultPoolCap - defaultPoolAlloc; + def->capacity =3D defaultPoolCap; + def->allocation =3D defaultPoolAlloc; + def->available =3D defaultPoolCap - defaultPoolAlloc; =20 if (VIR_STRDUP(configFile, "") < 0) return -1; @@ -4156,13 +4158,14 @@ testStoragePoolLookupByUUID(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindByUUID(privconn, uuid))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, - NULL, NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 virStoragePoolObjUnlock(obj); return pool; @@ -4175,13 +4178,14 @@ testStoragePoolLookupByName(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindByName(privconn, name))) return NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, - NULL, NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 virStoragePoolObjUnlock(obj); return pool; @@ -4426,38 +4430,40 @@ testStoragePoolCreateXML(virConnectPtr conn, unsigned int flags) { testDriverPtr privconn =3D conn->privateData; - virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, NULL); =20 testDriverLock(privconn); - if (!(def =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - obj =3D virStoragePoolObjFindByUUID(&privconn->pools, def->uuid); + obj =3D virStoragePoolObjFindByUUID(&privconn->pools, newDef->uuid); if (!obj) - obj =3D virStoragePoolObjFindByName(&privconn->pools, def->name); + obj =3D virStoragePoolObjFindByName(&privconn->pools, newDef->name= ); if (obj) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("storage pool already exists")); goto cleanup; } =20 - if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, newDef))) goto cleanup; - def =3D NULL; + newDef =3D NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - if (obj->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_H= OST) { + if (def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { /* In the real code, we'd call virVHBAManageVport followed by * find_new_device, but we cannot do that here since we're not * mocking udev. The mock routine will copy an existing vHBA and * rename a few fields to mock that. */ if (testCreateVport(privconn, - obj->def->source.adapter.data.fchost.wwnn, - obj->def->source.adapter.data.fchost.wwpn) < 0= ) { + def->source.adapter.data.fchost.wwnn, + def->source.adapter.data.fchost.wwpn) < 0) { virStoragePoolObjRemove(&privconn->pools, obj); obj =3D NULL; goto cleanup; @@ -4477,14 +4483,14 @@ testStoragePoolCreateXML(virConnectPtr conn, =20 virStoragePoolObjSetActive(obj, true); =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uu= id, + event =3D virStoragePoolEventLifecycleNew(def->name, def->uuid, VIR_STORAGE_POOL_EVENT_STARTED, 0); =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: - virStoragePoolDefFree(def); + virStoragePoolDefFree(newDef); testObjectEventQueue(privconn, event); if (obj) virStoragePoolObjUnlock(obj); @@ -4499,26 +4505,28 @@ testStoragePoolDefineXML(virConnectPtr conn, unsigned int flags) { testDriverPtr privconn =3D conn->privateData; - virStoragePoolDefPtr def; + virStoragePoolDefPtr newDef; virStoragePoolObjPtr obj =3D NULL; + virStoragePoolDefPtr def; virStoragePoolPtr pool =3D NULL; virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, NULL); =20 testDriverLock(privconn); - if (!(def =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - def->capacity =3D defaultPoolCap; - def->allocation =3D defaultPoolAlloc; - def->available =3D defaultPoolCap - defaultPoolAlloc; + newDef->capacity =3D defaultPoolCap; + newDef->allocation =3D defaultPoolAlloc; + newDef->available =3D defaultPoolCap - defaultPoolAlloc; =20 - if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, def))) + if (!(obj =3D virStoragePoolObjAssignDef(&privconn->pools, newDef))) goto cleanup; - def =3D NULL; + newDef =3D NULL; + def =3D virStoragePoolObjGetDef(obj); =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uu= id, + event =3D virStoragePoolEventLifecycleNew(def->name, def->uuid, VIR_STORAGE_POOL_EVENT_DEFINED, 0); =20 @@ -4528,10 +4536,10 @@ testStoragePoolDefineXML(virConnectPtr conn, goto cleanup; } =20 - pool =3D virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,= NULL); + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: - virStoragePoolDefFree(def); + virStoragePoolDefFree(newDef); testObjectEventQueue(privconn, event); if (obj) virStoragePoolObjUnlock(obj); @@ -4624,24 +4632,25 @@ testStoragePoolDestroy(virStoragePoolPtr pool) { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; int ret =3D -1; virObjectEventPtr event =3D NULL; =20 if (!(obj =3D testStoragePoolObjFindActiveByName(privconn, pool->name)= )) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 virStoragePoolObjSetActive(obj, false); =20 - if (obj->def->source.adapter.type =3D=3D - VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { + if (def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { if (testDestroyVport(privconn, - obj->def->source.adapter.data.fchost.wwnn, - obj->def->source.adapter.data.fchost.wwpn) < = 0) + def->source.adapter.data.fchost.wwnn, + def->source.adapter.data.fchost.wwpn) < 0) goto cleanup; } =20 - event =3D virStoragePoolEventLifecycleNew(obj->def->name, - obj->def->uuid, + event =3D virStoragePoolEventLifecycleNew(def->name, + def->uuid, VIR_STORAGE_POOL_EVENT_STOPPED, 0); =20 @@ -4710,18 +4719,20 @@ testStoragePoolGetInfo(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; =20 if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) return -1; + def =3D virStoragePoolObjGetDef(obj); =20 memset(info, 0, sizeof(virStoragePoolInfo)); if (virStoragePoolObjIsActive(obj)) info->state =3D VIR_STORAGE_POOL_RUNNING; else info->state =3D VIR_STORAGE_POOL_INACTIVE; - info->capacity =3D obj->def->capacity; - info->allocation =3D obj->def->allocation; - info->available =3D obj->def->available; + info->capacity =3D def->capacity; + info->allocation =3D def->allocation; + info->available =3D def->available; =20 virStoragePoolObjUnlock(obj); return 0; @@ -4741,7 +4752,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; @@ -4881,16 +4892,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 @@ -4906,6 +4919,7 @@ testStorageVolLookupByKey(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; size_t i; virStorageVolPtr ret =3D NULL; =20 @@ -4913,14 +4927,13 @@ testStorageVolLookupByKey(virConnectPtr conn, for (i =3D 0; i < privconn->pools.count; i++) { obj =3D privconn->pools.objs[i]; virStoragePoolObjLock(obj); + def =3D virStoragePoolObjGetDef(obj); if (virStoragePoolObjIsActive(obj)) { virStorageVolDefPtr privvol =3D virStorageVolDefFindByKey(obj,= key); =20 if (privvol) { - ret =3D virGetStorageVol(conn, - obj->def->name, - privvol->name, - privvol->key, + ret =3D virGetStorageVol(conn, def->name, + privvol->name, privvol->key, NULL, NULL); virStoragePoolObjUnlock(obj); break; @@ -4944,6 +4957,7 @@ testStorageVolLookupByPath(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; size_t i; virStorageVolPtr ret =3D NULL; =20 @@ -4951,14 +4965,13 @@ testStorageVolLookupByPath(virConnectPtr conn, for (i =3D 0; i < privconn->pools.count; i++) { obj =3D privconn->pools.objs[i]; virStoragePoolObjLock(obj); + def =3D virStoragePoolObjGetDef(obj); if (virStoragePoolObjIsActive(obj)) { virStorageVolDefPtr privvol =3D virStorageVolDefFindByPath(obj= , path); =20 if (privvol) { - ret =3D virGetStorageVol(conn, - obj->def->name, - privvol->name, - privvol->key, + ret =3D virGetStorageVol(conn, def->name, + privvol->name, privvol->key, NULL, NULL); virStoragePoolObjUnlock(obj); break; @@ -4983,6 +4996,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageVolDefPtr privvol =3D NULL; virStorageVolPtr ret =3D NULL; =20 @@ -4990,8 +5004,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 @@ -5002,8 +5017,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); @@ -5011,17 +5026,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; @@ -5041,6 +5056,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 @@ -5048,8 +5064,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 @@ -5068,27 +5085,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; @@ -5106,6 +5122,7 @@ testStorageVolDelete(virStorageVolPtr vol, { testDriverPtr privconn =3D vol->conn->privateData; virStoragePoolObjPtr obj; + virStoragePoolDefPtr def; virStorageVolDefPtr privvol; int ret =3D -1; =20 @@ -5113,12 +5130,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 @@ -5151,17 +5169,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; @@ -5189,7 +5209,7 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, if (!(privvol =3D testStorageVolDefFindByName(obj, vol->name))) goto cleanup; =20 - ret =3D virStorageVolDefFormat(obj->def, privvol); + ret =3D virStorageVolDefFormat(virStoragePoolObjGetDef(obj), privvol); =20 cleanup: virStoragePoolObjUnlock(obj); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list