From nobody Mon Nov 25 11:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605206803; cv=none; d=zohomail.com; s=zohoarc; b=jIbJvLTxmbcxC5tG/Ho0F5EG9qy72wOPv576M8SmFfzR+eZyifkP1zehJLhWWnPk9B6OfdBDRuSjguMcJNi3lFIEjYhh9bHOJbl0Ps7lpEfY1zhPkfHHq+BZ9vWMMqChkD4Z9aeKkHkDtln7mWaJ3s7KLvhvkvY/dXpnfBrU9iU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605206803; 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=f/6v8Z3ImYinGhgEZijLINPwXcjqLp/9rZ5jFmpcOdI=; b=BnjVnHdHuJswUBcLN5brOgcBE/fk6027LzU1IUCoKZ9qfmib2MbvctVtNBMpwv04PaaIoEdWNj+58OOE9vZ7N9wLjXm9NXlcMjUzWJw070bcPeGe8b+D57aQjTz0RqvtkyPX2lc4muj6w781tSSOwVeumc5OIOn6BgCGQnsksXU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605206803685580.335463734819; Thu, 12 Nov 2020 10:46:43 -0800 (PST) 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-551-nqf5k2gAPX-SqhIbPa8Ddg-1; Thu, 12 Nov 2020 13:46:40 -0500 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 5DC51107B275; Thu, 12 Nov 2020 18:46:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 38EA31002D7A; Thu, 12 Nov 2020 18:46:34 +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 CD6945810D; Thu, 12 Nov 2020 18:46:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ACIjoak018113 for ; Thu, 12 Nov 2020 13:45:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 477D85D9E8; Thu, 12 Nov 2020 18:45:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA3085D9E4 for ; Thu, 12 Nov 2020 18:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605206802; 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=f/6v8Z3ImYinGhgEZijLINPwXcjqLp/9rZ5jFmpcOdI=; b=HD0av3uEMIZMtCMSSB0yGVWVdyh+78hRnGeCvJI/LDsIp502qvfPoKbDOhaZW+jwU4ohTp HaOtjiCkQ4R5Grx+6KjhEI7dSGBSYspiV5IaJIGGNxkppjre3nWuJIUIPYxAdPTKvy4VPE 7rRrzKOIeOPlqSvgqLXpe5kE9bsCOeU= X-MC-Unique: nqf5k2gAPX-SqhIbPa8Ddg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] qemu: Check if driver is still available in qemuStateStop() Date: Thu, 12 Nov 2020 19:45:39 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 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) Content-Type: text/plain; charset="utf-8" When the host is shutting down then we get PrepareForShutdown signal on DBus to which we react by creating a thread which runs virStateStop() and thus qemuStateStop(). But if scheduling the thread is delayed just a but it may happen that we receive SIGTERM (sent by systemd) to which we respond by quitting our event loop and cleaning up everything (including drivers). And only after that the thread gets to run only to find qemu_driver being NULL. At this point there is nothing left to do anyways, the event loop is gone so no API call that qemuStateStop() does in attempt to save running domains can ever succeed. But to be fair, if there was a domain running we would have registered shutdown inhibitor so we would not get killed by signal. So there is nothing left to do for qemuStateStop() anyway. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1895359 Signed-off-by: Michal Privoznik --- src/qemu/qemu_driver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 05f8eb2cb7..9aa0ce4ec8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1046,7 +1046,12 @@ qemuStateStop(void) int state; virDomainPtr *domains =3D NULL; g_autofree unsigned int *flags =3D NULL; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(qemu_dri= ver); + g_autoptr(virQEMUDriverConfig) cfg =3D NULL; + + if (!qemu_driver) + return -1; + + cfg =3D virQEMUDriverGetConfig(qemu_driver); =20 if (!(conn =3D virConnectOpen(cfg->uri))) goto cleanup; --=20 2.26.2