From nobody Sun May 5 23:35:44 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=1615565735; cv=none; d=zohomail.com; s=zohoarc; b=SztpF1S+anB8d9t3OS9Kc8HM/ndN/ZzZlfMOEXP81jyN3gPtnM2pK6bIOhVz1U6uf+gMstCh69LJRBL0s1gMfhKQmXyBs2npXfEtxyTHRJvV9dTl6Wbrc6shopbOyGe3OuSI4v/AOFj+8uSBgLA7xTrgun72xGckx/eyOWS7msw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615565735; 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=FlD/VVLOipF4ABIv2lw5pCXrH1bdnOYGyN600YqUMkE=; b=UrZ8mm58lmVl96/RS3ZZ9fRUnisokXnEC4/ngNyg04HM+dUtOf37lC9MhceaaUGB+dfqvpkNOtkDhWGMgApmOB53duNzBPB/ftZk15YaX9R7lDfatnwnSIev69SlPRdFBNiI0Fy8dIZab6spEAWY6pefMXo7azwjeRyF9Tr6alk= 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 1615565735883571.9234732452531; Fri, 12 Mar 2021 08:15:35 -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-39-DdqqKvXANxqhUlWbJZcncA-1; Fri, 12 Mar 2021 11:15:29 -0500 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 51B7C8042BE; Fri, 12 Mar 2021 16:15:23 +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 294F7610A8; Fri, 12 Mar 2021 16:15:23 +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 8EF5257DC1; Fri, 12 Mar 2021 16:15:22 +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 12CF8swX013037 for ; Fri, 12 Mar 2021 10:08:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 724EE10016FB; Fri, 12 Mar 2021 15:08:54 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7C69100164A for ; Fri, 12 Mar 2021 15:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615565734; 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=FlD/VVLOipF4ABIv2lw5pCXrH1bdnOYGyN600YqUMkE=; b=i7XH3Pz5uXTpUQI/FPQy7zoI6BaUyHiXz5EljWzxRL0pvG/AnRMq4aDKdTuGPQblu4AHAv nz0/wCLev+Wceniy2+JUj4zrKGphuQDpcZxbnmIyNbNdXdBEMXTZBo7giyvTu6mCM2nd96 7cAVVuoC5hcrsYz48oNIiipqmf0Mxxw= X-MC-Unique: DdqqKvXANxqhUlWbJZcncA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2] qemu_shim: Don't hang if failed to start domain Date: Fri, 12 Mar 2021 16:08:51 +0100 Message-Id: <2f898f8b46b6fedac6b5489ad3a03e5cc306fd47.1615561573.git.mprivozn@redhat.com> 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.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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The qemu shim spawns a separate thread in which the event loop is ran. The virEventRunDefaultImpl() call is wrapped in a while() loop, just like it should. There are few lines of code around which try to ensure that domain is destroyed (when quitting) and that the last round of event loop is ran after the virDomainDestroy() call. Only after that the loop is quit from and the thread quits. However, if domain creation fails, there is no @dom to call destroy over, the @quit flag is never set and while() never exits. Set the flag regardless of @dom pointer. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1920337 Signed-off-by: Michal Privoznik --- v2 of: https://listman.redhat.com/archives/libvir-list/2021-March/msg00011.html Thanks to Andrea who made me realize that this can be written better. diff to v1: - Instead of exiting from while() early, let the event loop run another iteration (it should be no-op anyway). src/qemu/qemu_shim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_shim.c b/src/qemu/qemu_shim.c index d85497bd3a..8b3afd0324 100644 --- a/src/qemu/qemu_shim.c +++ b/src/qemu/qemu_shim.c @@ -45,9 +45,9 @@ qemuShimEventLoop(void *opaque G_GNUC_UNUSED) while (!quit) { g_mutex_lock(&eventLock); if (eventQuitFlag && !eventPreventQuitFlag) { + quit =3D true; if (dom) { virDomainDestroy(dom); - quit =3D true; } } g_mutex_unlock(&eventLock); --=20 2.26.2