From patchwork Thu Jun 23 00:12:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 70701 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp167492qgy; Wed, 22 Jun 2016 17:14:55 -0700 (PDT) X-Received: by 10.28.85.3 with SMTP id j3mr11085126wmb.0.1466640895209; Wed, 22 Jun 2016 17:14:55 -0700 (PDT) Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com. [209.132.183.25]) by mx.google.com with ESMTPS id c6si2120029wmd.102.2016.06.22.17.14.54 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 Jun 2016 17:14:55 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 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 mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u5N0CMYU015979; Wed, 22 Jun 2016 20:12:22 -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 u5N0CKS1003805 for ; Wed, 22 Jun 2016 20:12:20 -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 u5N0CHC4010243; Wed, 22 Jun 2016 20:12:20 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 22 Jun 2016 20:12:13 -0400 Message-Id: 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 3/6] storage: Handle transient pool removal in driver startup 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 Currently transient storage pools can end up in a shutoff state via driver startup https://bugzilla.redhat.com/show_bug.cgi?id=1227475 Use storagePoolSetInactive to handle transient pool removal in this case. There's some weirdness here though because this can happen while we are iterating over the storage pool list --- src/storage/storage_driver.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 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 c7ffea8..45f00e0 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -102,12 +102,16 @@ storagePoolSetInactive(virStoragePoolObjPtr pool) return ret; } -static void +/* + * Returns true if pool was removed from driver->pools, via + * storagePoolSetInactive + */ +static bool storagePoolUpdateState(virStoragePoolObjPtr pool) { - bool active; + bool active = false; virStorageBackendPtr backend; - int ret = -1; + bool ret = false; char *stateFile; if (!(stateFile = virFileBuildPath(driver->stateDir, @@ -123,7 +127,6 @@ storagePoolUpdateState(virStoragePoolObjPtr pool) /* Backends which do not support 'checkPool' are considered * inactive by default. */ - active = false; if (backend->checkPool && backend->checkPool(pool, &active) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -149,15 +152,15 @@ storagePoolUpdateState(virStoragePoolObjPtr pool) } pool->active = active; - ret = 0; error: - if (ret < 0) { + if (!active) { + ret = storagePoolSetInactive(pool); if (stateFile) unlink(stateFile); } VIR_FREE(stateFile); - return; + return ret; } static void @@ -169,7 +172,13 @@ storagePoolUpdateAllState(void) virStoragePoolObjPtr pool = driver->pools.objs[i]; virStoragePoolObjLock(pool); - storagePoolUpdateState(pool); + if (storagePoolUpdateState(pool)) { + /* The transient pool was removed from the list, while we + are iterating over the list. Adjust the counter backwards + to match */ + --i; + continue; + } virStoragePoolObjUnlock(pool); } }