diff mbox

[qemu-kvm] device-assignment: add config fd qdev property

Message ID 20100519190041.GK28275@x200.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wright May 19, 2010, 7 p.m. UTC
None
diff mbox

Patch

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(),
     },
 };