From nobody Thu May 15 19:20:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1503580170834434.4296810483312; Thu, 24 Aug 2017 06:09:30 -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 2A6EC461E0; Thu, 24 Aug 2017 13:09:29 +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 0A6597B8D7; Thu, 24 Aug 2017 13:09: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 BF7AB180610A; Thu, 24 Aug 2017 13:09:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7OD9DiW027809 for ; Thu, 24 Aug 2017 09:09:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id EFEB67B8D4; Thu, 24 Aug 2017 13:09:13 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-123-165.rdu2.redhat.com [10.10.123.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id B91897CFA4 for ; Thu, 24 Aug 2017 13:09:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2A6EC461E0 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, 24 Aug 2017 09:08:59 -0400 Message-Id: <20170824130905.5199-7-jferlan@redhat.com> In-Reply-To: <20170824130905.5199-1-jferlan@redhat.com> References: <20170824130905.5199-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 06/12] storage: Use virStoragePoolObj{Get|Set}ConfigFile 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.29]); Thu, 24 Aug 2017 13:09:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the new accessor APIs for storage_driver and test_driver. Signed-off-by: John Ferlan --- src/storage/storage_backend_scsi.c | 4 +++- src/storage/storage_driver.c | 14 +++++++------- src/test/test_driver.c | 20 ++++++++++++-------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index 575e6a6..02fd4b6 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -443,8 +443,10 @@ static int virStorageBackendSCSIStartPool(virConnectPtr conn, virStoragePoolObjPtr pool) { + const char *configFile =3D virStoragePoolObjGetConfigFile(pool); + if (pool->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_= HOST) - return createVport(conn, pool->def, pool->configFile, + return createVport(conn, pool->def, configFile, &pool->def->source.adapter.data.fchost); =20 return 0; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index b780f9a..7b1396f 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -91,7 +91,7 @@ virStoragePoolUpdateInactive(virStoragePoolObjPtr *objptr) { virStoragePoolObjPtr obj =3D *objptr; =20 - if (obj->configFile =3D=3D NULL) { + if (!virStoragePoolObjGetConfigFile(obj)) { virStoragePoolObjRemove(&driver->pools, obj); *objptr =3D NULL; } else if (obj->newDef) { @@ -643,7 +643,7 @@ storagePoolIsPersistent(virStoragePoolPtr pool) if (virStoragePoolIsPersistentEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - ret =3D obj->configFile ? 1 : 0; + ret =3D virStoragePoolObjGetConfigFile(obj) ? 1 : 0; =20 cleanup: virStoragePoolObjUnlock(obj); @@ -849,7 +849,6 @@ storagePoolUndefine(virStoragePoolPtr pool) obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf= ))); } =20 - VIR_FREE(obj->configFile); VIR_FREE(obj->autostartLink); =20 event =3D virStoragePoolEventLifecycleNew(obj->def->name, @@ -1250,7 +1249,7 @@ storagePoolGetAutostart(virStoragePoolPtr pool, if (virStoragePoolGetAutostartEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if (!obj->configFile) { + if (!virStoragePoolObjGetConfigFile(obj)) { *autostart =3D 0; } else { *autostart =3D obj->autostart; @@ -1268,6 +1267,7 @@ storagePoolSetAutostart(virStoragePoolPtr pool, int autostart) { virStoragePoolObjPtr obj; + const char *configFile; int ret =3D -1; =20 storageDriverLock(); @@ -1277,7 +1277,7 @@ storagePoolSetAutostart(virStoragePoolPtr pool, if (virStoragePoolSetAutostartEnsureACL(pool->conn, obj->def) < 0) goto cleanup; =20 - if (!obj->configFile) { + if (!(configFile =3D virStoragePoolObjGetConfigFile(obj))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("pool has no config file")); goto cleanup; @@ -1294,10 +1294,10 @@ storagePoolSetAutostart(virStoragePoolPtr pool, goto cleanup; } =20 - if (symlink(obj->configFile, obj->autostartLink) < 0) { + if (symlink(configFile, obj->autostartLink) < 0) { virReportSystemError(errno, _("Failed to create symlink '%s' to '= %s'"), - obj->autostartLink, obj->configFile); + obj->autostartLink, configFile); goto cleanup; } } else { diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 67b115f..36e5ba1 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4056,12 +4056,17 @@ testInterfaceDestroy(virInterfacePtr iface, static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj) { + char *configFile; =20 obj->def->capacity =3D defaultPoolCap; obj->def->allocation =3D defaultPoolAlloc; obj->def->available =3D defaultPoolCap - defaultPoolAlloc; =20 - return VIR_STRDUP(obj->configFile, ""); + if (VIR_STRDUP(configFile, "") < 0) + return -1; + + virStoragePoolObjSetConfigFile(obj, configFile); + return 0; } =20 =20 @@ -4303,7 +4308,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; @@ -4469,7 +4474,7 @@ 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); + virStoragePoolObjSetConfigFile(obj, NULL); =20 obj->active =3D true; =20 @@ -4634,7 +4639,7 @@ testStoragePoolDestroy(virStoragePoolPtr pool) VIR_STORAGE_POOL_EVENT_STOPPED, 0); =20 - if (obj->configFile =3D=3D NULL) { + if (!(virStoragePoolObjGetConfigFile(obj))) { virStoragePoolObjRemove(&privconn->pools, obj); obj =3D NULL; } @@ -4740,11 +4745,10 @@ testStoragePoolGetAutostart(virStoragePoolPtr pool, if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) return -1; =20 - if (!obj->configFile) { + if (!virStoragePoolObjGetConfigFile(obj)) *autostart =3D 0; - } else { + else *autostart =3D obj->autostart; - } =20 virStoragePoolObjUnlock(obj); return 0; @@ -4762,7 +4766,7 @@ testStoragePoolSetAutostart(virStoragePoolPtr pool, if (!(obj =3D testStoragePoolObjFindByName(privconn, pool->name))) return -1; =20 - if (!obj->configFile) { + if (!virStoragePoolObjGetConfigFile(obj)) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("pool has no config file")); goto cleanup; --=20 2.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list