From nobody Mon Feb 9 09:29:43 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510335513775228.6237411239531; Fri, 10 Nov 2017 09:38:33 -0800 (PST) Received: from localhost ([::1]:42842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDDG1-0005Um-1H for importer@patchew.org; Fri, 10 Nov 2017 12:38:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDDCS-0002v0-Hc for qemu-devel@nongnu.org; Fri, 10 Nov 2017 12:34:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDDCR-00021B-OL for qemu-devel@nongnu.org; Fri, 10 Nov 2017 12:34:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45646) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDDCR-00020Z-Ie for qemu-devel@nongnu.org; Fri, 10 Nov 2017 12:34:39 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B47C9C0587E0; Fri, 10 Nov 2017 17:34:38 +0000 (UTC) Received: from dhcp-1-107.brq.redhat.com (ovpn-204-32.brq.redhat.com [10.40.204.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4291117A8F; Fri, 10 Nov 2017 17:34:37 +0000 (UTC) From: Ladi Prosek To: qemu-devel@nongnu.org Date: Fri, 10 Nov 2017 18:34:21 +0100 Message-Id: <20171110173421.17904-4-lprosek@redhat.com> In-Reply-To: <20171110173421.17904-1-lprosek@redhat.com> References: <20171110173421.17904-1-lprosek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 10 Nov 2017 17:34:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/3] ivshmem: Improve MSI irqfd error handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: geoff@hostfission.com, pbonzini@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Adds a rollback path to ivshmem_enable_irqfd() and fixes ivshmem_disable_irqfd() to bail if irqfd has not been enabled. Signed-off-by: Ladi Prosek Reviewed-by: Markus Armbruster --- hw/misc/ivshmem.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 493a5030a1..ff07a94691 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -784,6 +784,20 @@ static int ivshmem_setup_interrupts(IVShmemState *s, E= rror **errp) return 0; } =20 +static void ivshmem_remove_kvm_msi_virq(IVShmemState *s, int vector) +{ + IVSHMEM_DPRINTF("ivshmem_remove_kvm_msi_virq vector:%d\n", vector); + + if (s->msi_vectors[vector].pdev =3D=3D NULL) { + return; + } + + /* it was cleaned when masked in the frontend. */ + kvm_irqchip_release_virq(kvm_state, s->msi_vectors[vector].virq); + + s->msi_vectors[vector].pdev =3D NULL; +} + static void ivshmem_enable_irqfd(IVShmemState *s) { PCIDevice *pdev =3D PCI_DEVICE(s); @@ -795,7 +809,7 @@ static void ivshmem_enable_irqfd(IVShmemState *s) ivshmem_add_kvm_msi_virq(s, i, &err); if (err) { error_report_err(err); - /* TODO do we need to handle the error? */ + goto undo; } } =20 @@ -804,21 +818,14 @@ static void ivshmem_enable_irqfd(IVShmemState *s) ivshmem_vector_mask, ivshmem_vector_poll)) { error_report("ivshmem: msix_set_vector_notifiers failed"); + goto undo; } -} + return; =20 -static void ivshmem_remove_kvm_msi_virq(IVShmemState *s, int vector) -{ - IVSHMEM_DPRINTF("ivshmem_remove_kvm_msi_virq vector:%d\n", vector); - - if (s->msi_vectors[vector].pdev =3D=3D NULL) { - return; +undo: + while (--i >=3D 0) { + ivshmem_remove_kvm_msi_virq(s, i); } - - /* it was cleaned when masked in the frontend. */ - kvm_irqchip_release_virq(kvm_state, s->msi_vectors[vector].virq); - - s->msi_vectors[vector].pdev =3D NULL; } =20 static void ivshmem_disable_irqfd(IVShmemState *s) @@ -826,6 +833,10 @@ static void ivshmem_disable_irqfd(IVShmemState *s) PCIDevice *pdev =3D PCI_DEVICE(s); int i; =20 + if (!pdev->msix_vector_use_notifier) { + return; + } + msix_unset_vector_notifiers(pdev); =20 for (i =3D 0; i < s->peers[s->vm_id].nb_eventfds; i++) { --=20 2.13.5