From nobody Mon Apr 29 12:38:42 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=1611677348; cv=none; d=zohomail.com; s=zohoarc; b=YSNSwF4YeHU8QolTgFiNNq/bgFiaxnhDSWyAk39eX7rOZGhJUYJ8jG4Ki4Av2Www+WAn07F/fJ2vpUGtpAJfs/fpa7bSeGBCMqr4yy0sRLkMEZbbshhz91pBzpoMYPxt4dzTrd8WZ68vv5gfJfISwy/1GM+7RryVYZ34NENAuWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611677348; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=khnxOOeNpsdPxnZchsoCOqma6qQsqdjBL5sUEmCMlqA=; b=avAFxr3oI34t/BCZZtlI8T8DAGwfVEZI0JnWOrpmBPGjygtl8fWwoZGCkNTzEonJ4+t9CzH46NWyt6C540ZReVjjYOcoSGhcTqW6AYAIpM4jjs6UMFEzCMZMQNkOAcjxpp8t7Kqlhem1glvDzv6Uum++wMqR1EiPJdwVi5h0lUE= 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 161167734813635.87782666493922; Tue, 26 Jan 2021 08:09:08 -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-471-aJxkBNDtM_i-PKZOSatKHA-1; Tue, 26 Jan 2021 11:09:02 -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 CC680A0CA2; Tue, 26 Jan 2021 16:08:54 +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 36BD95D9F1; Tue, 26 Jan 2021 16:08:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6DB25180954D; Tue, 26 Jan 2021 16:08:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10QG8naE021429 for ; Tue, 26 Jan 2021 11:08:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9E7D9100164C; Tue, 26 Jan 2021 16:08:49 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.193.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7199010023AE for ; Tue, 26 Jan 2021 16:08:46 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A941224519D; Tue, 26 Jan 2021 17:08:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611677346; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=khnxOOeNpsdPxnZchsoCOqma6qQsqdjBL5sUEmCMlqA=; b=eB5/91yfAuUOWOfmay93lXH/8l85ufXpOxBNOV6Kfk5ReFxQe5n7SH3gydsqqslvArlrZn Lvdnp+MUNZP38J83IJ+8jRv/EDmo2z/K7fo7E0IJ/YIAodW6PQj6esowi52ddtVcBCETgx o+AQ//egU7YH/JR85G8FZRZgoJ+s0fw= X-MC-Unique: aJxkBNDtM_i-PKZOSatKHA-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu: Avoid segfault when driver initialization fails Date: Tue, 26 Jan 2021 17:08:42 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) Content-Type: text/plain; charset="utf-8" In case qemuStateInitialize fails for any reason (e.g., a typo in qemu.conf), it properly cleans up after itself and sets qemu_driver back to NULL. A tiny bit later the daemon asks all drivers to shutdown by calling their stateShutdown* APIs. But the implementation of these APIs in QEMU driver expected qemu_driver to be initialized at this point causing a segfault otherwise. Signed-off-by: Jiri Denemark --- src/qemu/qemu_driver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ed966cf7e3..a68ebe5259 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1075,6 +1075,9 @@ qemuStateStop(void) static int qemuStateShutdownPrepare(void) { + if (!qemu_driver) + return 0; + virThreadPoolStop(qemu_driver->workerPool); return 0; } @@ -1094,6 +1097,9 @@ qemuDomainObjStopWorkerIter(virDomainObjPtr vm, static int qemuStateShutdownWait(void) { + if (!qemu_driver) + return 0; + virDomainObjListForEach(qemu_driver->domains, false, qemuDomainObjStopWorkerIter, NULL); virThreadPoolDrain(qemu_driver->workerPool); --=20 2.30.0