From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708620; cv=none; d=zoho.com; s=zohoarc; b=c/YHPlQBn5eXg6alcNOYtWRi+fKpqLUIhZ8QodYmdQAyaMN1VfeZTphm003aH33fWvP+X9RAAbNbhjV3ab9i+P9xWkihmq+GUMXD0w+YbSdGTzSmAfiRBCO2h0cteSjWk+9QxWqdVzrV+2ojqmYONTYQIHxl7hJRu8kr92P3B+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708620; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+O4VdDLuh52EYzAY+6G2dyowRpT+iSOskn2hYAj94ec=; b=Pr6ORuLX+WklQBWu9WzyPtO6PWgftvNXDa94NTNeeuFmOf3N9gdITuQYXTHPvtxqYJ1zgVGTJ/Qrz1AkKIPM4lz3zHTbKYxbKBuPgJ9iRwl5obvDbc5qHQ3+nkAn21ImqZSjRMjUGob5x+13s4KHwXQo5X4S6QkFKe1D6/seolw= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558708620871727.6978503413767; Fri, 24 May 2019 07:37:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6CC188E5E; Fri, 24 May 2019 14:36:28 +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 2926810027BC; Fri, 24 May 2019 14:36:17 +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 9535A5B423; Fri, 24 May 2019 14:36:02 +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 x4OEZxST011296 for ; Fri, 24 May 2019 10:35:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0733369287; Fri, 24 May 2019 14:35:59 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83AD517243 for ; Fri, 24 May 2019 14:35:58 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:37 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 01/11] virStoragePoolObjRemove: Don't unlock pool object upon return 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 24 May 2019 14:36:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The fact that we're removing a pool object from the list of pools doesn't mean we want to unlock it. It violates locking policy too as object locking and unlocking is not done on the same level. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/virstorageobj.c | 5 ++--- src/storage/storage_driver.c | 17 +++-------------- src/test/test_driver.c | 14 +++----------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 31b5af8e9e..6af4a1a22d 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -514,7 +514,6 @@ virStoragePoolObjRemove(virStoragePoolObjListPtr pools, virObjectLock(obj); virHashRemoveEntry(pools->objs, uuidstr); virHashRemoveEntry(pools->objsName, obj->def->name); - virObjectUnlock(obj); virObjectUnref(obj); virObjectRWUnlock(pools); } @@ -1594,13 +1593,13 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pool= s, VIR_FREE(obj->configFile); /* for driver reload */ if (VIR_STRDUP(obj->configFile, path) < 0) { virStoragePoolObjRemove(pools, obj); - virObjectUnref(obj); + virStoragePoolObjEndAPI(&obj); return NULL; } VIR_FREE(obj->autostartLink); /* for driver reload */ if (VIR_STRDUP(obj->autostartLink, autostartLink) < 0) { virStoragePoolObjRemove(pools, obj); - virObjectUnref(obj); + virStoragePoolObjEndAPI(&obj); return NULL; } =20 diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 496d51b1e0..c14620765e 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -125,8 +125,7 @@ virStoragePoolUpdateInactive(virStoragePoolObjPtr *objp= tr) =20 if (!virStoragePoolObjGetConfigFile(obj)) { virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - *objptr =3D NULL; + virStoragePoolObjEndAPI(objptr); } else if (virStoragePoolObjGetNewDef(obj)) { virStoragePoolObjDefUseNewDef(obj); } @@ -760,12 +759,8 @@ storagePoolCreateXML(virConnectPtr conn, =20 if (build_flags || (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) { - if (backend->buildPool(obj, build_flags) < 0) { - virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; - goto cleanup; - } + if (backend->buildPool(obj, build_flags) < 0) + goto error; } } =20 @@ -798,8 +793,6 @@ storagePoolCreateXML(virConnectPtr conn, =20 error: virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } =20 @@ -835,8 +828,6 @@ storagePoolDefineXML(virConnectPtr conn, =20 if (virStoragePoolObjSaveDef(driver, obj, newDef ? newDef : def) < 0) { virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; newDef =3D NULL; goto cleanup; } @@ -903,8 +894,6 @@ storagePoolUndefine(virStoragePoolPtr pool) =20 VIR_INFO("Undefining storage pool '%s'", def->name); virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; ret =3D 0; =20 cleanup: diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7fd06fcfa8..a0f19f5c5c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4595,16 +4595,12 @@ testStoragePoolCreateXML(virConnectPtr conn, def->source.adapter.data.fchost.wwnn, def->source.adapter.data.fchost.wwpn) < 0) { virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } } =20 if (testStoragePoolObjSetDefaults(obj) =3D=3D -1) { virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } =20 @@ -4662,8 +4658,6 @@ testStoragePoolDefineXML(virConnectPtr conn, =20 if (testStoragePoolObjSetDefaults(obj) =3D=3D -1) { virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } =20 @@ -4692,7 +4686,7 @@ testStoragePoolUndefine(virStoragePoolPtr pool) 0); =20 virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); + virStoragePoolObjEndAPI(&obj); =20 virObjectEventStateQueue(privconn->eventState, event); return 0; @@ -4784,11 +4778,9 @@ testStoragePoolDestroy(virStoragePoolPtr pool) VIR_STORAGE_POOL_EVENT_STOPPED, 0); =20 - if (!(virStoragePoolObjGetConfigFile(obj))) { + if (!(virStoragePoolObjGetConfigFile(obj))) virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); - obj =3D NULL; - } + ret =3D 0; =20 cleanup: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708661; cv=none; d=zoho.com; s=zohoarc; b=AQETbNRL/5AKmbYENCecB1msn+4EQEMHCDTkhX3Ur3Zllq/KoirV9FeDZ1e1M/PIVhgaHCmAK3VTe0VVEBL6BkN18C+1QIVLEIHAUkb1/C2POrmmVgFv34sXi6Pzp5lvkRaTNWnjfIMimGJag7xVo5e1plcBIIGZ8TxHa64oJO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708661; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=vIskQvrioZCX+JgzmVM3OlW7YFFqjPeoNoqdOA96ejw=; b=aPArYedkOU6DloFT08yOLHjdqvspzStsc+7FNvkDUtkTiR8FlSgE7XvcpHX7bxHO8NJ7P0ocaeSbDYbGXrPWv0oW5p8dFwdsz80mjlCVg80hbYMVjThBp0IDZMg8hBb5MR60s1+U2OphLzijxzOx3ar0b2ECVDRp4OtTkuEbTAU= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558708661199708.0581669250117; Fri, 24 May 2019 07:37:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8E277E425; Fri, 24 May 2019 14:37:33 +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 627CB10027C4; Fri, 24 May 2019 14:37:31 +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 24EAC1806B0F; Fri, 24 May 2019 14:37:28 +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 x4OEZx7M011307 for ; Fri, 24 May 2019 10:35:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id CB38469287; Fri, 24 May 2019 14:35:59 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53D4217243 for ; Fri, 24 May 2019 14:35:59 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 02/11] virStoragePoolObjListForEach: Grab a reference for pool object 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 24 May 2019 14:37:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Turns out there's one callback that might remove a storage pool during its run: storagePoolUpdateAllState() call storagePoolUpdateStateCallback() which may call virStoragePoolUpdateInactive() which in turn may call virStoragePoolObjRemove(). Problem is that the UpdateStateCallback() sees a storage pool object with just two references: one for each hash table holding the object. If the function ends up calling ObjRemove() then upon removing the object from hash tables those references are gone and thus any subsequent call touching the object is invalid. The solution to this problem is to grab reference for the object we are running iterator with. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/virstorageobj.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 6af4a1a22d..286f55fb0c 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -411,9 +411,13 @@ virStoragePoolObjListForEachCb(void *payload, virStoragePoolObjPtr obj =3D payload; struct _virStoragePoolObjListForEachData *data =3D opaque; =20 + /* Grab a reference so that we don't rely only on references grabbed by + * hash table earlier. Remember, an iterator can remove object from the + * hash table. */ + virObjectRef(obj); virObjectLock(obj); data->iter(obj, data->opaque); - virObjectUnlock(obj); + virStoragePoolObjEndAPI(&obj); =20 return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708626; cv=none; d=zoho.com; s=zohoarc; b=jQwXLq7p9y3pe24c0w357ONYEKPktjZLR6udcZfdLt1QQ+IOCnlft1e1BG4QuHloijgenT2urreTf3TYl/WmRn449v67ENdLsazEtjt7GMlqQ/F0O/PnS9hOjUfwKvnV/dxhcy1JJ1bs4dS8pCRoobBnyT+4EuIAgIgyJ9Agj9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708626; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=XQ+EpDxAhgJI/OwVsfAHL8Yf/Rw1gi897K/iJ66PmuM=; b=N0o64uRiceOzwKlDvc/Fxu1KsgmThMT3Tu9IpYRfmd3ED6w9wvouWDcUS5hZXIxfKOvTizE187Itbw+YE7/vTzwqFvpA/S7izhYKXzPGAYqEHW28qHeUDBlorslpIa2u7kze63joGLzpWftK2jAcqIgqTUn7yOxHsmtoYWQVtno= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558708626635646.5036046244055; Fri, 24 May 2019 07:37:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D485A3B5E; Fri, 24 May 2019 14:36:47 +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 696AB6928D; Fri, 24 May 2019 14:36:38 +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 DD4645B423; Fri, 24 May 2019 14:36:29 +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 x4OEa0Bg011314 for ; Fri, 24 May 2019 10:36:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D32169287; Fri, 24 May 2019 14:36:00 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 264B26928F for ; Fri, 24 May 2019 14:35:59 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:39 +0200 Message-Id: <1a360afb4d87912d1b8e24f2c8e5fa84a240eba4.1558707820.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 03/11] storagePoolRefreshImpl: Fix variable name in comment 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: , 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 24 May 2019 14:37:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function comment mistakenly refers to 'poolptr' when in fact the variable is named 'objptr'. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index c14620765e..4d26c94e66 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -112,7 +112,7 @@ storagePoolRefreshImpl(virStorageBackendPtr backend, =20 /** * virStoragePoolUpdateInactive: - * @poolptr: pointer to a variable holding the pool object pointer + * @objptr: 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 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708666; cv=none; d=zoho.com; s=zohoarc; b=J7DcKaifR4wnRhimVvxZ9J68qtsj8QrFtrFxSFLRlhj1cMP4NqY+v6ULNFNLti4hH/IqHFFLHfvROjHrRlh+IBvhxAf1aUYZ8KFYqze4/YlmQYKhnq/lJB3jEo3O6Da0/HcoXu3jX3AxJexGG6g5OCAr2O41b87nvpTHwIdbfck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708666; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6MO8yMWEzSxLH+I2jt04rg8AEiqEsrhev8n4/Jw65Jk=; b=SLTOeZVAtbniBvhkg/GkLktRJ+GVoGxEbG4U9CSEsKpIhwLosDhMvYG8G5Brl585/NPfyxImrLKBzLQJ7LNj8uSQGGLxZnxPLcPeQztpoU3Rtof3HcqZ67S8jMY1hhL1ixfhXbq2ykeflaVK7JDDVYd5vdwuGIniXzW3iCor/SA= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558708666619160.4904885414536; Fri, 24 May 2019 07:37:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F103C7E42F; Fri, 24 May 2019 14:37:34 +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 C81D452E9; Fri, 24 May 2019 14:37:33 +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 7A1315B428; Fri, 24 May 2019 14:37:31 +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 x4OEa3qi011333 for ; Fri, 24 May 2019 10:36:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D4186928D; Fri, 24 May 2019 14:36:03 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9258692A1 for ; Fri, 24 May 2019 14:36:00 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:40 +0200 Message-Id: <665e954d771025f550712ce7e2a80a141f05baaa.1558707820.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 04/11] virStoragePoolUpdateInactive: Don't call virStoragePoolObjEndAPI 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 24 May 2019 14:37:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" There is no need for this function to call virStoragePoolObjEndAPI(). The object is perfectly usable after return from this function. In fact, all callers will call virStoragePoolObjEndAPI() eventually. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_driver.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 4d26c94e66..5d3ab1b25f 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -112,20 +112,17 @@ storagePoolRefreshImpl(virStorageBackendPtr backend, =20 /** * virStoragePoolUpdateInactive: - * @objptr: pointer to a variable holding the pool object pointer + * @obj: pool object * * 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 *objptr) +virStoragePoolUpdateInactive(virStoragePoolObjPtr obj) { - virStoragePoolObjPtr obj =3D *objptr; - if (!virStoragePoolObjGetConfigFile(obj)) { virStoragePoolObjRemove(driver->pools, obj); - virStoragePoolObjEndAPI(objptr); } else if (virStoragePoolObjGetNewDef(obj)) { virStoragePoolObjDefUseNewDef(obj); } @@ -176,7 +173,7 @@ storagePoolUpdateStateCallback(virStoragePoolObjPtr obj, virStoragePoolObjSetActive(obj, active); =20 if (!virStoragePoolObjIsActive(obj)) - virStoragePoolUpdateInactive(&obj); + virStoragePoolUpdateInactive(obj); =20 return; } @@ -1076,7 +1073,7 @@ storagePoolDestroy(virStoragePoolPtr pool) =20 virStoragePoolObjSetActive(obj, false); =20 - virStoragePoolUpdateInactive(&obj); + virStoragePoolUpdateInactive(obj); =20 ret =3D 0; =20 @@ -1194,7 +1191,7 @@ storagePoolRefresh(virStoragePoolPtr pool, 0); virStoragePoolObjSetActive(obj, false); =20 - virStoragePoolUpdateInactive(&obj); + virStoragePoolUpdateInactive(obj); =20 goto cleanup; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708661; cv=none; d=zoho.com; s=zohoarc; b=FhOV6L4asnVJESOKHa4rFnC0uB7XFAT3pOsIXAJIZOWl5i6s3uFgKAD/NrsT66/ZVgKgT+xALclP2hIsj7u3yRSw8G9yVYt3JGkNmGCzQhd9xaDE4syJ4Kh4Bo23hGVFUnpDjWRL699dfKXQsspSSto2xwGxQywU1NTGAMIIxdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708661; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=0UvklhwyrIT84cjPrFrvAtC09C0cNfwDgQPGithWpCk=; b=OodMFcGjT+8nLqnpMlauXwAPMi5Vscmy6XdFkzq0Sx5qyAFRSZcJt+QINN1dp/0m6fqelmXqcbaT0wMLN0TBJf2G0ftnDrURFCXXBLNgrfU3ufesX/hbBcaNYCJ59Lh6P00hh1HFRsy7xq0qYqd+SiiHDlxWK9qG3kfQ3jGA4fg= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155870866121189.8165427309599; Fri, 24 May 2019 07:37:41 -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 02F6330198AA; Fri, 24 May 2019 14:37:33 +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 C50C436FB; Fri, 24 May 2019 14:37:32 +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 70AF81806B14; Fri, 24 May 2019 14:37:31 +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 x4OEa4OA011340 for ; Fri, 24 May 2019 10:36:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F16B69287; Fri, 24 May 2019 14:36:04 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA74969294 for ; Fri, 24 May 2019 14:36:03 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:41 +0200 Message-Id: <2e4784d01752dbf888187924a6f18e74f7c8b8f1.1558707820.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 05/11] virstorageobj: Rename virStoragePoolObjAssignDef 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: , 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.47]); Fri, 24 May 2019 14:37:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This function is doing much more than plain assigning pool definition to a pool object. Rename it. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/virstorageobj.c | 12 ++++++------ src/conf/virstorageobj.h | 6 +++--- src/libvirt_private.syms | 2 +- src/storage/storage_driver.c | 4 ++-- src/test/test_driver.c | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 286f55fb0c..7f25931d05 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1506,7 +1506,7 @@ virStoragePoolObjSourceFindDuplicate(virStoragePoolOb= jListPtr pools, =20 =20 /** - * virStoragePoolObjAssignDef: + * virStoragePoolObjListAdd: * @pools: Storage Pool object list pointer * @def: Storage pool definition to add or update * @check_active: If true, ensure that pool is not active @@ -1517,9 +1517,9 @@ virStoragePoolObjSourceFindDuplicate(virStoragePoolOb= jListPtr pools, * Returns locked and reffed object pointer or NULL on error */ virStoragePoolObjPtr -virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools, - virStoragePoolDefPtr def, - bool check_active) +virStoragePoolObjListAdd(virStoragePoolObjListPtr pools, + virStoragePoolDefPtr def, + bool check_active) { virStoragePoolObjPtr obj =3D NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -1590,7 +1590,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools, return NULL; } =20 - if (!(obj =3D virStoragePoolObjAssignDef(pools, def, false))) + if (!(obj =3D virStoragePoolObjListAdd(pools, def, false))) return NULL; def =3D NULL; =20 @@ -1651,7 +1651,7 @@ virStoragePoolObjLoadState(virStoragePoolObjListPtr p= ools, } =20 /* create the object */ - if (!(obj =3D virStoragePoolObjAssignDef(pools, def, true))) + if (!(obj =3D virStoragePoolObjListAdd(pools, def, true))) goto cleanup; def =3D NULL; =20 diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index c41d4c16ad..090dd6a7e6 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -193,9 +193,9 @@ virStoragePoolObjVolumeListExport(virConnectPtr conn, virStoragePoolVolumeACLFilter filter); =20 virStoragePoolObjPtr -virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools, - virStoragePoolDefPtr def, - bool check_active); +virStoragePoolObjListAdd(virStoragePoolObjListPtr pools, + virStoragePoolDefPtr def, + bool check_active); =20 int virStoragePoolObjSaveDef(virStorageDriverStatePtr driver, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 909975750c..8fb366d218 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1178,7 +1178,6 @@ virSecretObjSetValueSize; =20 # conf/virstorageobj.h virStoragePoolObjAddVol; -virStoragePoolObjAssignDef; virStoragePoolObjClearVols; virStoragePoolObjDecrAsyncjobs; virStoragePoolObjDefUseNewDef; @@ -1197,6 +1196,7 @@ virStoragePoolObjGetVolumesCount; virStoragePoolObjIncrAsyncjobs; virStoragePoolObjIsActive; virStoragePoolObjIsAutostart; +virStoragePoolObjListAdd; virStoragePoolObjListExport; virStoragePoolObjListForEach; virStoragePoolObjListNew; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 5d3ab1b25f..b4a56e54bb 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -743,7 +743,7 @@ storagePoolCreateXML(virConnectPtr conn, if ((backend =3D virStorageBackendForType(newDef->type)) =3D=3D NULL) goto cleanup; =20 - if (!(obj =3D virStoragePoolObjAssignDef(driver->pools, newDef, true))) + if (!(obj =3D virStoragePoolObjListAdd(driver->pools, newDef, true))) goto cleanup; newDef =3D NULL; def =3D virStoragePoolObjGetDef(obj); @@ -818,7 +818,7 @@ storagePoolDefineXML(virConnectPtr conn, if (virStorageBackendForType(newDef->type) =3D=3D NULL) goto cleanup; =20 - if (!(obj =3D virStoragePoolObjAssignDef(driver->pools, newDef, false)= )) + if (!(obj =3D virStoragePoolObjListAdd(driver->pools, newDef, false))) goto cleanup; newDef =3D virStoragePoolObjGetNewDef(obj); def =3D virStoragePoolObjGetDef(obj); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index a0f19f5c5c..832943c1fb 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1095,7 +1095,7 @@ testParseStorage(testDriverPtr privconn, if (!def) return -1; =20 - if (!(obj =3D virStoragePoolObjAssignDef(privconn->pools, def, fal= se))) { + if (!(obj =3D virStoragePoolObjListAdd(privconn->pools, def, false= ))) { virStoragePoolDefFree(def); return -1; } @@ -4581,7 +4581,7 @@ testStoragePoolCreateXML(virConnectPtr conn, if (!(newDef =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - if (!(obj =3D virStoragePoolObjAssignDef(privconn->pools, newDef, true= ))) + if (!(obj =3D virStoragePoolObjListAdd(privconn->pools, newDef, true))) goto cleanup; newDef =3D NULL; def =3D virStoragePoolObjGetDef(obj); @@ -4647,7 +4647,7 @@ testStoragePoolDefineXML(virConnectPtr conn, newDef->allocation =3D defaultPoolAlloc; newDef->available =3D defaultPoolCap - defaultPoolAlloc; =20 - if (!(obj =3D virStoragePoolObjAssignDef(privconn->pools, newDef, fals= e))) + if (!(obj =3D virStoragePoolObjListAdd(privconn->pools, newDef, false)= )) goto cleanup; newDef =3D NULL; def =3D virStoragePoolObjGetDef(obj); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708669; cv=none; d=zoho.com; s=zohoarc; b=UyRtvz+6F3mJJwlP32BgLojO0FkcDwJpESv19SQYBRsmR3qTdTPGzb/RdEiJO/gJmCxhRoZzVuyQe28t6JT9P+1DRWMkK1ZdxTquskVpXpD8x+/6nDslQ0IxMIQ+nRl+a95LKV28EUwO4PM0CtfPOlZNF7Qkqw1fTF0tf0PNuBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708669; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=FsbAyN10j34UjvGd9jGn8GhAidXYmpZJlI9ApShI1TQ=; b=TEkfp3zQ9wZQUGRZ3WlJudXAsthgPEZo7Kc7YivefNYHJkimzFgyNtHBbWbOuT3LP/PXq7ZmU3JjQr3/JBeG4M8SdpfH2W++SZ8T6/elkIQiLFboGJSJoX2b6PbBoFbOyAro/gr5Y+24OUPK00nzIuTtn+2zdwHN1FAd5PWT/nM= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558708669295432.34783906965345; Fri, 24 May 2019 07:37:49 -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 1C49E7E9F9; Fri, 24 May 2019 14:37:47 +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 E89DE7D676; Fri, 24 May 2019 14:37:45 +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 A2F395B425; Fri, 24 May 2019 14:37:45 +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 x4OEa55G011345 for ; Fri, 24 May 2019 10:36:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F6146928D; Fri, 24 May 2019 14:36:05 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B91469287 for ; Fri, 24 May 2019 14:36:04 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:42 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 06/11] virStoragePoolObjListAdd: Turn boolean arg into flags 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: , 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.26]); Fri, 24 May 2019 14:37:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" There will be more boolean information that we want to pass to this function. Instead of having them in separate arguments per each one, use @flags. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/virstorageobj.c | 16 +++++++++++----- src/conf/virstorageobj.h | 6 +++++- src/storage/storage_driver.c | 5 +++-- src/test/test_driver.c | 7 ++++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 7f25931d05..7515b5d107 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1509,17 +1509,20 @@ virStoragePoolObjSourceFindDuplicate(virStoragePool= ObjListPtr pools, * virStoragePoolObjListAdd: * @pools: Storage Pool object list pointer * @def: Storage pool definition to add or update - * @check_active: If true, ensure that pool is not active + * @flags: bitwise-OR of VIR_STORAGE_POOL_OBJ_LIST_* flags * * Lookup the @def to see if it already exists in the @pools in order * to either update or add if it does not exist. * + * If VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE is set in @flags + * then this will fail if the pool exists and is active. + * * Returns locked and reffed object pointer or NULL on error */ virStoragePoolObjPtr virStoragePoolObjListAdd(virStoragePoolObjListPtr pools, virStoragePoolDefPtr def, - bool check_active) + unsigned int flags) { virStoragePoolObjPtr obj =3D NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -1530,7 +1533,9 @@ virStoragePoolObjListAdd(virStoragePoolObjListPtr poo= ls, if (virStoragePoolObjSourceFindDuplicate(pools, def) < 0) goto error; =20 - rc =3D virStoragePoolObjIsDuplicate(pools, def, check_active, &obj); + rc =3D virStoragePoolObjIsDuplicate(pools, def, + !!(flags & VIR_STORAGE_POOL_OBJ_LIST= _ADD_CHECK_LIVE), + &obj); =20 if (rc < 0) goto error; @@ -1590,7 +1595,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools, return NULL; } =20 - if (!(obj =3D virStoragePoolObjListAdd(pools, def, false))) + if (!(obj =3D virStoragePoolObjListAdd(pools, def, 0))) return NULL; def =3D NULL; =20 @@ -1651,7 +1656,8 @@ virStoragePoolObjLoadState(virStoragePoolObjListPtr p= ools, } =20 /* create the object */ - if (!(obj =3D virStoragePoolObjListAdd(pools, def, true))) + if (!(obj =3D virStoragePoolObjListAdd(pools, def, + VIR_STORAGE_POOL_OBJ_LIST_ADD_CHE= CK_LIVE))) goto cleanup; def =3D NULL; =20 diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index 090dd6a7e6..fe62515b50 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -192,10 +192,14 @@ virStoragePoolObjVolumeListExport(virConnectPtr conn, virStorageVolPtr **vols, virStoragePoolVolumeACLFilter filter); =20 +enum { + VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE =3D (1 << 1), +}; + virStoragePoolObjPtr virStoragePoolObjListAdd(virStoragePoolObjListPtr pools, virStoragePoolDefPtr def, - bool check_active); + unsigned int flags); =20 int virStoragePoolObjSaveDef(virStorageDriverStatePtr driver, diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index b4a56e54bb..38b83a77b7 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -743,7 +743,8 @@ storagePoolCreateXML(virConnectPtr conn, if ((backend =3D virStorageBackendForType(newDef->type)) =3D=3D NULL) goto cleanup; =20 - if (!(obj =3D virStoragePoolObjListAdd(driver->pools, newDef, true))) + if (!(obj =3D virStoragePoolObjListAdd(driver->pools, newDef, + VIR_STORAGE_POOL_OBJ_LIST_ADD_CHE= CK_LIVE))) goto cleanup; newDef =3D NULL; def =3D virStoragePoolObjGetDef(obj); @@ -818,7 +819,7 @@ storagePoolDefineXML(virConnectPtr conn, if (virStorageBackendForType(newDef->type) =3D=3D NULL) goto cleanup; =20 - if (!(obj =3D virStoragePoolObjListAdd(driver->pools, newDef, false))) + if (!(obj =3D virStoragePoolObjListAdd(driver->pools, newDef, 0))) goto cleanup; newDef =3D virStoragePoolObjGetNewDef(obj); def =3D virStoragePoolObjGetDef(obj); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 832943c1fb..39f5557fe1 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1095,7 +1095,7 @@ testParseStorage(testDriverPtr privconn, if (!def) return -1; =20 - if (!(obj =3D virStoragePoolObjListAdd(privconn->pools, def, false= ))) { + if (!(obj =3D virStoragePoolObjListAdd(privconn->pools, def, 0))) { virStoragePoolDefFree(def); return -1; } @@ -4581,7 +4581,8 @@ testStoragePoolCreateXML(virConnectPtr conn, if (!(newDef =3D virStoragePoolDefParseString(xml))) goto cleanup; =20 - if (!(obj =3D virStoragePoolObjListAdd(privconn->pools, newDef, true))) + if (!(obj =3D virStoragePoolObjListAdd(privconn->pools, newDef, + VIR_STORAGE_POOL_OBJ_LIST_ADD_CHE= CK_LIVE))) goto cleanup; newDef =3D NULL; def =3D virStoragePoolObjGetDef(obj); @@ -4647,7 +4648,7 @@ testStoragePoolDefineXML(virConnectPtr conn, newDef->allocation =3D defaultPoolAlloc; newDef->available =3D defaultPoolCap - defaultPoolAlloc; =20 - if (!(obj =3D virStoragePoolObjListAdd(privconn->pools, newDef, false)= )) + if (!(obj =3D virStoragePoolObjListAdd(privconn->pools, newDef, 0))) goto cleanup; newDef =3D NULL; def =3D virStoragePoolObjGetDef(obj); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708682; cv=none; d=zoho.com; s=zohoarc; b=UW06ALtxV752jRuQo+qO0Xa4PYsHpGTTZN0BvhlaalhQyG3neUDnW98lBgaIr8RIa+JZdYzrvWE7ubkog1ZFTt5zPhk7LF/K5Nk3gCLlWP1cnLud2QByM3DTq4eO0G/qUSU/6fpXtfApB+pVtM/NKonfeEFOK2Q6qHAuo8Kru60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708682; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=5n0mhKFoY1p1Mtz94xLd1OgfxBQ89wDVgqGpd1izhyg=; b=i+TeosM+oXpWVwdvv8Pcu6hv9elfmVn2dK3YTZmF0cg0yHlgtuDgrRz148nV5u4F/NgEDPeiHWnRn0Qm3xZDzYhZoBra+0PC0M8iHrQNVm5uIFxbxoovYMFoR7rdPOFQYTk5idSJRrhGPpDx3l4bJXKD6j6WO93jmUDFg7+CWKw= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558708682482556.2599840140755; Fri, 24 May 2019 07:38:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C88B98F921; Fri, 24 May 2019 14:37:55 +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 912B45B2EB; Fri, 24 May 2019 14:37:54 +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 504355B423; Fri, 24 May 2019 14:37:53 +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 x4OEa5Ze011350 for ; Fri, 24 May 2019 10:36:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id D6B776928D; Fri, 24 May 2019 14:36:05 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DDCD69287 for ; Fri, 24 May 2019 14:36:05 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:43 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 07/11] virStoragePoolObjListAdd: Separate out definition assignment 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 24 May 2019 14:38:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Separate storage pool definition assignment into a function. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/virstorageobj.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 7515b5d107..2b9ad6fc98 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1505,6 +1505,21 @@ virStoragePoolObjSourceFindDuplicate(virStoragePoolO= bjListPtr pools, } =20 =20 +static void +virStoragePoolObjAssignDef(virStoragePoolObjPtr obj, + virStoragePoolDefPtr def, + unsigned int flgs ATTRIBUTE_UNUSED) +{ + if (!virStoragePoolObjIsActive(obj)) { + virStoragePoolDefFree(obj->def); + obj->def =3D def; + } else { + virStoragePoolDefFree(obj->newDef); + obj->newDef =3D def; + } +} + + /** * virStoragePoolObjListAdd: * @pools: Storage Pool object list pointer @@ -1540,14 +1555,8 @@ virStoragePoolObjListAdd(virStoragePoolObjListPtr po= ols, if (rc < 0) goto error; if (rc > 0) { - if (!virStoragePoolObjIsActive(obj)) { - virStoragePoolDefFree(obj->def); - obj->def =3D def; - } else { - virStoragePoolDefFree(obj->newDef); - obj->newDef =3D def; - } virObjectRWUnlock(pools); + virStoragePoolObjAssignDef(obj, def, flags); return obj; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708672; cv=none; d=zoho.com; s=zohoarc; b=jBSIvU/1sOFLnVqDELpJGPnrbPoCYkYkg/NghmWx9t9iUwp0pWaPsQZC33hkkBWC8NyGS+Lbxr7EWfzRjSodW270Pw58r4/Ni0zS0Q6BJCK2rpWUGqMbgi7TgzYgsxbnwQ15uM+5rUC1D9Gwq91H+j9m58yc2UqPIgfj15bWlj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708672; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=XUly71mipJFKPhay56d8IVD9QyTe2RCV4RC88E5wIDI=; b=eA6tPL74rQxvU7v/3H4KhbY2SpbKz9VZqs/WAAdQt9r/fJ+mKerJb8IN16XZPa9Bh1npdvkn8ARggCb+Mdj7rsXzvcvapxea2SOYtMJnmXZrJtwD8WYYAuTOjI3/biZyQpQgmIKX49kjEsd5u1AjV73JnhvguGR8wSZJaAjzTaw= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15587086723141017.404577357265; Fri, 24 May 2019 07:37:52 -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 86703EE569; Fri, 24 May 2019 14:37:50 +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 625BE63BB5; Fri, 24 May 2019 14:37:50 +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 1F2541806B0F; Fri, 24 May 2019 14:37:49 +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 x4OEa8uF011381 for ; Fri, 24 May 2019 10:36:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4350C6928F; Fri, 24 May 2019 14:36:08 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFA68692A3 for ; Fri, 24 May 2019 14:36:06 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:44 +0200 Message-Id: <1ce12c57d42f0df3b3b1f81a2d3ddf2c3a75fd3d.1558707820.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 08/11] virstorageobj: Introduce VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE flag 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: , 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.38]); Fri, 24 May 2019 14:37:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This flag can be used to denote that the definition we're trying to assign to a pool object is live definition and thus the inactive definition should be saved into ->newDef. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/virstorageobj.c | 19 ++++++++++++++----- src/conf/virstorageobj.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 2b9ad6fc98..bdb167e9e2 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1508,14 +1508,18 @@ virStoragePoolObjSourceFindDuplicate(virStoragePool= ObjListPtr pools, static void virStoragePoolObjAssignDef(virStoragePoolObjPtr obj, virStoragePoolDefPtr def, - unsigned int flgs ATTRIBUTE_UNUSED) + unsigned int flags) { - if (!virStoragePoolObjIsActive(obj)) { - virStoragePoolDefFree(obj->def); - obj->def =3D def; - } else { + if (virStoragePoolObjIsActive(obj)) { virStoragePoolDefFree(obj->newDef); obj->newDef =3D def; + } else { + if (!obj->newDef && + flags & VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE) + VIR_STEAL_PTR(obj->newDef, obj->def); + + virStoragePoolDefFree(obj->def); + obj->def =3D def; } } =20 @@ -1529,6 +1533,11 @@ virStoragePoolObjAssignDef(virStoragePoolObjPtr obj, * Lookup the @def to see if it already exists in the @pools in order * to either update or add if it does not exist. * + * Use VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE to denote that @def + * refers to an active definition and thus any possible inactive + * definition found should be saved to ->newDef (in case of + * future restore). + * * If VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE is set in @flags * then this will fail if the pool exists and is active. * diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index fe62515b50..df699a84c5 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -193,6 +193,7 @@ virStoragePoolObjVolumeListExport(virConnectPtr conn, virStoragePoolVolumeACLFilter filter); =20 enum { + VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE=3D (1 << 0), VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE =3D (1 << 1), }; =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708670; cv=none; d=zoho.com; s=zohoarc; b=FXUmNMraVXnJRGtJRb6pGsxhr77u/208VqD4a3KawVX7OlfQQuPO2ulKtu+5Y+w6e8z9fmVPazbEMLoR/VM+O1EwZ3ABsmriMoTv19UG+zb6aqcXP3wpL67WMMxJ6qXxYkV5rmxGI4vTU6blIje2S4aFmdwNwFufOqlsNjUrUSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708670; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=J5Kn8Xt4FzZyEaeCm3rOiSQvK4OTgLvHkJwJW1HbS/k=; b=OwPIzG3SSVDzNyKKPa7XdXTxxUiJMag0MeMSXJbY2SHqsqV9XJHA1FXiVz4TNcDuuLzHSV0Q24nqL58GPEzLIhAVer6o6PkTffjrBTlqLd99+U3EWCt+al+CppzuU8hMOhJeoErcN9p7629JDTdH979KiuG5Jxo+K0Vc0YG0e+0= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15587086709806.622809874496511; Fri, 24 May 2019 07:37:50 -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 39FB7C00C7DD; Fri, 24 May 2019 14:37:49 +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 132B01835C; Fri, 24 May 2019 14:37:48 +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 CB6301806B16; Fri, 24 May 2019 14:37:47 +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 x4OEa90g011392 for ; Fri, 24 May 2019 10:36:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1531B69299; Fri, 24 May 2019 14:36:09 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 912C56928D for ; Fri, 24 May 2019 14:36:08 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 09/11] storagePoolCreateXML: Don't lose persistent storage on failed create 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: , 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.31]); Fri, 24 May 2019 14:37:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If there's a persistent storage and user tries to start a new one with the same name and UUID (e.g. to test new configuration) it may happen that upon failure we lose the persistent defintion. Fortunately, we don't remove it from the disk only from the internal list of the pools. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 38b83a77b7..def4123b82 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -744,6 +744,7 @@ storagePoolCreateXML(virConnectPtr conn, goto cleanup; =20 if (!(obj =3D virStoragePoolObjListAdd(driver->pools, newDef, + VIR_STORAGE_POOL_OBJ_LIST_ADD_LIV= E | VIR_STORAGE_POOL_OBJ_LIST_ADD_CHE= CK_LIVE))) goto cleanup; newDef =3D NULL; @@ -790,7 +791,7 @@ storagePoolCreateXML(virConnectPtr conn, return pool; =20 error: - virStoragePoolObjRemove(driver->pools, obj); + virStoragePoolUpdateInactive(obj); goto cleanup; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708685; cv=none; d=zoho.com; s=zohoarc; b=j+bArlKYr/1P2t53nKcaAmFWAv1pHNinX/6wa/bclcCwqtCqztGKFBGh6iOOt1EX5+2mKyuOoUfP0udYloKm+rl/OygrqW0XSlbZOYLy98h4EFNno1bLHrt0kOnty0fYVQ4miDtjwEDA9yksjAaVS67Fq9ZA3rVAlE1sTj3H1Rw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708685; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bLw5i13Yd8CrvvZ5VXUYpocen0Ub2BnpRmk7a7k0028=; b=jLHs6QSEGG0pL4Gk2qDJ10BGPYZQWwxWqw8OdrTFow2cvmraAxfBfcJkp+Ryr3Qg8YtTlLCT7lDs5pTxAJizNSf5y2V8JDzXf43qKU0mPXH3hg3oyjAajK20tGU5WBRlFvMDIvjGCKmilw5SgioyT0vJX2QN7Svk5NfYV05Rqo8= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558708685104955.3113121334225; Fri, 24 May 2019 07:38:05 -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 CD8913078AC8; Fri, 24 May 2019 14:37:59 +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 A66D57BE7D; Fri, 24 May 2019 14:37:59 +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 653D95B427; Fri, 24 May 2019 14:37:58 +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 x4OEaGPo011417 for ; Fri, 24 May 2019 10:36:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id EA15769287; Fri, 24 May 2019 14:36:16 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71C6D692A1 for ; Fri, 24 May 2019 14:36:09 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 10/11] storage_driver: Protect pool def during startup and build 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: , 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.48]); Fri, 24 May 2019 14:38:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In near future the storage pool object lock will be released during startPool and buildPool callback (in some backends). But this means that another thread may acquire the pool object lock and change its definition rendering the former thread access not only stale definition but also access freed memory (virStoragePoolObjAssignDef() will free old def when setting a new one). One way out of this would be to have the pool appear as active because our code deals with obj->def and obj->newdef just fine. But we can't declare a pool as active if it's not started or still building up. Therefore, have a boolean flag that is very similar and forces virStoragePoolObjAssignDef() to store new definition in obj->newdef even for an inactive pool. In turn, we have to move the definition to correct place when unsetting the flag. But that's as easy as calling virStoragePoolUpdateInactive(). Technically speaking, change made to storageDriverAutostartCallback() is not needed because until storage driver is initialized no storage API can run therefore there can't be anyone wanting to change the pool's definition. But I'm doing the change there for consistency anyways. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/virstorageobj.c | 26 +++++++++++++++++++++++++- src/conf/virstorageobj.h | 6 ++++++ src/libvirt_private.syms | 2 ++ src/storage/storage_driver.c | 31 ++++++++++++++++++++++++++++++- 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index bdb167e9e2..9abcac479e 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -86,6 +86,7 @@ struct _virStoragePoolObj { char *configFile; char *autostartLink; bool active; + bool starting; bool autostart; unsigned int asyncjobs; =20 @@ -312,6 +313,21 @@ virStoragePoolObjSetActive(virStoragePoolObjPtr obj, } =20 =20 +void +virStoragePoolObjSetStarting(virStoragePoolObjPtr obj, + bool starting) +{ + obj->starting =3D starting; +} + + +bool +virStoragePoolObjIsStarting(virStoragePoolObjPtr obj) +{ + return obj->starting; +} + + bool virStoragePoolObjIsAutostart(virStoragePoolObjPtr obj) { @@ -1090,6 +1106,13 @@ virStoragePoolObjIsDuplicate(virStoragePoolObjListPt= r pools, obj->def->name); goto cleanup; } + + if (virStoragePoolObjIsStarting(obj)) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("pool '%s' is starting up"), + obj->def->name); + goto cleanup; + } } =20 VIR_STEAL_PTR(*objRet, obj); @@ -1510,7 +1533,8 @@ virStoragePoolObjAssignDef(virStoragePoolObjPtr obj, virStoragePoolDefPtr def, unsigned int flags) { - if (virStoragePoolObjIsActive(obj)) { + if (virStoragePoolObjIsActive(obj) || + virStoragePoolObjIsStarting(obj)) { virStoragePoolDefFree(obj->newDef); obj->newDef =3D def; } else { diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index df699a84c5..7dfdf42b26 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -92,6 +92,12 @@ void virStoragePoolObjSetActive(virStoragePoolObjPtr obj, bool active); =20 +void +virStoragePoolObjSetStarting(virStoragePoolObjPtr obj, + bool starting); +bool +virStoragePoolObjIsStarting(virStoragePoolObjPtr obj); + bool virStoragePoolObjIsAutostart(virStoragePoolObjPtr obj); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8fb366d218..243e3179cf 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1196,6 +1196,7 @@ virStoragePoolObjGetVolumesCount; virStoragePoolObjIncrAsyncjobs; virStoragePoolObjIsActive; virStoragePoolObjIsAutostart; +virStoragePoolObjIsStarting; virStoragePoolObjListAdd; virStoragePoolObjListExport; virStoragePoolObjListForEach; @@ -1214,6 +1215,7 @@ virStoragePoolObjSetActive; virStoragePoolObjSetAutostart; virStoragePoolObjSetConfigFile; virStoragePoolObjSetDef; +virStoragePoolObjSetStarting; virStoragePoolObjVolumeGetNames; virStoragePoolObjVolumeListExport; =20 diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index def4123b82..60bfa48e25 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -201,12 +201,14 @@ storageDriverAutostartCallback(virStoragePoolObjPtr o= bj, =20 if (virStoragePoolObjIsAutostart(obj) && !virStoragePoolObjIsActive(obj)) { + + virStoragePoolObjSetStarting(obj, true); if (backend->startPool && backend->startPool(obj) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart storage pool '%s': %s"), def->name, virGetLastErrorMessage()); - return; + goto cleanup; } started =3D true; } @@ -225,6 +227,13 @@ storageDriverAutostartCallback(virStoragePoolObjPtr ob= j, virStoragePoolObjSetActive(obj, true); } } + + cleanup: + if (virStoragePoolObjIsStarting(obj)) { + if (!virStoragePoolObjIsActive(obj)) + virStoragePoolUpdateInactive(obj); + virStoragePoolObjSetStarting(obj, false); + } } =20 =20 @@ -750,6 +759,8 @@ storagePoolCreateXML(virConnectPtr conn, newDef =3D NULL; def =3D virStoragePoolObjGetDef(obj); =20 + virStoragePoolObjSetStarting(obj, true); + if (backend->buildPool) { if (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE) build_flags |=3D VIR_STORAGE_POOL_BUILD_OVERWRITE; @@ -786,6 +797,11 @@ storagePoolCreateXML(virConnectPtr conn, pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); =20 cleanup: + if (virStoragePoolObjIsStarting(obj)) { + if (!virStoragePoolObjIsActive(obj)) + virStoragePoolUpdateInactive(obj); + virStoragePoolObjSetStarting(obj, false); + } virObjectEventStateQueue(driver->storageEventState, event); virStoragePoolObjEndAPI(&obj); return pool; @@ -937,6 +953,8 @@ storagePoolCreate(virStoragePoolPtr pool, goto cleanup; } =20 + virStoragePoolObjSetStarting(obj, true); + if (backend->buildPool) { if (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE) build_flags |=3D VIR_STORAGE_POOL_BUILD_OVERWRITE; @@ -972,6 +990,11 @@ storagePoolCreate(virStoragePoolPtr pool, ret =3D 0; =20 cleanup: + if (virStoragePoolObjIsStarting(obj)) { + if (!virStoragePoolObjIsActive(obj)) + virStoragePoolUpdateInactive(obj); + virStoragePoolObjSetStarting(obj, false); + } virObjectEventStateQueue(driver->storageEventState, event); virStoragePoolObjEndAPI(&obj); return ret; @@ -1004,6 +1027,8 @@ storagePoolBuild(virStoragePoolPtr pool, goto cleanup; } =20 + virStoragePoolObjSetStarting(obj, true); + if (backend->buildPool && backend->buildPool(obj, flags) < 0) goto cleanup; @@ -1016,6 +1041,10 @@ storagePoolBuild(virStoragePoolPtr pool, ret =3D 0; =20 cleanup: + if (virStoragePoolObjIsStarting(obj)) { + virStoragePoolUpdateInactive(obj); + virStoragePoolObjSetStarting(obj, false); + } virObjectEventStateQueue(driver->storageEventState, event); virStoragePoolObjEndAPI(&obj); return ret; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:19:00 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558708685; cv=none; d=zoho.com; s=zohoarc; b=VF7gjnwEaeoL+zHNvkmDYkMB8rxWJJ7YXbtIX/4J8SG9Mmwk4DCOWPRWL9mGeNb5vb9DfiWDv+F8jB9xjFXPvHKFyDOYof4qkyqUNAhzVfXEqa7hb4sHqspwLEUxfdRq+YXLOB3ift2YsS6qIkWEeuJhs9T/KHtclWdiDeAoYh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558708685; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/7ToHjMw5zDOtpmsMk7Y5FvG1X8Bw1S1VWjdSonydZM=; b=DgsitIXl0bJol/snofo6p/qXvMzKUiWMZUKdlL91XtA8z7iA6PnUGYtR6omBsD4Bqy3pndrjdyXkyu5rA6UP2UUrCrG3eXovv1dfKFRJiYWnOUv7XsRyoGMdv6l347fhm/4QLYVe42bHTuN8yGj8+Lzix2lx+PaGKT/CDhhAbe0= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558708685134616.3006588876167; Fri, 24 May 2019 07:38:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54D36B0CFB; Fri, 24 May 2019 14:38:03 +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 1C8D25B2EB; Fri, 24 May 2019 14:38:02 +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 D32D01806B11; Fri, 24 May 2019 14:38:01 +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 x4OEaKEb011427 for ; Fri, 24 May 2019 10:36:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 17FB769287; Fri, 24 May 2019 14:36:20 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9396D692A1 for ; Fri, 24 May 2019 14:36:17 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 24 May 2019 16:35:47 +0200 Message-Id: <1ffb6e8cd780a57122d1633e68df282e5056673d.1558707820.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 11/11] storage: Drop and reacquire pool obj lock in some backends 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 24 May 2019 14:38:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1711789 Starting up or building some types of pools may take a very long time (e.g. a misconfigured NFS). Holding the pool object locked throughout the whole time hurts concurrency, e.g. if there's another thread that is listing all the pools. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_backend_disk.c | 11 ++++++++++- src/storage/storage_backend_fs.c | 13 +++++++++++-- src/storage/storage_backend_logical.c | 15 ++++++++++----- src/storage/storage_backend_vstorage.c | 9 ++++++++- src/storage/storage_backend_zfs.c | 7 ++++++- 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index 9b94d26cf9..f58b7b294c 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -461,7 +461,10 @@ virStorageBackendDiskStartPool(virStoragePoolObjPtr po= ol) const char *format; const char *path =3D def->source.devices[0].path; =20 + /* This can take a significant amount of time. */ + virObjectUnlock(pool); virWaitForDevices(); + virObjectLock(pool); =20 if (!virFileExists(path)) { virReportError(VIR_ERR_INVALID_ARG, @@ -490,6 +493,7 @@ virStorageBackendDiskBuildPool(virStoragePoolObjPtr poo= l, int format =3D def->source.format; const char *fmt; VIR_AUTOPTR(virCommand) cmd =3D NULL; + int ret =3D -1; =20 virCheckFlags(VIR_STORAGE_POOL_BUILD_OVERWRITE | VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, -1); @@ -523,7 +527,12 @@ virStorageBackendDiskBuildPool(virStoragePoolObjPtr po= ol, "--script", fmt, NULL); - return virCommandRun(cmd, NULL); + + virObjectUnlock(pool); + ret =3D virCommandRun(cmd, NULL); + virObjectLock(pool); + + return ret; } =20 =20 diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index ae4e9a03a3..1257419760 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -318,7 +318,14 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr = pool) return -1; =20 cmd =3D virStorageBackendFileSystemMountCmd(MOUNT, def, src); - return virCommandRun(cmd, NULL); + + /* Mounting a shared FS might take a long time. Don't hold + * the pool locked meanwhile. */ + virObjectUnlock(pool); + rc =3D virCommandRun(cmd, NULL); + virObjectLock(pool); + + return rc; } =20 =20 @@ -457,13 +464,14 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr = pool, virReportError(VIR_ERR_OPERATION_INVALID, _("No source device specified when formatting pool = '%s'"), def->name); - goto error; + return -1; } =20 device =3D def->source.devices[0].path; format =3D virStoragePoolFormatFileSystemTypeToString(def->source.form= at); VIR_DEBUG("source device: '%s' format: '%s'", device, format); =20 + virObjectUnlock(pool); if (!virFileExists(device)) { virReportError(VIR_ERR_OPERATION_INVALID, _("Source device does not exist when formatting poo= l '%s'"), @@ -482,6 +490,7 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr po= ol, ret =3D virStorageBackendExecuteMKFS(device, format); =20 error: + virObjectLock(pool); return ret; } =20 diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 83b5f27151..603a3f9a42 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -50,9 +50,15 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr p= ool, { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); VIR_AUTOPTR(virCommand) cmd =3D NULL; + int ret; =20 cmd =3D virStorageBackendLogicalChangeCmd(VGCHANGE, def, on); - return virCommandRun(cmd, NULL); + + virObjectUnlock(pool); + ret =3D virCommandRun(cmd, NULL); + virObjectLock(pool); + + return ret; } =20 =20 @@ -723,11 +729,10 @@ virStorageBackendLogicalBuildPool(virStoragePoolObjPt= r pool, virCommandAddArg(vgcmd, path); } =20 + virObjectUnlock(pool); /* Now create the volume group itself */ - if (virCommandRun(vgcmd, NULL) < 0) - goto cleanup; - - ret =3D 0; + ret =3D virCommandRun(vgcmd, NULL); + virObjectLock(pool); =20 cleanup: /* On any failure, run through the devices that had pvcreate run in diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_b= ackend_vstorage.c index d446aa2726..cec21dccbf 100644 --- a/src/storage/storage_backend_vstorage.c +++ b/src/storage/storage_backend_vstorage.c @@ -42,6 +42,7 @@ virStorageBackendVzPoolStart(virStoragePoolObjPtr pool) VIR_AUTOFREE(char *) usr_name =3D NULL; VIR_AUTOFREE(char *) mode =3D NULL; VIR_AUTOPTR(virCommand) cmd =3D NULL; + int ret; =20 /* Check the permissions */ if (def->target.perms.mode =3D=3D (mode_t)-1) @@ -69,7 +70,13 @@ virStorageBackendVzPoolStart(virStoragePoolObjPtr pool) "-g", grp_name, "-u", usr_name, NULL); =20 - return virCommandRun(cmd, NULL); + /* Mounting a shared FS might take a long time. Don't hold + * the pool locked meanwhile. */ + virObjectUnlock(pool); + ret =3D virCommandRun(cmd, NULL); + virObjectLock(pool); + + return ret; } =20 =20 diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index 826a95538e..d172a5a165 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -385,6 +385,7 @@ virStorageBackendZFSBuildPool(virStoragePoolObjPtr pool, virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); size_t i; VIR_AUTOPTR(virCommand) cmd =3D NULL; + int ret =3D -1; =20 virCheckFlags(0, -1); =20 @@ -400,7 +401,11 @@ virStorageBackendZFSBuildPool(virStoragePoolObjPtr poo= l, for (i =3D 0; i < def->source.ndevice; i++) virCommandAddArg(cmd, def->source.devices[i].path); =20 - return virCommandRun(cmd, NULL); + virObjectUnlock(pool); + ret =3D virCommandRun(cmd, NULL); + virObjectLock(pool); + + return ret; } =20 static int --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list