From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] device-assignment: Better fd tracking Date: Thu, 08 Jul 2010 11:32:07 +0300 Message-ID: <4C358D07.1070405@redhat.com> References: <20100707162948.5414.51749.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, ddutile@redhat.com To: Alex Williamson Return-path: Received: from mx1.redhat.com ([209.132.183.28]:23861 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753765Ab0GHIcJ (ORCPT ); Thu, 8 Jul 2010 04:32:09 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o688W866024015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 8 Jul 2010 04:32:09 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o688W7Yp003792 for ; Thu, 8 Jul 2010 04:32:08 -0400 In-Reply-To: <20100707162948.5414.51749.stgit@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: On 07/07/2010 07:29 PM, Alex Williamson wrote: > Commit 909bfdba fixed a hole with not closing resource file descriptors > but we need to be more careful about tracking which are real fds, > otherwise we might close fd 0, which doesn't work out so well for stdio. > > @@ -785,7 +786,8 @@ static void free_assigned_device(AssignedDevice *dev) > fprintf(stderr, > "Failed to unmap assigned device region: %s\n", > strerror(errno)); > - close(pci_region->resource_fd); > + if (pci_region->resource_fd>= 0) > + close(pci_region->resource_fd); > Missing { }s. > } > } > } > @@ -793,10 +795,8 @@ static void free_assigned_device(AssignedDevice *dev) > if (dev->cap.available& ASSIGNED_DEVICE_CAP_MSIX) > assigned_dev_unregister_msix_mmio(dev); > > - if (dev->real_device.config_fd) { > + if (dev->real_device.config_fd>= 0) > close(dev->real_device.config_fd); > - dev->real_device.config_fd = 0; > - } > Again. > > #ifdef KVM_CAP_IRQ_ROUTING > free_dev_irq_entries(dev); > @@ -1415,7 +1415,7 @@ static int assigned_initfn(struct PCIDevice *pci_dev) > > if (!dev->host.seg&& !dev->host.bus&& !dev->host.dev&& !dev->host.func) { > error_report("pci-assign: error: no host device specified"); > - goto out; > + return -1; > } > -error is better than -1, but this is not introduces by this patch, so okay. -- error compiling committee.c: too many arguments to function