From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499378; cv=none; d=zohomail.com; s=zohoarc; b=lynAg4ItdXJiKpmRY1R2pCE/IG0/lxoDQ4/KeMC+DgCvdCe3sEuk2kh7pdYEKG+I08yJnst8m5UTV141ImntOBt4WBhxQ+Hu+z3g2mcQIugwGHHdDBhx1HqNztOJ378AVKsVWRKABfObrNclyDyr/WclK+lFUBhNvB6Ia7QdAq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499378; 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; bh=QFhor3xsZM+1G9LJywVr6Uij2sCaqVk9kg6VTcUrzRQ=; b=NMI8zMR+n7kHyUATYHen0kLGplegrPGOoYriD0Hk7rTJYmGcdhz4BU0ItASNVYRWaS+NJldrv+Dnkc/I1UZTXkGAk55Wb+O+X3Xvv2VBXrFEAtf+CvzgvmqBE3p3ONl1mwmJmy4YoQ6KWLdImU2DauLxfTsVih3Ap98DkDf/GKI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1595499378317395.0624052358139; Thu, 23 Jul 2020 03:16:18 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-E8fangLfOhKI299LEs7--Q-1; Thu, 23 Jul 2020 06:16:15 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 222CA19200C0; Thu, 23 Jul 2020 10:16:08 +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 F3BE15D9F7; Thu, 23 Jul 2020 10:16:07 +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 C16D194EE2; Thu, 23 Jul 2020 10:16:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFqWp008424 for ; Thu, 23 Jul 2020 06:15:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 392FB208DD86; Thu, 23 Jul 2020 10:15:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3261D208DD88 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 47137101244A for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-XjzyQ64xNaqNiX82W4vavA-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGM-0007ZV-O2 for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:42 +0300 X-MC-Unique: E8fangLfOhKI299LEs7--Q-1 X-MC-Unique: XjzyQ64xNaqNiX82W4vavA-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 01/13] libvirt: add stateShutdownPrepare/stateShutdownWait to drivers Date: Thu, 23 Jul 2020 13:14:01 +0300 Message-Id: <1595499253-584162-2-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable stateShutdownPrepare is supposed to inform driver that it will be closed so= on so that the driver can prepare and finish all background threads quickly on stateShutdownWait call. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza --- scripts/check-drivername.py | 2 ++ src/driver-state.h | 8 ++++++++ src/libvirt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/libvirt_internal.h | 2 ++ src/libvirt_private.syms | 2 ++ 5 files changed, 56 insertions(+) diff --git a/scripts/check-drivername.py b/scripts/check-drivername.py index 39eff83..cce8e7d 100644 --- a/scripts/check-drivername.py +++ b/scripts/check-drivername.py @@ -50,6 +50,8 @@ for drvfile in drvfiles: "virDrvStateCleanup", "virDrvStateReload", "virDrvStateStop", + "virDrvStateShutdownPrepare", + "virDrvStateShutdownWait", "virDrvConnectSupportsFeature", "virDrvConnectURIProbe", "virDrvDomainMigratePrepare", diff --git a/src/driver-state.h b/src/driver-state.h index 6b3f501..767d8e8 100644 --- a/src/driver-state.h +++ b/src/driver-state.h @@ -45,6 +45,12 @@ typedef int typedef int (*virDrvStateStop)(void); =20 +typedef int +(*virDrvStateShutdownPrepare)(void); + +typedef int +(*virDrvStateShutdownWait)(void); + typedef struct _virStateDriver virStateDriver; typedef virStateDriver *virStateDriverPtr; =20 @@ -55,4 +61,6 @@ struct _virStateDriver { virDrvStateCleanup stateCleanup; virDrvStateReload stateReload; virDrvStateStop stateStop; + virDrvStateShutdownPrepare stateShutdownPrepare; + virDrvStateShutdownWait stateShutdownWait; }; diff --git a/src/libvirt.c b/src/libvirt.c index b2d0ba3..c5089ea 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -673,6 +673,48 @@ virStateInitialize(bool privileged, =20 =20 /** + * virStateShutdownPrepare: + * + * Run each virtualization driver's shutdown prepare method. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int +virStateShutdownPrepare(void) +{ + size_t i; + + for (i =3D 0; i < virStateDriverTabCount; i++) { + if (virStateDriverTab[i]->stateShutdownPrepare && + virStateDriverTab[i]->stateShutdownPrepare() < 0) + return -1; + } + return 0; +} + + +/** + * virStateShutdownWait: + * + * Run each virtualization driver's shutdown wait method. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int +virStateShutdownWait(void) +{ + size_t i; + + for (i =3D 0; i < virStateDriverTabCount; i++) { + if (virStateDriverTab[i]->stateShutdownWait && + virStateDriverTab[i]->stateShutdownWait() < 0) + return -1; + } + return 0; +} + + +/** * virStateCleanup: * * Run each virtualization driver's cleanup method. diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 72c6127..e27030b 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -34,6 +34,8 @@ int virStateInitialize(bool privileged, const char *root, virStateInhibitCallback inhibit, void *opaque); +int virStateShutdownPrepare(void); +int virStateShutdownWait(void); int virStateCleanup(void); int virStateReload(void); int virStateStop(void); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 73b72c9..cf3ccab 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1503,6 +1503,8 @@ virSetSharedStorageDriver; virStateCleanup; virStateInitialize; virStateReload; +virStateShutdownPrepare; +virStateShutdownWait; virStateStop; virStreamInData; =20 --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499367; cv=none; d=zohomail.com; s=zohoarc; b=im6flYsYQKhHOOafc00/66klSFZcCXd0C8/j+69M5PRdH3RvzsO1sgMVSy0N4Q/FLV9zaHfaqDMuLoq4OClt3aP2Qey+SUZilEVBe6WOSXt6uyy5bmSjfWGszBc48v8fQhCVXaHls+aoUPbb1I4qK6OakdqIIW+UH9jul7Pw0RU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499367; 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; bh=PjebxIg9tdsivWoC/ZqG1uFCoE4P4mv3bBK/q8fPU6Q=; b=LqS5FI8YyK8BFMld7lO7KA3S/TTve4E+L7FH+cKAc1T8jaqNXj5JnBbSwkqaLm5XpS7cifRUctiMafwVs/ed+XMkquKZ1DEG7cyfhZBZpwsF6J1tOh2ncOkj69o9GlxfbJEP78PXZGfXc4okr7K+tbm7c16OIzPaDQDPMfezOhs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1595499366826479.666715850979; Thu, 23 Jul 2020 03:16:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-RGemk3R7N8mM6nFbH3EqYw-1; Thu, 23 Jul 2020 06:16:03 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8290A100A8E7; Thu, 23 Jul 2020 10:15:57 +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 123278BEDC; Thu, 23 Jul 2020 10:15:57 +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 009F3730FA; Thu, 23 Jul 2020 10:15:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFq3K008423 for ; Thu, 23 Jul 2020 06:15:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3AD69208DD88; Thu, 23 Jul 2020 10:15:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 34627208DD8A for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4EDAB89CD21 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-375-35P6EttdPMCVjSD72lHRxQ-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGM-0007ZV-Pi for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:42 +0300 X-MC-Unique: RGemk3R7N8mM6nFbH3EqYw-1 X-MC-Unique: 35P6EttdPMCVjSD72lHRxQ-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 02/13] util: always initialize priority condition Date: Thu, 23 Jul 2020 13:14:02 +0300 Message-Id: <1595499253-584162-3-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Even if we have no priority threads on pool creation we can add them thru virThreadPoolSetParameters later. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza --- src/util/virthreadpool.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c index 379d236..10a44de 100644 --- a/src/util/virthreadpool.c +++ b/src/util/virthreadpool.c @@ -245,6 +245,8 @@ virThreadPoolNewFull(size_t minWorkers, goto error; if (virCondInit(&pool->cond) < 0) goto error; + if (virCondInit(&pool->prioCond) < 0) + goto error; if (virCondInit(&pool->quit_cond) < 0) goto error; =20 @@ -255,13 +257,8 @@ virThreadPoolNewFull(size_t minWorkers, if (virThreadPoolExpand(pool, minWorkers, false) < 0) goto error; =20 - if (prioWorkers) { - if (virCondInit(&pool->prioCond) < 0) - goto error; - - if (virThreadPoolExpand(pool, prioWorkers, true) < 0) - goto error; - } + if (virThreadPoolExpand(pool, prioWorkers, true) < 0) + goto error; =20 return pool; =20 @@ -274,7 +271,6 @@ virThreadPoolNewFull(size_t minWorkers, void virThreadPoolFree(virThreadPoolPtr pool) { virThreadPoolJobPtr job; - bool priority =3D false; =20 if (!pool) return; @@ -283,10 +279,8 @@ void virThreadPoolFree(virThreadPoolPtr pool) pool->quit =3D true; if (pool->nWorkers > 0) virCondBroadcast(&pool->cond); - if (pool->nPrioWorkers > 0) { - priority =3D true; + if (pool->nPrioWorkers > 0) virCondBroadcast(&pool->prioCond); - } =20 while (pool->nWorkers > 0 || pool->nPrioWorkers > 0) ignore_value(virCondWait(&pool->quit_cond, &pool->mutex)); @@ -301,10 +295,8 @@ void virThreadPoolFree(virThreadPoolPtr pool) virMutexDestroy(&pool->mutex); virCondDestroy(&pool->quit_cond); virCondDestroy(&pool->cond); - if (priority) { - VIR_FREE(pool->prioWorkers); - virCondDestroy(&pool->prioCond); - } + VIR_FREE(pool->prioWorkers); + virCondDestroy(&pool->prioCond); VIR_FREE(pool); } =20 --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499379; cv=none; d=zohomail.com; s=zohoarc; b=gGjxzZchj9JznciSRfP+eQPkQXOXrRL9aDFWLFPKdxeGwMlsf5aGf1kPrqBQ67aBVjnTb2qW8OEp13NmnFp93eK3wol64CJGsrHMEjK58dSsBV1yREybFaACTpPuiMxAAlBmnH6h6cKBx/jTSngRiFz/ThW63Qj7NjyOWMmO6ek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499379; 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; bh=zNCrffuNc57BZFnQaS07OHQlnZ6eOLapZjoqllYsyJc=; b=nOjCuvGawAwDlCVy/DMSELo0sk8gVUAUL5sUn0uTZCUgeFBsR0LvBYXLbijkgjLriKIDrMCNQHtNkw66dyLP5DY5YhNFnVUJ0/kEhNU6kKvFrn3/ERcpXc0ScARZo3Viuq9HffBh0IGdLNFVLx0kOy8BTrakgV+yDhZ0ICBLCIE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1595499379350919.171984580293; Thu, 23 Jul 2020 03:16:19 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-478-CloLdCsMOlmpE_jM4pVu2A-1; Thu, 23 Jul 2020 06:16:15 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8718CE924; Thu, 23 Jul 2020 10:16:10 +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 66CA25D9D3; Thu, 23 Jul 2020 10:16:10 +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 2F4D09625C; Thu, 23 Jul 2020 10:16:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFrRO008461 for ; Thu, 23 Jul 2020 06:15:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 32CCB2156A49; Thu, 23 Jul 2020 10:15:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DE732156A2D for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3FF071832D2C for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-340-NmwqiNwnMt-z6mb8oJVUEA-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGM-0007ZV-R2 for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:42 +0300 X-MC-Unique: CloLdCsMOlmpE_jM4pVu2A-1 X-MC-Unique: NmwqiNwnMt-z6mb8oJVUEA-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 03/13] util: add stop/drain functions to thread pool Date: Thu, 23 Jul 2020 13:14:03 +0300 Message-Id: <1595499253-584162-4-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Stop just send signal for threads to exit when they finish with current task. Drain waits when all threads will finish. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza --- src/libvirt_private.syms | 2 ++ src/util/virthreadpool.c | 43 ++++++++++++++++++++++++++++++++++++++----- src/util/virthreadpool.h | 3 +++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cf3ccab..0a9afc5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3328,6 +3328,7 @@ virThreadJobSetWorker; =20 =20 # util/virthreadpool.h +virThreadPoolDrain; virThreadPoolFree; virThreadPoolGetCurrentWorkers; virThreadPoolGetFreeWorkers; @@ -3338,6 +3339,7 @@ virThreadPoolGetPriorityWorkers; virThreadPoolNewFull; virThreadPoolSendJob; virThreadPoolSetParameters; +virThreadPoolStop; =20 =20 # util/virtime.h diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c index 10a44de..ca44f55 100644 --- a/src/util/virthreadpool.c +++ b/src/util/virthreadpool.c @@ -268,19 +268,27 @@ virThreadPoolNewFull(size_t minWorkers, =20 } =20 -void virThreadPoolFree(virThreadPoolPtr pool) -{ - virThreadPoolJobPtr job; =20 - if (!pool) +static void +virThreadPoolStopLocked(virThreadPoolPtr pool) +{ + if (pool->quit) return; =20 - virMutexLock(&pool->mutex); pool->quit =3D true; if (pool->nWorkers > 0) virCondBroadcast(&pool->cond); if (pool->nPrioWorkers > 0) virCondBroadcast(&pool->prioCond); +} + + +static void +virThreadPoolDrainLocked(virThreadPoolPtr pool) +{ + virThreadPoolJobPtr job; + + virThreadPoolStopLocked(pool); =20 while (pool->nWorkers > 0 || pool->nPrioWorkers > 0) ignore_value(virCondWait(&pool->quit_cond, &pool->mutex)); @@ -289,6 +297,15 @@ void virThreadPoolFree(virThreadPoolPtr pool) pool->jobList.head =3D pool->jobList.head->next; VIR_FREE(job); } +} + +void virThreadPoolFree(virThreadPoolPtr pool) +{ + if (!pool) + return; + + virMutexLock(&pool->mutex); + virThreadPoolDrainLocked(pool); =20 VIR_FREE(pool->workers); virMutexUnlock(&pool->mutex); @@ -475,3 +492,19 @@ virThreadPoolSetParameters(virThreadPoolPtr pool, virMutexUnlock(&pool->mutex); return -1; } + +void +virThreadPoolStop(virThreadPoolPtr pool) +{ + virMutexLock(&pool->mutex); + virThreadPoolStopLocked(pool); + virMutexUnlock(&pool->mutex); +} + +void +virThreadPoolDrain(virThreadPoolPtr pool) +{ + virMutexLock(&pool->mutex); + virThreadPoolDrainLocked(pool); + virMutexUnlock(&pool->mutex); +} diff --git a/src/util/virthreadpool.h b/src/util/virthreadpool.h index c97d9b3..dd1aaf3 100644 --- a/src/util/virthreadpool.h +++ b/src/util/virthreadpool.h @@ -56,3 +56,6 @@ int virThreadPoolSetParameters(virThreadPoolPtr pool, long long int minWorkers, long long int maxWorkers, long long int prioWorkers); + +void virThreadPoolStop(virThreadPoolPtr pool); +void virThreadPoolDrain(virThreadPoolPtr pool); --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499374; cv=none; d=zohomail.com; s=zohoarc; b=fsjnnFPTbZrYAY2BSHm5dUCvmMUDmdcfil8LIJyHu3iwlwdsfqbeA/K5NjmMOCYGw5OH4wf/Z7ZVCXthTJe7MtBshYqxwco2UqjHjEfIUyAOKNaMmv9vNwustiycDRw9XgGd2Kj32iy4Ve4Ojel46QRyj3nL7PV3khKclhrxLT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499374; 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; bh=aa8O3+J+PA8uA0QOvs4LLxvJ2ZxnsTSNy/3Ov2ATgBE=; b=cu7f2MKy1SFR/7qmc/AGdCgG/Fdjki0xTiW+t0qEsKWAynHWwUQ2QfpEptPK9cZl9WulsQosgWZw+Ku8CybtZpuO28NRDCzbyzBJZDWhyVxCmg8AWCtsY6nhwvnGQgrBXjOzTqfYjebzynWwi3Agh4KEiza6JP77aWbMTiIfxHY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1595499374969169.95254599709426; Thu, 23 Jul 2020 03:16:14 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-216-GyKPLRzlMjO3pNWH1UPSbw-1; Thu, 23 Jul 2020 06:16:11 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE26419200C2; Thu, 23 Jul 2020 10:16: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 87D431A8F7; Thu, 23 Jul 2020 10:16: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 E02AB1800BB2; Thu, 23 Jul 2020 10:16:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFqjw008429 for ; Thu, 23 Jul 2020 06:15:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7DFA71065788; Thu, 23 Jul 2020 10:15:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77ECA1065753 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D2FC8007CB for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-375-rvZb4kntPwmQrquK3YAVUA-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGM-0007ZV-Sf for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:42 +0300 X-MC-Unique: GyKPLRzlMjO3pNWH1UPSbw-1 X-MC-Unique: rvZb4kntPwmQrquK3YAVUA-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 04/13] rpc: don't unref service ref on socket behalf twice Date: Thu, 23 Jul 2020 13:14:04 +0300 Message-Id: <1595499253-584162-5-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Second unref was added in [1]. We don't need it actually as we pass free callback to virNetSocketAddIOCallback thus when we call virNetSocketRemoveIOCallback the extra ref for callback will be dropped without extra efforts. [1] 355d8f470f9: virNetServerServiceClose: Don't leak sockets Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza --- src/rpc/virnetserverservice.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c index 9d5df45..e4165ea 100644 --- a/src/rpc/virnetserverservice.c +++ b/src/rpc/virnetserverservice.c @@ -449,6 +449,5 @@ void virNetServerServiceClose(virNetServerServicePtr sv= c) for (i =3D 0; i < svc->nsocks; i++) { virNetSocketRemoveIOCallback(svc->socks[i]); virNetSocketClose(svc->socks[i]); - virObjectUnref(svc); } } --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499571; cv=none; d=zohomail.com; s=zohoarc; b=RVUVNRlP+ybx5ldsTPWvMKyLL8rI0RTNoumDQSJoQviJ+tUxGoaIq9VGh7oS9CKa6fksq2EiUgVhJZboVeost8leQPxEADyRTBlgGUVIrOH0InPcifCCIin8NuZM6x1PujycPZnHRe1/bi+NRH0DnI1mukTGs9xhZSQ4WSCfwfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499571; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=PYoSf9yaZnkifljM8kD5dmi6kvXRGlHU0mQyEqIbly8=; b=YAy3VnOku8C7zZqgv1lZQX3EbK6fjQRje9Uy4ZH4+uBxkEcv029V8XZGByPBlyO6/qE4wrzLybJLxt4UV+t/OJHmJeBy2n09sjPqBxt2eWz2P1OXKDIV2q/7YUz3doEiAR60wciUvBxwy9B2ogxgvQyhYY+xkHdFU9AtizWjagk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1595499571657839.6979545447341; Thu, 23 Jul 2020 03:19:31 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-244-ugUSKD-nNzSf5Q82CeHVqQ-1; Thu, 23 Jul 2020 06:19:28 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29154100CCC4; Thu, 23 Jul 2020 10:19:22 +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 0700C1009978; Thu, 23 Jul 2020 10:19:22 +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 CC4659A15A; Thu, 23 Jul 2020 10:19:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFrmT008462 for ; Thu, 23 Jul 2020 06:15:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 501EE12DA90; Thu, 23 Jul 2020 10:15:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 481B91281EF for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5493680CC2C for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-3P4VyvhAOMK5Vnin3eYNlA-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGM-0007ZV-Ty for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:42 +0300 X-MC-Unique: ugUSKD-nNzSf5Q82CeHVqQ-1 X-MC-Unique: 3P4VyvhAOMK5Vnin3eYNlA-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 05/13] rpc: add virNetDaemonSetShutdownCallbacks Date: Thu, 23 Jul 2020 13:14:05 +0300 Message-Id: <1595499253-584162-6-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The function is used to set shutdown prepare and wait callbacks. Prepare callback is used to inform other threads of the daemon that the daemon will= be closed soon so that they can start to shutdown. Wait callback is used to wa= it for other threads to actually finish. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel Henrique Barboza --- src/libvirt_remote.syms | 1 + src/rpc/virnetdaemon.c | 15 +++++++++++++++ src/rpc/virnetdaemon.h | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms index 0018a0c..335e431 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -87,6 +87,7 @@ virNetDaemonPreExecRestart; virNetDaemonQuit; virNetDaemonRemoveShutdownInhibition; virNetDaemonRun; +virNetDaemonSetShutdownCallbacks; virNetDaemonUpdateServices; =20 =20 diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index bb81a43..5a5643c 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -69,6 +69,8 @@ struct _virNetDaemon { virHashTablePtr servers; virJSONValuePtr srvObject; =20 + virNetDaemonShutdownCallback shutdownPrepareCb; + virNetDaemonShutdownCallback shutdownWaitCb; bool quit; =20 unsigned int autoShutdownTimeout; @@ -922,3 +924,16 @@ virNetDaemonHasClients(virNetDaemonPtr dmn) =20 return ret; } + +void +virNetDaemonSetShutdownCallbacks(virNetDaemonPtr dmn, + virNetDaemonShutdownCallback prepareCb, + virNetDaemonShutdownCallback waitCb) +{ + virObjectLock(dmn); + + dmn->shutdownPrepareCb =3D prepareCb; + dmn->shutdownWaitCb =3D waitCb; + + virObjectUnlock(dmn); +} diff --git a/src/rpc/virnetdaemon.h b/src/rpc/virnetdaemon.h index c2c7767..9f7a282 100644 --- a/src/rpc/virnetdaemon.h +++ b/src/rpc/virnetdaemon.h @@ -82,3 +82,9 @@ virNetServerPtr virNetDaemonGetServer(virNetDaemonPtr dmn, ssize_t virNetDaemonGetServers(virNetDaemonPtr dmn, virNetServerPtr **serv= ers); bool virNetDaemonHasServer(virNetDaemonPtr dmn, const char *serverName); + +typedef int (*virNetDaemonShutdownCallback)(void); + +void virNetDaemonSetShutdownCallbacks(virNetDaemonPtr dmn, + virNetDaemonShutdownCallback prepare= Cb, + virNetDaemonShutdownCallback waitCb); --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499565; cv=none; d=zohomail.com; s=zohoarc; b=lj0H1GavNi0y5ayqnGQIfokUL1io9Axv3NI9lExlY5/z1Jo4yfcqBAZLTB1x4ZJdgnwO4LDw3RRykJXGd/o4QSoefIqu1RJzryl/E74XxWJK80yQuPVJ/d1Kl8ez9NRRbKQ0WJ+dWmrPFup9tNOiN5L2Lls6nK7RjWikJHa2Flg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499565; 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; bh=m7yj8SmcSHYdSj0OGk7g9shDeidSHUzVLb4pwPyFsH8=; b=nL0D69BMNjNHmgdyBqmVshU0oUYgnYYanyNJ+6OZmZwksZ1SicqFasdc6aRItoenbD0jaUifZr8UMCXbI8vdauYwYrPAnpvbRxn3P4Bh6awetfbtxnwnIOlZcQxCZk2Nc98Pmc/6T/joS6cul3ITzgNXfTLHoeZpdzF1YCUjFNY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1595499565864953.6957301447658; Thu, 23 Jul 2020 03:19:25 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-oBxpBVmnP2mbQqbyIloVZA-1; Thu, 23 Jul 2020 06:19:22 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53DB0100CCC3; Thu, 23 Jul 2020 10:19:17 +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 2DFFA1009978; Thu, 23 Jul 2020 10:19:16 +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 BB6B61809557; Thu, 23 Jul 2020 10:19:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFrGD008459 for ; Thu, 23 Jul 2020 06:15:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 308F72156A3A; Thu, 23 Jul 2020 10:15:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C0CD2157F26 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2DAE1800658 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-iJwIvonvMGizVDNTyU35HA-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGM-0007ZV-VL for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:42 +0300 X-MC-Unique: oBxpBVmnP2mbQqbyIloVZA-1 X-MC-Unique: iJwIvonvMGizVDNTyU35HA-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 06/13] rpc: add shutdown facilities to netserver Date: Thu, 23 Jul 2020 13:14:06 +0300 Message-Id: <1595499253-584162-7-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable virNetServerClose and virNetServerShutdownWait are used to start net server threads shutdown and wait net server threads to actually finish respectively during net daemon shutdown procedure. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza --- src/rpc/virnetserver.c | 8 ++++++++ src/rpc/virnetserver.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index e0a2386..79ea9f6 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -942,9 +942,17 @@ void virNetServerClose(virNetServerPtr srv) for (i =3D 0; i < srv->nclients; i++) virNetServerClientClose(srv->clients[i]); =20 + virThreadPoolStop(srv->workers); + virObjectUnlock(srv); } =20 +void +virNetServerShutdownWait(virNetServerPtr srv) +{ + virThreadPoolDrain(srv->workers); +} + static inline size_t virNetServerTrackPendingAuthLocked(virNetServerPtr srv) { diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h index 1c6a2ef..112a51d 100644 --- a/src/rpc/virnetserver.h +++ b/src/rpc/virnetserver.h @@ -56,6 +56,7 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONVal= uePtr object, ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(6); =20 void virNetServerClose(virNetServerPtr srv); +void virNetServerShutdownWait(virNetServerPtr srv); =20 virJSONValuePtr virNetServerPreExecRestart(virNetServerPtr srv); =20 --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499573; cv=none; d=zohomail.com; s=zohoarc; b=Rk2RCSTTixo7kWBOOSVP4AXhX4vHfPCEZgkTVVE0YJE/CgyaCMJ/YWyJ00g4NUR9fMYiHTZAz9ZGf6fjHXR5hnKrSdh+v3cglkF7W/08JnPMhZ+NrY7Grcz9bTu97vveGTswhzZWDmq3d+2SqR+AMp/qVB+0NTXTgAg8LNQTGYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499573; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=kXNVDRq3Fszd+Mo8TROWmUCnVmRfc3odQBxGsHrBSSc=; b=k943K/23kGFhUYnKCFQamQIIW6ZY9iGIFZQ68gfbVakLv7nkt9mg3QlhBc4MozgvdIZnJfFZYLiae61wrtrlDHUMG+OMC0vgryzC/YvImy6D+z3LO223Is+CaZvvlPZr+8ljrHFcU0xt1oC61XeRxs49K2Esf5fg0D/9QD8UeM8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1595499573732354.91947110208775; Thu, 23 Jul 2020 03:19:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-9-ZfdqzfFTMzWO1Il4AfpXZA-1; Thu, 23 Jul 2020 06:19:30 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 859F0102C802; Thu, 23 Jul 2020 10:19:24 +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 5FE0E8BEFA; Thu, 23 Jul 2020 10:19:24 +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 2ED22180B791; Thu, 23 Jul 2020 10:19:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFrd1008482 for ; Thu, 23 Jul 2020 06:15:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 852491281EE; Thu, 23 Jul 2020 10:15:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 818541281F0 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22A7F8007D4 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-199-HkZTlTVRMCaZi-mLaZ-HuA-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGN-0007ZV-0K for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:43 +0300 X-MC-Unique: ZfdqzfFTMzWO1Il4AfpXZA-1 X-MC-Unique: HkZTlTVRMCaZi-mLaZ-HuA-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 07/13] rpc: finish all threads before exiting main loop Date: Thu, 23 Jul 2020 13:14:07 +0300 Message-Id: <1595499253-584162-8-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently we have issues like [1] on libvirtd shutdown as we cleanup while = RPC and other threads are still running. Let's finish all threads other then ma= in before cleanup. The approach to finish threads is suggested in [2]. In order to finish RPC threads serving API calls we let the event loop run but stop accepting new = API calls and block processing any pending API calls. We also inform all driver= s of shutdown so they can prepare for shutdown too. Then we wait for all RPC thr= eads and driver's background thread to finish. If finishing takes more then 15s = we just exit as we can't safely cleanup in time. [1] https://bugzilla.redhat.com/show_bug.cgi?id=3D1828207 [2] https://www.redhat.com/archives/libvir-list/2020-April/msg01328.html Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- src/remote/remote_daemon.c | 6 ++-- src/rpc/virnetdaemon.c | 81 ++++++++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index 1aa9bfc..2ac4f6c 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -1193,6 +1193,9 @@ int main(int argc, char **argv) { #endif =20 /* Run event loop. */ + virNetDaemonSetShutdownCallbacks(dmn, + virStateShutdownPrepare, + virStateShutdownWait); virNetDaemonRun(dmn); =20 ret =3D 0; @@ -1201,9 +1204,6 @@ int main(int argc, char **argv) { 0, "shutdown", NULL, NULL); =20 cleanup: - /* Keep cleanup order in inverse order of startup */ - virNetDaemonClose(dmn); - virNetlinkEventServiceStopAll(); =20 if (driversInitialized) { diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 5a5643c..1d7f00d 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -71,7 +71,10 @@ struct _virNetDaemon { =20 virNetDaemonShutdownCallback shutdownPrepareCb; virNetDaemonShutdownCallback shutdownWaitCb; + int finishTimer; bool quit; + bool finished; + bool graceful; =20 unsigned int autoShutdownTimeout; size_t autoShutdownInhibitions; @@ -82,6 +85,11 @@ struct _virNetDaemon { =20 static virClassPtr virNetDaemonClass; =20 +static int +daemonServerClose(void *payload, + const void *key G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED); + static void virNetDaemonDispose(void *obj) { @@ -798,11 +806,53 @@ daemonServerProcessClients(void *payload, return 0; } =20 +static int +daemonServerShutdownWait(void *payload, + const void *key G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ + virNetServerPtr srv =3D payload; + + virNetServerShutdownWait(srv); + return 0; +} + +static void +daemonShutdownWait(void *opaque) +{ + virNetDaemonPtr dmn =3D opaque; + bool graceful =3D false; + + virHashForEach(dmn->servers, daemonServerShutdownWait, NULL); + if (dmn->shutdownWaitCb && dmn->shutdownWaitCb() < 0) + goto finish; + + graceful =3D true; + + finish: + virObjectLock(dmn); + dmn->graceful =3D graceful; + virEventUpdateTimeout(dmn->finishTimer, 0); + virObjectUnlock(dmn); +} + +static void +virNetDaemonFinishTimer(int timerid G_GNUC_UNUSED, + void *opaque) +{ + virNetDaemonPtr dmn =3D opaque; + + virObjectLock(dmn); + dmn->finished =3D true; + virObjectUnlock(dmn); +} + void virNetDaemonRun(virNetDaemonPtr dmn) { int timerid =3D -1; bool timerActive =3D false; + virThread shutdownThread; =20 virObjectLock(dmn); =20 @@ -813,6 +863,9 @@ virNetDaemonRun(virNetDaemonPtr dmn) } =20 dmn->quit =3D false; + dmn->finishTimer =3D -1; + dmn->finished =3D false; + dmn->graceful =3D false; =20 if (dmn->autoShutdownTimeout && (timerid =3D virEventAddTimeout(-1, @@ -828,7 +881,7 @@ virNetDaemonRun(virNetDaemonPtr dmn) virSystemdNotifyStartup(); =20 VIR_DEBUG("dmn=3D%p quit=3D%d", dmn, dmn->quit); - while (!dmn->quit) { + while (!dmn->finished) { /* A shutdown timeout is specified, so check * if any drivers have active state, if not * shutdown after timeout seconds @@ -859,6 +912,32 @@ virNetDaemonRun(virNetDaemonPtr dmn) virObjectLock(dmn); =20 virHashForEach(dmn->servers, daemonServerProcessClients, NULL); + + if (dmn->quit && dmn->finishTimer =3D=3D -1) { + virHashForEach(dmn->servers, daemonServerClose, NULL); + if (dmn->shutdownPrepareCb && dmn->shutdownPrepareCb() < 0) + break; + + if ((dmn->finishTimer =3D virEventAddTimeout(30 * 1000, + virNetDaemonFinishT= imer, + dmn, NULL)) < 0) { + VIR_WARN("Failed to register finish timer."); + break; + } + + if (virThreadCreateFull(&shutdownThread, true, daemonShutdownW= ait, + "daemon-shutdown", false, dmn) < 0) { + VIR_WARN("Failed to register join thread."); + break; + } + } + } + + if (dmn->graceful) { + virThreadJoin(&shutdownThread); + } else { + VIR_WARN("Make forcefull daemon shutdown"); + exit(EXIT_FAILURE); } =20 cleanup: --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499374; cv=none; d=zohomail.com; s=zohoarc; b=kGM9Rii7Iz13Sln3vz72nzOFio/zuw3oKrj7eMtx8jI4UV5v6TZWJFLUdHa89Q5N5zMQdbWWIZDn7k193VKOHi43qO9WAEt+kY5GRf3Dw6UetVS6ek0Nbr9DlPFM5P+mmbVI3jDnbvCOftY+KsFlwzBnFiGz7u5pn4pzkpATUbk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499374; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=cXHRaNuHwHw3stKshSUH/KFJeuHRs3+q3cV3Gbqf1ho=; b=Kbinzouu2yWECf42nSwn4uibid014Sb0Lp/91DKpgciBR54vgq57may0DR2gTQ9AYZIUVUTquEXHboEkuiEnjnjrU6U6Cy6fcS0wahlPYZY8QiwCQ8xWeXYEbA86T472Cy7A9SYdKuZUzcrHKxBF3dP8O75QxkxQlKzi9WN5+YU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1595499374566721.5415975420739; Thu, 23 Jul 2020 03:16:14 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-399-RA7WC2RNMqW6utbSO_7VOw-1; Thu, 23 Jul 2020 06:16:11 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D40C419200C4; Thu, 23 Jul 2020 10:16: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 8773871D12; Thu, 23 Jul 2020 10:16: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 C5ED41800B71; Thu, 23 Jul 2020 10:16:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFqGN008427 for ; Thu, 23 Jul 2020 06:15:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79EDF10657AF; Thu, 23 Jul 2020 10:15:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 739791065788 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5456980029D for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-278-Pxhrgdt-OuW3pCA3BfnQ6g-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGN-0007ZV-1c for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:43 +0300 X-MC-Unique: RA7WC2RNMqW6utbSO_7VOw-1 X-MC-Unique: Pxhrgdt-OuW3pCA3BfnQ6g-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 08/13] qemu: don't shutdown event thread in monitor EOF callback Date: Thu, 23 Jul 2020 13:14:08 +0300 Message-Id: <1595499253-584162-9-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This hunk was introduced in [1] in order to avoid loosing events from monitor on stopping qemu process. But as explained in [2] on destroy we won't get neither EOF nor any other events as monitor is just closed. In case of crash/shutdown we won't get any more events as well and qemuDomainObjStopWorker will be called by qemuProcessStop eventually. Thus let's remove qemuDomainObjStopWorker from qemuProcessHandleMonitorEOF as it is not useful anymore. [1] e6afacb0f: qemu: start/stop an event loop thread for domains [2] d2954c072: qemu: ensure domain event thread is always stopped Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_process.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e8b15ee..44098fe 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -322,9 +322,6 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon, qemuDomainDestroyNamespace(driver, vm); =20 cleanup: - /* Now we got EOF we're not expecting more I/O, so we - * can finally kill the event thread */ - qemuDomainObjStopWorker(vm); virObjectUnlock(vm); } =20 --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499383; cv=none; d=zohomail.com; s=zohoarc; b=lKkXggDRr9kILmBV5WO3V5RPdhPofhuRmWY4w+OwMnMPpu3ai6IIsQW4lHW0Ku1/vUxXn1FN02PxXzz+wM9KwE+K70FFZvh53/FELjvqFd6SuYzJTQPqIwKNFYVpnYwgPAXTzC5Xtonijnag789YlLYx88JSx/k/9+7+QOkT5eQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499383; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=RROXBuocJpxeXF8++/uHREjgOXIxkEd6t5EHVjoZmdw=; b=eE+2HakD2whfuuDyBZF/eM/nn0HLsLi5vUuEKSdLo4ybY7gvmK6se1Ej4Kuj+4mSeepRlHFisapDXHGar8QQQqqHMQerA/GQ2oBpB6JjTck/bXSP0Uriji+jmQLm+4wIsyqr0hn6o8Bhjid47RurCZ0fmz05oyDkZmnYZ59r0I4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1595499383440379.8866268011117; Thu, 23 Jul 2020 03:16:23 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-73-72-qe-fwObaoobS58C0W6A-1; Thu, 23 Jul 2020 06:16:20 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C781106B24D; Thu, 23 Jul 2020 10:16:15 +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 2EB0F71D2E; Thu, 23 Jul 2020 10:16:15 +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 EF5B41809563; Thu, 23 Jul 2020 10:16:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFrpr008477 for ; Thu, 23 Jul 2020 06:15:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 83F5112DA92; Thu, 23 Jul 2020 10:15:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7EA8B1281EE for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 34B1E1012449 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-psdSe4EHNJGF3m-jXjTdVQ-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGN-0007ZV-2q for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:43 +0300 X-MC-Unique: 72-qe-fwObaoobS58C0W6A-1 X-MC-Unique: psdSe4EHNJGF3m-jXjTdVQ-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 09/13] vireventthread: exit thread synchronously on finalize Date: Thu, 23 Jul 2020 13:14:09 +0300 Message-Id: <1595499253-584162-10-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It useful to be sure no thread is running after we drop all references to virEventThread. Otherwise in order to avoid crashes we need to synchronize = some other way or we make extra references in event handler callbacks to all the object in use. And some of them are not prepared to be refcounted. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/vireventthread.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/vireventthread.c b/src/util/vireventthread.c index cf86592..136a550 100644 --- a/src/util/vireventthread.c +++ b/src/util/vireventthread.c @@ -43,6 +43,7 @@ vir_event_thread_finalize(GObject *object) =20 if (evt->thread) { g_main_loop_quit(evt->loop); + g_thread_join(evt->thread); g_thread_unref(evt->thread); } =20 --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499367; cv=none; d=zohomail.com; s=zohoarc; b=f97L89EmN63J7gDOWHvSe6hKcaNq2CVL7+1PNdlR/Zs72M//uRlgfQr8Z5UcFBGhl5yKgZg9EofwAoPQBr3kbu8ZRkgZhkzV/yTRxx0l4e/A+JO4W4jhHcHs2knScnrdFYAk5nPq8hfy9Zwj1hMJ6sR0N822NuON3D1VWVPFLvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499367; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=5jbET4kVlOWVAUEnQpN70ekpGVHPKQq1mJdLE/wqdag=; b=jARzQ6qA8PIIzpXxy/bk3SpI6/34DyiiJY3SEplrriCdi2dakmNlRCaJoZnwQ2PB5CDay/mWIUtym1guCi53OIF2CKFjRuTwyhWE5jEeUF9Z5Y7hB5SxtDqxcYhugu2LQrs1g9EO+8uDwiKqwMU6xaH8Ympg6gEkF/Abd2jZuaA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1595499367200174.47269622811325; Thu, 23 Jul 2020 03:16:07 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-r8FA4MqVOAyOTuHmTpBP8Q-1; Thu, 23 Jul 2020 06:16:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ABD35800C64; Thu, 23 Jul 2020 10:15:57 +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 953B860CC0; Thu, 23 Jul 2020 10:15:56 +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 A1A8B1809554; Thu, 23 Jul 2020 10:15:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFqlE008425 for ; Thu, 23 Jul 2020 06:15:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 38E762026D5D; Thu, 23 Jul 2020 10:15:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32D2C208DD89 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A67A1012443 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-Ov04CkqjNiq_Ic_F6IiFpA-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGN-0007ZV-5g for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:43 +0300 X-MC-Unique: r8FA4MqVOAyOTuHmTpBP8Q-1 X-MC-Unique: Ov04CkqjNiq_Ic_F6IiFpA-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 10/13] qemu: avoid deadlock in qemuDomainObjStopWorker Date: Thu, 23 Jul 2020 13:14:10 +0300 Message-Id: <1595499253-584162-11-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We are dropping the only reference here so that the event loop thread is going to be exited synchronously. In order to avoid deadlocks we need to unlock the VM so that any handler being called can finish execution and thus even loop thread be finished too. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_domain.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5b22eb2..82b3d11 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1637,11 +1637,21 @@ void qemuDomainObjStopWorker(virDomainObjPtr dom) { qemuDomainObjPrivatePtr priv =3D dom->privateData; + virEventThread *eventThread; =20 - if (priv->eventThread) { - g_object_unref(priv->eventThread); - priv->eventThread =3D NULL; - } + if (!priv->eventThread) + return; + + /* + * We are dropping the only reference here so that the event loop thre= ad + * is going to be exited synchronously. In order to avoid deadlocks we + * need to unlock the VM so that any handler being called can finish + * execution and thus even loop thread be finished too. + */ + eventThread =3D g_steal_pointer(&priv->eventThread); + virObjectUnlock(dom); + g_object_unref(eventThread); + virObjectLock(dom); } =20 =20 --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499379; cv=none; d=zohomail.com; s=zohoarc; b=TbSZ47aEKGNOfPUSMQruBoIVvpTxOnWmjedKMoAola4iFjU0FmaRwGdy8p7fq0ejUoaKwnAnBA+A5tzM9k+5X8dimyZRtHYJiEDMgaRUANcqum9UKZrb1luSFx3yfrFpxu1a65B8igqvx7Q3ECZ8wJDSJxOnxhqlrpGrBrFttgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499379; 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; bh=CSUvs8ciwY83j2QHCUfQZfVquv8IfUD8QKaorEmuJp0=; b=n9x/E9xixecFkPoBgIHN1R6+l9aZGSebKXQvikmD9lC584jE4Kyn9L6yPenVl9A7VewJNlarF98J8U9tRFLuxb2bx2CDhZObiXxwQ4t9lwwfH5IswUGp+JW5KFtH1biz1R6mSLYXWAIXJmLheC/o3JS59QBAcQsPrHYUOjT763A= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1595499379911610.5138707816205; Thu, 23 Jul 2020 03:16:19 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-114-f330S9jjPCuDl9dOv1M2tA-1; Thu, 23 Jul 2020 06:16:13 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2852D8064B6; Thu, 23 Jul 2020 10:16:08 +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 071D46932A; Thu, 23 Jul 2020 10:16:08 +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 C8DE094EFC; Thu, 23 Jul 2020 10:16:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFqJL008428 for ; Thu, 23 Jul 2020 06:15:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C3511059172; Thu, 23 Jul 2020 10:15:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 76F0410657B8 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 151D2810B40 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-29-9IxLRIsTNJmVIilxZ5xu9A-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGN-0007ZV-6z for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:43 +0300 X-MC-Unique: f330S9jjPCuDl9dOv1M2tA-1 X-MC-Unique: 9IxLRIsTNJmVIilxZ5xu9A-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 11/13] qemu: implement driver's shutdown/shutdown wait methods Date: Thu, 23 Jul 2020 13:14:11 +0300 Message-Id: <1595499253-584162-12-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On shutdown we just stop accepting new jobs for worker thread so that on shutdown wait we can exit worker thread faster. Yes we basically stop processing of events for VMs but we are going to do so anyway in case of da= emon shutdown. At the same time synchronous event processing that some API calls may requi= re are still possible as per VM event loop is still running and we don't need worker thread for synchronous event processing. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_driver.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8e81c30..78a1aaf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1098,6 +1098,36 @@ qemuStateStop(void) return ret; } =20 + +static int +qemuStateShutdownPrepare(void) +{ + virThreadPoolStop(qemu_driver->workerPool); + return 0; +} + + +static int +qemuDomainObjStopWorkerIter(virDomainObjPtr vm, + void *opaque G_GNUC_UNUSED) +{ + virObjectLock(vm); + qemuDomainObjStopWorker(vm); + virObjectUnlock(vm); + return 0; +} + + +static int +qemuStateShutdownWait(void) +{ + virDomainObjListForEach(qemu_driver->domains, false, + qemuDomainObjStopWorkerIter, NULL); + virThreadPoolDrain(qemu_driver->workerPool); + return 0; +} + + /** * qemuStateCleanup: * @@ -23402,6 +23432,8 @@ static virStateDriver qemuStateDriver =3D { .stateCleanup =3D qemuStateCleanup, .stateReload =3D qemuStateReload, .stateStop =3D qemuStateStop, + .stateShutdownPrepare =3D qemuStateShutdownPrepare, + .stateShutdownWait =3D qemuStateShutdownWait, }; =20 int qemuRegister(void) --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499569; cv=none; d=zohomail.com; s=zohoarc; b=kRurUmK7LZWOj96hFwyWw1ptWyMfVC2yYxOckvJNdc1Cn9+ejzwIPJIi+YX6x+OMtDlIenLjFlOQX2vpnZET6N/6cJLD4+edBNboexPAjw5YY1J4hnBQ7N9Z02B4zLyY+FGfyu5qJrQ33daz06RwAuSabCPtdBVF/EeSGNdBojA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499569; 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; bh=WIx3nmd6j5PYgsHz4V9Bxc6qeV/gEg3qgIpwXL+TQ/w=; b=VWc30oBZpPcA7vo5zTBJiKs56U5N1HRnVtikKFYBDVjiw+Rk2fa97FtCqJQU7GPJNt6i1wguXHF3ZpRrQZ2jKfcmuREJ7B07Fi6hdy7G3S/MjpC1glici+zNA1XHd/upeD7uHWCv1rAwD/ShbM2ncUL/AJabUL1HlWb6ARti1eY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1595499569068708.8957474478788; Thu, 23 Jul 2020 03:19:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-a_dNF9k7PZ-_IwgXKZwV4g-1; Thu, 23 Jul 2020 06:19:25 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD0BF801A03; Thu, 23 Jul 2020 10:19:19 +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 9D81E71D2E; Thu, 23 Jul 2020 10:19:19 +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 6D0351800B71; Thu, 23 Jul 2020 10:19:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFr7d008460 for ; Thu, 23 Jul 2020 06:15:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2FA7F2156A30; Thu, 23 Jul 2020 10:15:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AFC22157F24 for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D37E833B7B for ; Thu, 23 Jul 2020 10:15:50 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-32-zT6-b9R-M_eX8vJ4Uu3Acg-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGN-0007ZV-8L for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:43 +0300 X-MC-Unique: a_dNF9k7PZ-_IwgXKZwV4g-1 X-MC-Unique: zT6-b9R-M_eX8vJ4Uu3Acg-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 12/13] rpc: cleanup virNetDaemonClose method Date: Thu, 23 Jul 2020 13:14:12 +0300 Message-Id: <1595499253-584162-13-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza --- src/libvirt_remote.syms | 1 - src/rpc/virnetdaemon.c | 13 ------------- src/rpc/virnetdaemon.h | 2 -- 3 files changed, 16 deletions(-) diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms index 335e431..c8f2e31 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -75,7 +75,6 @@ virNetDaemonAddServer; virNetDaemonAddShutdownInhibition; virNetDaemonAddSignalHandler; virNetDaemonAutoShutdown; -virNetDaemonClose; virNetDaemonGetServer; virNetDaemonGetServers; virNetDaemonHasClients; diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 1d7f00d..e2f4d5c 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -967,19 +967,6 @@ daemonServerClose(void *payload, return 0; } =20 -void -virNetDaemonClose(virNetDaemonPtr dmn) -{ - if (!dmn) - return; - - virObjectLock(dmn); - - virHashForEach(dmn->servers, daemonServerClose, NULL); - - virObjectUnlock(dmn); -} - static int daemonServerHasClients(void *payload, const void *key G_GNUC_UNUSED, diff --git a/src/rpc/virnetdaemon.h b/src/rpc/virnetdaemon.h index 9f7a282..6ae5305 100644 --- a/src/rpc/virnetdaemon.h +++ b/src/rpc/virnetdaemon.h @@ -73,8 +73,6 @@ void virNetDaemonRun(virNetDaemonPtr dmn); =20 void virNetDaemonQuit(virNetDaemonPtr dmn); =20 -void virNetDaemonClose(virNetDaemonPtr dmn); - bool virNetDaemonHasClients(virNetDaemonPtr dmn); =20 virNetServerPtr virNetDaemonGetServer(virNetDaemonPtr dmn, --=20 1.8.3.1 From nobody Wed May 8 15:20:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1595499383; cv=none; d=zohomail.com; s=zohoarc; b=fQP+YTlXPS/O2OaqUrA2Cl4TKdl91Z+DR1V0WvKrYCXsBK+WiBqnI/ZCkEC4KjxwWNsUJWUG2xL43mafaEC64rkShF4SrGUWa+0ofYYXeAF7bODMdQ7fQQ4+6ncbdx7FiWVFLkwia6kbsk/hVKt+Wtx7p07TOtpk5Yqh+UnO0I8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595499383; 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; bh=G8mA5wtji18T0gR3ig6E8yN5L+QqAnnOtlA1WY0nuZU=; b=iBwOU9w8RFAIeHpDN18IgcNy8+KO947zcrJVu6i50r7QzwFZH2BXFPZfAnvICt7TvJJ8gyGv+2uRAUuu+NEEec8Huvt/MKgnrg4v5ca8LDdHB/c/MFCvsoepjx98mAT/gmLVgLjl3c4getj/c2PDhLhJB5PSHx8Wio4aKVAb+5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 159549938318030.676989660433037; Thu, 23 Jul 2020 03:16:23 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-Q3DtF6iOMfqk-IQ0Vs88Zg-1; Thu, 23 Jul 2020 06:16:19 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D47CD100A8F9; Thu, 23 Jul 2020 10:16:12 +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 B465F5D9D3; Thu, 23 Jul 2020 10:16:12 +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 82EB6180CB27; Thu, 23 Jul 2020 10:16:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06NAFrct008464 for ; Thu, 23 Jul 2020 06:15:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5B35B1281EF; Thu, 23 Jul 2020 10:15:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 508431281EE for ; Thu, 23 Jul 2020 10:15:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0133F1012444 for ; Thu, 23 Jul 2020 10:15:51 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-OkivdE_hMVqyoiNVRohisw-1; Thu, 23 Jul 2020 06:15:47 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jyYGN-0007ZV-9f for libvir-list@redhat.com; Thu, 23 Jul 2020 13:15:43 +0300 X-MC-Unique: Q3DtF6iOMfqk-IQ0Vs88Zg-1 X-MC-Unique: OkivdE_hMVqyoiNVRohisw-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 13/13] util: remove unused virThreadPoolNew macro Date: Thu, 23 Jul 2020 13:14:13 +0300 Message-Id: <1595499253-584162-14-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1595499253-584162-1-git-send-email-nshirokovskiy@virtuozzo.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza --- src/util/virthreadpool.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/util/virthreadpool.h b/src/util/virthreadpool.h index dd1aaf3..cb800dc 100644 --- a/src/util/virthreadpool.h +++ b/src/util/virthreadpool.h @@ -28,9 +28,6 @@ typedef virThreadPool *virThreadPoolPtr; =20 typedef void (*virThreadPoolJobFunc)(void *jobdata, void *opaque); =20 -#define virThreadPoolNew(min, max, prio, func, opaque) \ - virThreadPoolNewFull(min, max, prio, func, #func, opaque) - virThreadPoolPtr virThreadPoolNewFull(size_t minWorkers, size_t maxWorkers, size_t prioWorkers, --=20 1.8.3.1