From nobody Mon Feb 9 17:05:24 2026 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=1594719221; cv=none; d=zohomail.com; s=zohoarc; b=h8mHjD1TEHaNyurjdavBd0ZdY9ZsJhezvO7XDhclBNsHHCmXKkF+TmY+II2WAroVVc2sfV/Lo+YZ8el6UNPJ+/vhQ66/jvP1kp+Oe/PDz5SzjHlyoRI++BYk0+v8LL0oCrvuvgAZMvsLNFIeattjYWNP6eZKxifAaE2zkE46Hsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594719221; 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=yPqUtb6FL6afqrZ4sP2HNxRQFI9Y/b39SDEsZGkCu4U=; b=JRfverjEkLoB1mHF7ZMtZEjoPk7ep6bHT9O/SlESqO3ZkmplSqgzzDArGW2JUasYMJX61b1smBxLHGq2wQeIgFOmFKBv7lPDufUe54nq4RQqQFkoAo/tg8TC3129REvK29QxqyYOF7VKk3opDNpd87Bwf2DtGi5FJ6VTEB9VpPI= 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-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1594719221905382.6850065820962; Tue, 14 Jul 2020 02:33:41 -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-255-BMiT56hvN7KvuXqb9bzs4A-1; Tue, 14 Jul 2020 05:33:38 -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 D6E6C8027EC; Tue, 14 Jul 2020 09:33:32 +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 B85285FC2C; Tue, 14 Jul 2020 09:33: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 883A394EF2; Tue, 14 Jul 2020 09:33:32 +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 06E9XNxV027911 for ; Tue, 14 Jul 2020 05:33:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 396325AB71; Tue, 14 Jul 2020 09:33:23 +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 34A907D286 for ; Tue, 14 Jul 2020 09:33:21 +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 A871E856A58 for ; Tue, 14 Jul 2020 09:33:21 +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-452-3Q_4AMkXOluNdY6R8Hrvhw-1; Tue, 14 Jul 2020 05:33:18 -0400 Received: from [172.16.50.220] (helo=vz7.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jvHJB-00044B-Tb for libvir-list@redhat.com; Tue, 14 Jul 2020 12:33:05 +0300 X-MC-Unique: BMiT56hvN7KvuXqb9bzs4A-1 X-MC-Unique: 3Q_4AMkXOluNdY6R8Hrvhw-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 08/10] qemu: implement driver's shutdown/shutdown wait methods Date: Tue, 14 Jul 2020 12:32:59 +0300 Message-Id: <1594719181-546271-9-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1594719181-546271-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1594719181-546271-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.16 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" 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 --- 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 d185666..f7ff0fb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1098,6 +1098,36 @@ qemuStateStop(void) return ret; } =20 + +static int +qemuStateShutdown(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: * @@ -23413,6 +23443,8 @@ static virStateDriver qemuStateDriver =3D { .stateCleanup =3D qemuStateCleanup, .stateReload =3D qemuStateReload, .stateStop =3D qemuStateStop, + .stateShutdown =3D qemuStateShutdown, + .stateShutdownWait =3D qemuStateShutdownWait, }; =20 int qemuRegister(void) --=20 1.8.3.1