From patchwork Wed May 19 19:00:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wright X-Patchwork-Id: 101029 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4JJ0jZ6017068 for ; Wed, 19 May 2010 19:00:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754440Ab0ESTAn (ORCPT ); Wed, 19 May 2010 15:00:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34494 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753101Ab0ESTAn (ORCPT ); Wed, 19 May 2010 15:00:43 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4JJ0gPq015891 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 19 May 2010 15:00:42 -0400 Received: from x200.localdomain (vpn-226-37.phx2.redhat.com [10.3.226.37]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o4JJ0fU8027365; Wed, 19 May 2010 15:00:41 -0400 Date: Wed, 19 May 2010 12:00:41 -0700 From: Chris Wright To: kvm@vger.kernel.org Cc: Alex Williamson , Chris Wright Subject: [PATCH qemu-kvm] device-assignment: add config fd qdev property Message-ID: <20100519190041.GK28275@x200.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 19 May 2010 19:00:46 +0000 (UTC) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index eb31c78..172f0c9 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -612,12 +612,15 @@ static int get_real_device(AssignedDevice *pci_dev, uint16_t r_seg, snprintf(name, sizeof(name), "%sconfig", dir); - fd = open(name, O_RDWR); + fd = dev->config_fd; if (fd == -1) { - fprintf(stderr, "%s: %s: %m\n", __func__, name); - return 1; + fd = open(name, O_RDWR); + if (fd == -1) { + fprintf(stderr, "%s: %s: %m\n", __func__, name); + return 1; + } + dev->config_fd = fd; } - dev->config_fd = fd; again: r = read(fd, pci_dev->dev.config, pci_config_size(&pci_dev->dev)); if (r < 0) { @@ -1433,6 +1436,7 @@ static PCIDeviceInfo assign_info = { .qdev.props = (Property[]) { DEFINE_PROP("host", AssignedDevice, host, qdev_prop_hostaddr, PCIHostDevice), DEFINE_PROP_UINT32("iommu", AssignedDevice, use_iommu, 1), + DEFINE_PROP_INT32("configfd", AssignedDevice, real_device.config_fd, -1), DEFINE_PROP_END_OF_LIST(), }, };