From nobody Sun Apr 28 22:59:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639061560; cv=none; d=zohomail.com; s=zohoarc; b=iGQcb31k9t11glQvBInH+0aptW6iTEOqNrYLIL4DM165Tx1fEo0+SlR0ItClhJlVi1wbYHyG9zxxFcL5d/LiYHNgRqxndwzNt6zalaolD0OWh0IEbZHRmZPXB3CkFbJ5n7+yq6QbqYVadtvyT4TLZan163WKECwDMyfascnPoLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639061560; 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=HxlasRwdEH1BZRkkvlXrCj8v8CQmaf46+UbTEhEzvbU=; b=Q6If1isfH8sSzFHQH2fSHgMQ8wDgGyutxDrG0I78Xg0i/V4yotHBt8XgTtn8IehdGa4mMkTQBIeDVaPeVMNuMOejUqe7ChmkAT2WRunCz/sFuUSIQeyuaT+BbKmAvFZcHEeXWq+hZpeJ7bYVjEC45JsoaKWdFWsVKUULJRvjDg8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639061560533578.6014679288338; Thu, 9 Dec 2021 06:52:40 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-364-eD7csitpOu-h3QkcRVg3aA-1; Thu, 09 Dec 2021 09:52:37 -0500 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 3CEA080BCAD; Thu, 9 Dec 2021 14:52:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0FF0B5D9D5; Thu, 9 Dec 2021 14:52:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CE4901806D2B; Thu, 9 Dec 2021 14:52:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9Ehxpr003364 for ; Thu, 9 Dec 2021 09:43:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 64B6719D9B; Thu, 9 Dec 2021 14:43:59 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id E14A019C59 for ; Thu, 9 Dec 2021 14:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639061559; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HxlasRwdEH1BZRkkvlXrCj8v8CQmaf46+UbTEhEzvbU=; b=DWeGJswizHALHaeg0UID8MClsgb9e2DOc6KKFxqO8Cdv2DA0q6dBhCwklFX9rTUcLfx9DU Q7tDRvbvOMnhvDDezc5zknQi6RilAh6ud6Ka5k5FYsKR5DV1fnVB5RCeSPLWmqe+rue8MS 2mdgk4i5VD5lQVLAvrjDCsEpRFMMGFs= X-MC-Unique: eD7csitpOu-h3QkcRVg3aA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] remote_daemon: Set shutdown callbacks only after init is done Date: Thu, 9 Dec 2021 15:43:55 +0100 Message-Id: <6947ef2c4f6b97d884d0683e18726d93021696c0.1639061014.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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 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 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639061562201100001 Content-Type: text/plain; charset="utf-8" The initialization of drivers happens in a separate thread. However, the main thread continues initialization and sets shutdown callbacks (virStateShutdownPrepare() and virStateShutdownWait()) even though the driver init thread is still running. This is dangerous because if the daemon decides to quit early (e.g. because SIGINT was delivered) the shutdownPrepare and shutdownWait callback are called over partially init drivers. Set callbacks only after all drivers were initialized. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/218 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2027400 Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/remote/remote_daemon.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index de43a54c2e..4e10f3ad23 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -626,6 +626,10 @@ static void daemonRunStateInit(void *opaque) =20 driversInitialized =3D true; =20 + virNetDaemonSetShutdownCallbacks(dmn, + virStateShutdownPrepare, + virStateShutdownWait); + /* Tie the non-privileged daemons to the session/shutdown lifecycle */ if (!virNetDaemonIsPrivileged(dmn)) { =20 @@ -1214,9 +1218,6 @@ int main(int argc, char **argv) { #endif =20 /* Run event loop. */ - virNetDaemonSetShutdownCallbacks(dmn, - virStateShutdownPrepare, - virStateShutdownWait); virNetDaemonRun(dmn); =20 ret =3D 0; --=20 2.32.0 From nobody Sun Apr 28 22:59:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639061566; cv=none; d=zohomail.com; s=zohoarc; b=nx6Cj7xBzmaMDftnq8z9kttBqME7AoOeOD/EuFAKEwYZFTksQC9Tf49TNQJaSQ4rNlatnhA+/IpS9IN1A25ZJBKOXOKEfTcs3tMtzPzYQGhBa7chiJAUsM70Q96+KIXoz4EslcVUZ3oMvrufR3z43QixhpP28Sehd7OycJiL0sQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639061566; 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=MznjICcVZTlB5dSduRzlNLFyGjb5rx0HUtPqMTEX4IU=; b=C8R8faZs6ys54JX9c8wWmgntjzrdtZmV1/ZTFI0gxDpKEknN5cbokdVUfpVripd4WMuc29IahQSIc7oeoPsJf6ek1bf68UI3hmuTZRvGsiCVEugaT7KkxVlUaeOsb2X8v10qx96IFLLxcoitrHFJFPGnDyTe0vVYH49WdiQry4w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639061566441798.8395499898425; Thu, 9 Dec 2021 06:52:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-312-STr8deGNOw-DJx6SXLntfA-1; Thu, 09 Dec 2021 09:52:41 -0500 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 71CEE1006AA1; Thu, 9 Dec 2021 14:52:36 +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 513035E272; Thu, 9 Dec 2021 14:52:36 +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 24D624A707; Thu, 9 Dec 2021 14:52:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9Ei0ZY003372 for ; Thu, 9 Dec 2021 09:44:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3758919D9B; Thu, 9 Dec 2021 14:44:00 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3EA619C59 for ; Thu, 9 Dec 2021 14:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639061565; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MznjICcVZTlB5dSduRzlNLFyGjb5rx0HUtPqMTEX4IU=; b=NgCh8Rs59uxG+4NDHULetqAbOTzk26PySafdnJ8a/cFcLN4t8WzIeNfT3GrN90m25cyYK2 TYFRyiw71uKptnkUDNPsuaA12Osmzg93Aj7GFEdC2AVlDudTrywgpRtJ+jTk85flstBauz Hzsrp7wwDfGDyCMSVIrEsaQr3K3NHA4= X-MC-Unique: STr8deGNOw-DJx6SXLntfA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] Revert "qemu: Avoid crash in qemuStateShutdownPrepare() and qemuStateShutdownWait()" Date: Thu, 9 Dec 2021 15:43:56 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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 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 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639061568150100001 Content-Type: text/plain; charset="utf-8" This reverts commit 69977ff10560a80bcf5bf93f1a3f819a2d1623ca. After previous commit it's no longer possible that QEMU driver is not initialized in qemuStateShutdownPrepare() nor qemuStateShutdownWait(). Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/qemu/qemu_driver.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8093b8f69b..2b1a34fafb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1034,9 +1034,6 @@ qemuStateStop(void) static int qemuStateShutdownPrepare(void) { - if (!qemu_driver) - return 0; - virThreadPoolStop(qemu_driver->workerPool); return 0; } @@ -1056,9 +1053,6 @@ qemuDomainObjStopWorkerIter(virDomainObj *vm, static int qemuStateShutdownWait(void) { - if (!qemu_driver) - return 0; - virDomainObjListForEach(qemu_driver->domains, false, qemuDomainObjStopWorkerIter, NULL); virThreadPoolDrain(qemu_driver->workerPool); --=20 2.32.0