From nobody Wed Apr 24 21:30:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490875384179451.7609449270939; Thu, 30 Mar 2017 05:03:04 -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 42F09C0D6365; Thu, 30 Mar 2017 12:02:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E0BC8470C; Thu, 30 Mar 2017 12:02:58 +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 BC1F8B3484; Thu, 30 Mar 2017 12:02:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2UC2vZs009492 for ; Thu, 30 Mar 2017 08:02:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 198577DA07; Thu, 30 Mar 2017 12:02:57 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 635D07DA0E; Thu, 30 Mar 2017 12:02:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 42F09C0D6365 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 42F09C0D6365 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 30 Mar 2017 14:03:45 +0200 Message-Id: <61077f18304ba0327ee41823609613f7fc6256f3.1490875396.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 1/3] storage: backend: Use correct stringifier for pool type X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 30 Mar 2017 12:03:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When registering a storage poll backend, the code would use virStorageTypeToString instead of virStoragePoolTypeToString. The following message would be logged: virDriverLoadModuleFunc:71 : Lookup function 'virStorageBackendSCSIRegister' virStorageBackendRegister:174 : Registering storage backend '(null)' --- src/storage/storage_backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index ce278b99c..7f892df7e 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -171,7 +171,7 @@ int virStorageBackendRegister(virStorageBackendPtr backend) { VIR_DEBUG("Registering storage backend '%s'", - virStorageTypeToString(backend->type)); + NULLSTR(virStoragePoolTypeToString(backend->type))); if (virStorageBackendsCount >=3D VIR_STORAGE_BACKENDS_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, --=20 2.12.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 21:30:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490875387256283.23058291994414; Thu, 30 Mar 2017 05:03:07 -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 8B5A97F74F; Thu, 30 Mar 2017 12:03:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A14E7841C; Thu, 30 Mar 2017 12:03:05 +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 0203BB3487; Thu, 30 Mar 2017 12:03:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2UC2wHW009525 for ; Thu, 30 Mar 2017 08:02:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id B825F7DA0E; Thu, 30 Mar 2017 12:02:58 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A4D67DA06; Thu, 30 Mar 2017 12:02:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8B5A97F74F Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8B5A97F74F From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 30 Mar 2017 14:03:46 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 2/3] storage: driver: Split out code fixing pool state after deactivation 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.27]); Thu, 30 Mar 2017 12:03:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" After a pool is made inactive the definition objects need to be updated (if a new definition is prepared) and transient pools need to be completely removed. Split out the code doing these steps into a separate function for later reuse. --- src/storage/storage_driver.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 61c5e7eff..618b640a2 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -77,6 +77,31 @@ static void storageDriverUnlock(void) virMutexUnlock(&driver->lock); } + +/** + * virStoragePoolUpdateInactive: + * @poolptr: pointer to a variable holding the pool object pointer + * + * This function is supposed to be called after a pool becomes inactive. T= he + * function switches to the new config object for persistent pools. Inacti= ve + * pools are removed. + */ +static void +virStoragePoolUpdateInactive(virStoragePoolObjPtr *poolptr) +{ + virStoragePoolObjPtr pool =3D *poolptr; + + if (pool->configFile =3D=3D NULL) { + virStoragePoolObjRemove(&driver->pools, pool); + *poolptr =3D NULL; + } else if (pool->newDef) { + virStoragePoolDefFree(pool->def); + pool->def =3D pool->newDef; + pool->newDef =3D NULL; + } +} + + static void storagePoolUpdateState(virStoragePoolObjPtr pool) { @@ -1071,14 +1096,7 @@ storagePoolDestroy(virStoragePoolPtr obj) pool->active =3D false; - if (pool->configFile =3D=3D NULL) { - virStoragePoolObjRemove(&driver->pools, pool); - pool =3D NULL; - } else if (pool->newDef) { - virStoragePoolDefFree(pool->def); - pool->def =3D pool->newDef; - pool->newDef =3D NULL; - } + virStoragePoolUpdateInactive(&pool); ret =3D 0; @@ -1200,10 +1218,8 @@ storagePoolRefresh(virStoragePoolPtr obj, 0); pool->active =3D false; - if (pool->configFile =3D=3D NULL) { - virStoragePoolObjRemove(&driver->pools, pool); - pool =3D NULL; - } + virStoragePoolUpdateInactive(&pool); + goto cleanup; } --=20 2.12.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 21:30:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490875387370788.0620197196218; Thu, 30 Mar 2017 05:03:07 -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 950E37E9F4; Thu, 30 Mar 2017 12:03:05 +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 5D68778420; Thu, 30 Mar 2017 12:03:05 +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 05FC418523CE; Thu, 30 Mar 2017 12:03:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2UC30Fe009544 for ; Thu, 30 Mar 2017 08:03:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 14C667DA0A; Thu, 30 Mar 2017 12:03:00 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56E9F71C9A; Thu, 30 Mar 2017 12:02:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 950E37E9F4 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 950E37E9F4 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 30 Mar 2017 14:03:47 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 3/3] storage: driver: Remove unavailable transient pools after restart 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.26]); Thu, 30 Mar 2017 12:03:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If a transient storage pool is deemed inactive after libvirtd restart it would not be deleted from the list. Reuse virStoragePoolUpdateInactive along with a refactor necessary to properly update the state. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1242801 --- src/storage/storage_driver.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 618b640a2..fea769887 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -105,31 +105,28 @@ virStoragePoolUpdateInactive(virStoragePoolObjPtr *po= olptr) static void storagePoolUpdateState(virStoragePoolObjPtr pool) { - bool active; + bool active =3D false; virStorageBackendPtr backend; - int ret =3D -1; char *stateFile; if (!(stateFile =3D virFileBuildPath(driver->stateDir, pool->def->name, ".xml"))) - goto error; + goto cleanup; if ((backend =3D virStorageBackendForType(pool->def->type)) =3D=3D NUL= L) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Missing backend %d"), pool->def->type); - goto error; + goto cleanup; } /* Backends which do not support 'checkPool' are considered - * inactive by default. - */ - active =3D false; + * inactive by default. */ if (backend->checkPool && backend->checkPool(pool, &active) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to initialize storage pool '%s': %s"), pool->def->name, virGetLastErrorMessage()); - goto error; + active =3D false; } /* We can pass NULL as connection, most backends do not use @@ -144,17 +141,18 @@ storagePoolUpdateState(virStoragePoolObjPtr pool) virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to restart storage pool '%s': %s"), pool->def->name, virGetLastErrorMessage()); - goto error; + active =3D false; } } pool->active =3D active; - ret =3D 0; - error: - if (ret < 0) { - if (stateFile) - unlink(stateFile); - } + + if (!pool->active) + virStoragePoolUpdateInactive(&pool); + + cleanup: + if (!active && stateFile) + ignore_value(unlink(stateFile)); VIR_FREE(stateFile); return; --=20 2.12.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list