From: Boris Ostrovsky Subject: [PATCH 2/2] libxl: Simplify cleanup in do_pci_remove() Date: Mon, 10 Nov 2014 18:16:50 -0500 Message-ID: <1415661410-5191-3-git-send-email-boris.ostrovsky@oracle.com> References: <1415661410-5191-1-git-send-email-boris.ostrovsky@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1415661410-5191-1-git-send-email-boris.ostrovsky@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, wei.liu2@citrix.com Cc: boris.ostrovsky@oracle.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Calls to xc_physdev_unmap_pirq() will fail for HVM guests since QEMU makes the same call earlier, during device removal. In addition, guest's call to xc_domain_irq_permission() will also fail since clearing permissions is part of hypervisor's unmap_domain_pirq(). Signed-off-by: Boris Ostrovsky Tested-by: Konrad Rzeszutek Wilk --- tools/libxl/libxl_pci.c | 32 +++++++++++++++++--------------- 1 files changed, 17 insertions(+), 15 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 4c6a733..d5d7cc0 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -1310,24 +1310,26 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid, } fclose(f); skip1: - sysfs_path = libxl__sprintf(gc, SYSFS_PCI_DEV"/"PCI_BDF"/irq", pcidev->domain, - pcidev->bus, pcidev->dev, pcidev->func); - f = fopen(sysfs_path, "r"); - if (f == NULL) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", sysfs_path); - goto out; - } - if ((fscanf(f, "%u", &irq) == 1) && irq) { - rc = xc_physdev_unmap_pirq(ctx->xch, domid, irq); - if (rc < 0) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_physdev_unmap_pirq irq=%d", irq); + if (!hvm) { + sysfs_path = libxl__sprintf(gc, SYSFS_PCI_DEV"/"PCI_BDF"/irq", + pcidev->domain, + pcidev->bus, pcidev->dev, + pcidev->func); + f = fopen(sysfs_path, "r"); + if (f == NULL) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, + "Couldn't open %s", sysfs_path); + goto out; } - rc = xc_domain_irq_permission(ctx->xch, domid, irq, 0); - if (rc < 0) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_domain_irq_permission irq=%d", irq); + if ((fscanf(f, "%u", &irq) == 1) && irq) { + rc = xc_physdev_unmap_pirq(ctx->xch, domid, irq); + if (rc < 0) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, + "xc_physdev_unmap_pirq irq=%d", irq); + } } + fclose(f); } - fclose(f); } out: /* don't do multiple resets while some functions are still passed through */ -- 1.7.1