From patchwork Thu Jun 23 00:12:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 70702 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp167501qgy; Wed, 22 Jun 2016 17:14:58 -0700 (PDT) X-Received: by 10.28.142.194 with SMTP id q185mr10887310wmd.6.1466640898230; Wed, 22 Jun 2016 17:14:58 -0700 (PDT) Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com. [209.132.183.24]) by mx.google.com with ESMTPS id m124si2109610wmm.119.2016.06.22.17.14.57 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 Jun 2016 17:14:58 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u5N0CgPW016281; Wed, 22 Jun 2016 20:12:42 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u5N0CM0x003819 for ; Wed, 22 Jun 2016 20:12:22 -0400 Received: from colepc.redhat.com (ovpn-116-65.rdu2.redhat.com [10.10.116.65]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5N0CHC6010243; Wed, 22 Jun 2016 20:12:21 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 22 Jun 2016 20:12:15 -0400 Message-Id: <107986c706e93e31c5b3de471688f0c4b542e256.1466640165.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/6] storage: Unlink stateFile in storagePoolSetInactive 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 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com There are several places in the storage driver where a runtime stateFile is not being unlinked when the pool is shutdown. Move the unlinking to storagePoolSetInactive to fix those locations One minor semantic change is that we no longer fail PoolDestroy if we fail to build the stateFile path string, but I don't think that matters. --- src/storage/storage_driver.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 9e97f62..8f8d098 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -89,6 +89,13 @@ storagePoolSetInactive(virStoragePoolObjPtr pool) { bool ret = false; pool->active = false; + char *stateFile; + + stateFile = virFileBuildPath(driver->stateDir, pool->def->name, ".xml"); + if (stateFile) { + unlink(stateFile); + VIR_FREE(stateFile); + } if (pool->configFile == NULL) { virStoragePoolObjRemove(&driver->pools, pool); @@ -112,11 +119,6 @@ storagePoolUpdateState(virStoragePoolObjPtr pool) bool active = false; virStorageBackendPtr backend; bool ret = false; - char *stateFile; - - if (!(stateFile = virFileBuildPath(driver->stateDir, - pool->def->name, ".xml"))) - goto error; if ((backend = virStorageBackendForType(pool->def->type)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -153,12 +155,8 @@ storagePoolUpdateState(virStoragePoolObjPtr pool) pool->active = active; error: - if (!active) { + if (!active) ret = storagePoolSetInactive(pool); - if (stateFile) - unlink(stateFile); - } - VIR_FREE(stateFile); return ret; } @@ -210,8 +208,6 @@ storageDriverAutostartPool(virConnectPtr conn, if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 || backend->refreshPool(conn, pool) < 0) { - if (stateFile) - unlink(stateFile); if (backend->stopPool) backend->stopPool(conn, pool); virReportError(VIR_ERR_INTERNAL_ERROR, @@ -774,8 +770,6 @@ storagePoolCreateXML(virConnectPtr conn, virStoragePoolObjClearVols(pool); if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 || backend->refreshPool(conn, pool) < 0) { - if (stateFile) - unlink(stateFile); if (backend->stopPool) backend->stopPool(conn, pool); if (storagePoolSetInactive(pool)) @@ -991,8 +985,6 @@ storagePoolCreate(virStoragePoolPtr obj, virStoragePoolObjClearVols(pool); if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 || backend->refreshPool(obj->conn, pool) < 0) { - if (stateFile) - unlink(stateFile); if (backend->stopPool) backend->stopPool(obj->conn, pool); @@ -1060,7 +1052,6 @@ storagePoolDestroy(virStoragePoolPtr obj) virStoragePoolObjPtr pool; virStorageBackendPtr backend; virObjectEventPtr event = NULL; - char *stateFile = NULL; int ret = -1; storageDriverLock(); @@ -1094,13 +1085,6 @@ storagePoolDestroy(virStoragePoolPtr obj) goto cleanup; } - if (!(stateFile = virFileBuildPath(driver->stateDir, - pool->def->name, - ".xml"))) - goto cleanup; - - unlink(stateFile); - VIR_FREE(stateFile); if (backend->stopPool && backend->stopPool(obj->conn, pool) < 0)