From patchwork Mon May 24 16:53:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 101904 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 o4OGrr6Q028051 for ; Mon, 24 May 2010 16:53:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757662Ab0EXQxv (ORCPT ); Mon, 24 May 2010 12:53:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15977 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757594Ab0EXQxv (ORCPT ); Mon, 24 May 2010 12:53:51 -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 o4OGroat002013 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 24 May 2010 12:53:50 -0400 Received: from [172.17.76.2] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4OGrodB011469; Mon, 24 May 2010 12:53:50 -0400 Subject: Re: [PATCH qemu-kvm] device-assignment: add config fd qdev property From: Alex Williamson To: Chris Wright Cc: kvm@vger.kernel.org In-Reply-To: <20100519190041.GK28275@x200.localdomain> References: <20100519190041.GK28275@x200.localdomain> Date: Mon, 24 May 2010 10:53:49 -0600 Message-ID: <1274720029.4205.12.camel@x201> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 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]); Mon, 24 May 2010 16:53:53 +0000 (UTC) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index eb31c78..3c5184f 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -37,6 +37,7 @@ #include "console.h" #include "device-assignment.h" #include "loader.h" +#include "monitor.h" #include /* From linux/ioport.h */ @@ -612,14 +613,28 @@ static int get_real_device(AssignedDevice *pci_dev, uint16_t r_seg, snprintf(name, sizeof(name), "%sconfig", dir); - fd = open(name, O_RDWR); - if (fd == -1) { - fprintf(stderr, "%s: %s: %m\n", __func__, name); - return 1; + if (pci_dev->configfd_name && *pci_dev->configfd_name) { + if (qemu_isdigit(pci_dev->configfd_name[0])) { + dev->config_fd = strtol(pci_dev->configfd_name, NULL, 0); + } else { + dev->config_fd = monitor_get_fd(cur_mon, pci_dev->configfd_name); + if (dev->config_fd < 0) { + fprintf(stderr, "%s: (%s) unkown\n", __func__, + pci_dev->configfd_name); + return 1; + } + } + } else { + dev->config_fd = open(name, O_RDWR); + + if (dev->config_fd == -1) { + fprintf(stderr, "%s: %s: %m\n", __func__, name); + return 1; + } } - dev->config_fd = fd; again: - r = read(fd, pci_dev->dev.config, pci_config_size(&pci_dev->dev)); + r = read(dev->config_fd, pci_dev->dev.config, + pci_config_size(&pci_dev->dev)); if (r < 0) { if (errno == EINTR || errno == EAGAIN) goto again; @@ -1433,6 +1448,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_STRING("configfd", AssignedDevice, configfd_name), DEFINE_PROP_END_OF_LIST(), }, }; diff --git a/hw/device-assignment.h b/hw/device-assignment.h index d561112..f70ace9 100644 --- a/hw/device-assignment.h +++ b/hw/device-assignment.h @@ -104,6 +104,7 @@ typedef struct AssignedDevice { target_phys_addr_t msix_table_addr; int mmio_index; int need_emulate_cmd; + char *configfd_name; QLIST_ENTRY(AssignedDevice) next; } AssignedDevice;