From nobody Fri Nov 7 09:07:03 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547759409887210.38422638860948; Thu, 17 Jan 2019 13:10:09 -0800 (PST) Received: from localhost ([127.0.0.1]:54966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkEvH-0006sE-Si for importer@patchew.org; Thu, 17 Jan 2019 16:09:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkEsQ-0004uo-VL for qemu-devel@nongnu.org; Thu, 17 Jan 2019 16:07:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkEsO-0007N6-6C for qemu-devel@nongnu.org; Thu, 17 Jan 2019 16:07:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45344) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gkEsL-0007Hi-D8 for qemu-devel@nongnu.org; Thu, 17 Jan 2019 16:06:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2610B8E3DC; Thu, 17 Jan 2019 21:06:48 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-183.ams2.redhat.com [10.36.116.183]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43E1B600C0; Thu, 17 Jan 2019 21:06:46 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, alex.williamson@redhat.com Date: Thu, 17 Jan 2019 22:06:31 +0100 Message-Id: <20190117210632.18567-2-eric.auger@redhat.com> In-Reply-To: <20190117210632.18567-1-eric.auger@redhat.com> References: <20190117210632.18567-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 17 Jan 2019 21:06:48 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/2] vfio-pci: Introduce vfio_set_event_handler helper 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: aik@ozlabs.ru, cohuck@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The code used to attach the eventfd handler for the ERR and REQ irq indices can be factorized into a helper. In subsequent patches we will extend this helper to support other irq indices. We test whether the notification is allowed outside of the helper: respectively check vdev->pci_aer and VFIO_FEATURE_ENABLE_REQ. Depending on the returned value we set vdev->pci_aer and vdev->req_enabled. An error handle is introduced for future usage although not strictly useful here. Signed-off-by: Eric Auger --- v1 -> v2: - s/vfio_register_event_notifier/vfio_set_event_handler - turned into a void function - do the qemu_set_fd_handler(*pfd, NULL, NULL, vdev) and event_notifier_cleanup on VFIO_DEVICE_SET_IRQS failure as reported by Alexey - reset err in vfio_realize as reported by Cornelia - Text/comment fixes suggested by Cornelia --- hw/vfio/pci.c | 296 ++++++++++++++++++++++---------------------------- 1 file changed, 132 insertions(+), 164 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index c0cb1ec289..3cae4c99ef 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -105,6 +105,96 @@ static void vfio_intx_eoi(VFIODevice *vbasedev) vfio_unmask_single_irqindex(vbasedev, VFIO_PCI_INTX_IRQ_INDEX); } =20 +/* + * vfio_set_event_handler - setup/tear down eventfd + * notification and handling for IRQ indices that span over + * a single IRQ + * + * @vdev: VFIO device handle + * @index: IRQ index the eventfd/handler is associated with + * @enable: true means notifier chain needs to be set up + * @handler: handler to attach if @enable is true + * @errp: error handle + */ +static void vfio_set_event_handler(VFIOPCIDevice *vdev, + int index, + bool enable, + void (*handler)(void *opaque), + Error **errp) +{ + struct vfio_irq_info irq_info =3D { .argsz =3D sizeof(irq_info), + .index =3D index }; + struct vfio_irq_set *irq_set; + EventNotifier *notifier; + int argsz, ret =3D 0; + int32_t *pfd, fd; + + switch (index) { + case VFIO_PCI_REQ_IRQ_INDEX: + notifier =3D &vdev->req_notifier; + break; + case VFIO_PCI_ERR_IRQ_INDEX: + notifier =3D &vdev->err_notifier; + break; + default: + g_assert_not_reached(); + } + + if (ioctl(vdev->vbasedev.fd, + VFIO_DEVICE_GET_IRQ_INFO, &irq_info) < 0 || irq_info.count <= 1) { + error_setg_errno(errp, errno, "No irq index %d available", index); + return; + } + + if (enable) { + ret =3D event_notifier_init(notifier, 0); + if (ret) { + error_setg_errno(errp, -ret, + "Unable to init event notifier for irq index = %d", + index); + return; + } + } + + argsz =3D sizeof(*irq_set) + sizeof(*pfd); + + irq_set =3D g_malloc0(argsz); + irq_set->argsz =3D argsz; + irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | + VFIO_IRQ_SET_ACTION_TRIGGER; + irq_set->index =3D index; + irq_set->start =3D 0; + irq_set->count =3D 1; + pfd =3D (int32_t *)&irq_set->data; + + if (!notifier) { + error_setg(errp, "Notifier not initialized for irq index %d", inde= x); + return; + } + + fd =3D event_notifier_get_fd(notifier); + + if (enable) { + qemu_set_fd_handler(fd, handler, NULL, vdev); + *pfd =3D fd; + } else { + *pfd =3D -1; + } + + ret =3D ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set); + g_free(irq_set); + + if (ret) { + error_setg_errno(errp, -ret, + "Failed to %s eventfd signalling for index %d", + enable ? "set up" : "tear down", index); + } + if (ret || !enable) { + qemu_set_fd_handler(fd, NULL, NULL, vdev); + event_notifier_cleanup(notifier); + } +} + static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp) { #ifdef CONFIG_KVM @@ -2621,86 +2711,6 @@ static void vfio_err_notifier_handler(void *opaque) vm_stop(RUN_STATE_INTERNAL_ERROR); } =20 -/* - * Registers error notifier for devices supporting error recovery. - * If we encounter a failure in this function, we report an error - * and continue after disabling error recovery support for the - * device. - */ -static void vfio_register_err_notifier(VFIOPCIDevice *vdev) -{ - int ret; - int argsz; - struct vfio_irq_set *irq_set; - int32_t *pfd; - - if (!vdev->pci_aer) { - return; - } - - if (event_notifier_init(&vdev->err_notifier, 0)) { - error_report("vfio: Unable to init event notifier for error detect= ion"); - vdev->pci_aer =3D false; - return; - } - - argsz =3D sizeof(*irq_set) + sizeof(*pfd); - - irq_set =3D g_malloc0(argsz); - irq_set->argsz =3D argsz; - irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | - VFIO_IRQ_SET_ACTION_TRIGGER; - irq_set->index =3D VFIO_PCI_ERR_IRQ_INDEX; - irq_set->start =3D 0; - irq_set->count =3D 1; - pfd =3D (int32_t *)&irq_set->data; - - *pfd =3D event_notifier_get_fd(&vdev->err_notifier); - qemu_set_fd_handler(*pfd, vfio_err_notifier_handler, NULL, vdev); - - ret =3D ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set); - if (ret) { - error_report("vfio: Failed to set up error notification"); - qemu_set_fd_handler(*pfd, NULL, NULL, vdev); - event_notifier_cleanup(&vdev->err_notifier); - vdev->pci_aer =3D false; - } - g_free(irq_set); -} - -static void vfio_unregister_err_notifier(VFIOPCIDevice *vdev) -{ - int argsz; - struct vfio_irq_set *irq_set; - int32_t *pfd; - int ret; - - if (!vdev->pci_aer) { - return; - } - - argsz =3D sizeof(*irq_set) + sizeof(*pfd); - - irq_set =3D g_malloc0(argsz); - irq_set->argsz =3D argsz; - irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | - VFIO_IRQ_SET_ACTION_TRIGGER; - irq_set->index =3D VFIO_PCI_ERR_IRQ_INDEX; - irq_set->start =3D 0; - irq_set->count =3D 1; - pfd =3D (int32_t *)&irq_set->data; - *pfd =3D -1; - - ret =3D ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set); - if (ret) { - error_report("vfio: Failed to de-assign error fd: %m"); - } - g_free(irq_set); - qemu_set_fd_handler(event_notifier_get_fd(&vdev->err_notifier), - NULL, NULL, vdev); - event_notifier_cleanup(&vdev->err_notifier); -} - static void vfio_req_notifier_handler(void *opaque) { VFIOPCIDevice *vdev =3D opaque; @@ -2716,86 +2726,6 @@ static void vfio_req_notifier_handler(void *opaque) } } =20 -static void vfio_register_req_notifier(VFIOPCIDevice *vdev) -{ - struct vfio_irq_info irq_info =3D { .argsz =3D sizeof(irq_info), - .index =3D VFIO_PCI_REQ_IRQ_INDEX }; - int argsz; - struct vfio_irq_set *irq_set; - int32_t *pfd; - - if (!(vdev->features & VFIO_FEATURE_ENABLE_REQ)) { - return; - } - - if (ioctl(vdev->vbasedev.fd, - VFIO_DEVICE_GET_IRQ_INFO, &irq_info) < 0 || irq_info.count <= 1) { - return; - } - - if (event_notifier_init(&vdev->req_notifier, 0)) { - error_report("vfio: Unable to init event notifier for device reque= st"); - return; - } - - argsz =3D sizeof(*irq_set) + sizeof(*pfd); - - irq_set =3D g_malloc0(argsz); - irq_set->argsz =3D argsz; - irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | - VFIO_IRQ_SET_ACTION_TRIGGER; - irq_set->index =3D VFIO_PCI_REQ_IRQ_INDEX; - irq_set->start =3D 0; - irq_set->count =3D 1; - pfd =3D (int32_t *)&irq_set->data; - - *pfd =3D event_notifier_get_fd(&vdev->req_notifier); - qemu_set_fd_handler(*pfd, vfio_req_notifier_handler, NULL, vdev); - - if (ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set)) { - error_report("vfio: Failed to set up device request notification"); - qemu_set_fd_handler(*pfd, NULL, NULL, vdev); - event_notifier_cleanup(&vdev->req_notifier); - } else { - vdev->req_enabled =3D true; - } - - g_free(irq_set); -} - -static void vfio_unregister_req_notifier(VFIOPCIDevice *vdev) -{ - int argsz; - struct vfio_irq_set *irq_set; - int32_t *pfd; - - if (!vdev->req_enabled) { - return; - } - - argsz =3D sizeof(*irq_set) + sizeof(*pfd); - - irq_set =3D g_malloc0(argsz); - irq_set->argsz =3D argsz; - irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | - VFIO_IRQ_SET_ACTION_TRIGGER; - irq_set->index =3D VFIO_PCI_REQ_IRQ_INDEX; - irq_set->start =3D 0; - irq_set->count =3D 1; - pfd =3D (int32_t *)&irq_set->data; - *pfd =3D -1; - - if (ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set)) { - error_report("vfio: Failed to de-assign device request fd: %m"); - } - g_free(irq_set); - qemu_set_fd_handler(event_notifier_get_fd(&vdev->req_notifier), - NULL, NULL, vdev); - event_notifier_cleanup(&vdev->req_notifier); - - vdev->req_enabled =3D false; -} - static void vfio_realize(PCIDevice *pdev, Error **errp) { VFIOPCIDevice *vdev =3D PCI_VFIO(pdev); @@ -3069,8 +2999,33 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) goto out_teardown; } =20 - vfio_register_err_notifier(vdev); - vfio_register_req_notifier(vdev); + if (vdev->pci_aer) { + Error *err =3D NULL; + + /* + * Registers error notifier for devices supporting error recovery. + * If we encounter a failure during registration, we report an err= or + * and continue after disabling error recovery support for the + * device. + */ + vfio_set_event_handler(vdev, VFIO_PCI_ERR_IRQ_INDEX, true, + vfio_err_notifier_handler, &err); + if (err) { + warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); + } + vdev->pci_aer =3D !err; + } + + if (vdev->features & VFIO_FEATURE_ENABLE_REQ) { + Error *err =3D NULL; + + vfio_set_event_handler(vdev, VFIO_PCI_REQ_IRQ_INDEX, true, + vfio_req_notifier_handler, &err); + if (err) { + warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); + } + vdev->req_enabled =3D !err; + } vfio_setup_resetfn_quirk(vdev); =20 return; @@ -3106,9 +3061,22 @@ static void vfio_instance_finalize(Object *obj) static void vfio_exitfn(PCIDevice *pdev) { VFIOPCIDevice *vdev =3D PCI_VFIO(pdev); + Error *err =3D NULL; =20 - vfio_unregister_req_notifier(vdev); - vfio_unregister_err_notifier(vdev); + if (vdev->req_enabled) { + vfio_set_event_handler(vdev, VFIO_PCI_REQ_IRQ_INDEX, + false, NULL, &err); + if (err) { + warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); + } + } + if (vdev->pci_aer) { + vfio_set_event_handler(vdev, VFIO_PCI_ERR_IRQ_INDEX, + false, NULL, &err); + if (err) { + warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); + } + } pci_device_set_intx_routing_notifier(&vdev->pdev, NULL); vfio_disable_interrupts(vdev); if (vdev->intx.mmap_timer) { --=20 2.20.1 From nobody Fri Nov 7 09:07:03 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547759310512692.4490926171561; Thu, 17 Jan 2019 13:08:30 -0800 (PST) Received: from localhost ([127.0.0.1]:54956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkEtm-0005Vx-UM for importer@patchew.org; Thu, 17 Jan 2019 16:08:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkEsQ-0004uq-Vm for qemu-devel@nongnu.org; Thu, 17 Jan 2019 16:07:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkEsP-0007Nx-7C for qemu-devel@nongnu.org; Thu, 17 Jan 2019 16:07:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55152) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gkEsO-0007IV-5O for qemu-devel@nongnu.org; Thu, 17 Jan 2019 16:07:01 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DD4689AF7; Thu, 17 Jan 2019 21:06:50 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-183.ams2.redhat.com [10.36.116.183]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D0F6600C0; Thu, 17 Jan 2019 21:06:48 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, alex.williamson@redhat.com Date: Thu, 17 Jan 2019 22:06:32 +0100 Message-Id: <20190117210632.18567-3-eric.auger@redhat.com> In-Reply-To: <20190117210632.18567-1-eric.auger@redhat.com> References: <20190117210632.18567-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 17 Jan 2019 21:06:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] vfio-pci: Use vfio_set_event_handler in vfio_intx_enable 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: aik@ozlabs.ru, cohuck@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" vfio_set_event_handler() can be used in vfio_intx_enable() to set the signalling associated with VFIO_PCI_INTX_IRQ_INDEX. We also turn vfio_intx_enable() into a void function. Signed-off-by: Eric Auger --- vfio_set_event_handler cannot be used in vfio_intx_disable. The reason is not a call sequence issue but the VFIO_DEVICE_SET_IRQS invoction. vfio_disable_irqindex uses ACTION_TRIGGER/DATA_NONE/count=3D=3D0 whereas the new helper uses ACTION_TRIGGER/DATA_EVENTFD/fd=3D=3D-1. Surprisingly to me, both are not resulting into the same kernel actions. The first one does a complete tear down of the INTx (vfio_intx_disable), while the second - just taking care of a single index, the only one by the way for INTx -, does an incomplete tear down (vfio_intx_set_signal). If the last one is used, a subsequent setup of MSIx vectors fails. v1 -> v2: - turn vfio_intx_enable into a void function - s/vfio_intx_enable_kvm/vfio_intx_enable in title and commit msg --- hw/vfio/pci.c | 51 +++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 3cae4c99ef..dcba7a1539 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -136,6 +136,9 @@ static void vfio_set_event_handler(VFIOPCIDevice *vdev, case VFIO_PCI_ERR_IRQ_INDEX: notifier =3D &vdev->err_notifier; break; + case VFIO_PCI_INTX_IRQ_INDEX: + notifier =3D &vdev->intx.interrupt; + break; default: g_assert_not_reached(); } @@ -349,16 +352,13 @@ static void vfio_intx_update(PCIDevice *pdev) vfio_intx_eoi(&vdev->vbasedev); } =20 -static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) +static void vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) { uint8_t pin =3D vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1= ); - int ret, argsz, retval =3D 0; - struct vfio_irq_set *irq_set; - int32_t *pfd; Error *err =3D NULL; =20 if (!pin) { - return 0; + return; } =20 vfio_disable_interrupts(vdev); @@ -377,32 +377,11 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Erro= r **errp) } #endif =20 - ret =3D event_notifier_init(&vdev->intx.interrupt, 0); - if (ret) { - error_setg_errno(errp, -ret, "event_notifier_init failed"); - return ret; - } - - argsz =3D sizeof(*irq_set) + sizeof(*pfd); - - irq_set =3D g_malloc0(argsz); - irq_set->argsz =3D argsz; - irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRI= GGER; - irq_set->index =3D VFIO_PCI_INTX_IRQ_INDEX; - irq_set->start =3D 0; - irq_set->count =3D 1; - pfd =3D (int32_t *)&irq_set->data; - - *pfd =3D event_notifier_get_fd(&vdev->intx.interrupt); - qemu_set_fd_handler(*pfd, vfio_intx_interrupt, NULL, vdev); - - ret =3D ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set); - if (ret) { - error_setg_errno(errp, -ret, "failed to setup INTx fd"); - qemu_set_fd_handler(*pfd, NULL, NULL, vdev); - event_notifier_cleanup(&vdev->intx.interrupt); - retval =3D -errno; - goto cleanup; + vfio_set_event_handler(vdev, VFIO_PCI_INTX_IRQ_INDEX, true, + vfio_intx_interrupt, &err); + if (err) { + error_propagate(errp, err); + return; } =20 vfio_intx_enable_kvm(vdev, &err); @@ -413,11 +392,6 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error= **errp) vdev->interrupt =3D VFIO_INT_INTx; =20 trace_vfio_intx_enable(vdev->vbasedev.name); - -cleanup: - g_free(irq_set); - - return retval; } =20 static void vfio_intx_disable(VFIOPCIDevice *vdev) @@ -2982,8 +2956,9 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) vdev->intx.mmap_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, vfio_intx_mmap_enable, v= dev); pci_device_set_intx_routing_notifier(&vdev->pdev, vfio_intx_update= ); - ret =3D vfio_intx_enable(vdev, errp); - if (ret) { + vfio_intx_enable(vdev, &err); + if (err) { + error_propagate(errp, err); goto out_teardown; } } --=20 2.20.1