]> git.proxmox.com Git - qemu.git/commitdiff
vfio-pci: Loosen sanity checks to allow future features
authorAlex Williamson <alex.williamson@redhat.com>
Tue, 8 Jan 2013 21:10:03 +0000 (14:10 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 8 Jan 2013 21:10:03 +0000 (14:10 -0700)
VFIO_PCI_NUM_REGIONS and VFIO_PCI_NUM_IRQS should never have been
used in this manner as it locks a specific kernel implementation.
Future features may introduce new regions or interrupt entries
(VGA may add legacy ranges, AER might add an IRQ for error
signalling).  Fix this before it gets us into trouble.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Cc: qemu-stable@nongnu.org
hw/vfio_pci.c

index 8ec1faf27e13c10d766c1c83998fc9605186d720..c51ae6761b7ba357ed24e92d392d1e8f6994301c 100644 (file)
@@ -1837,13 +1837,13 @@ static int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vdev)
         error_report("Warning, device %s does not support reset\n", name);
     }
 
-    if (dev_info.num_regions != VFIO_PCI_NUM_REGIONS) {
+    if (dev_info.num_regions < VFIO_PCI_CONFIG_REGION_INDEX + 1) {
         error_report("vfio: unexpected number of io regions %u\n",
                      dev_info.num_regions);
         goto error;
     }
 
-    if (dev_info.num_irqs != VFIO_PCI_NUM_IRQS) {
+    if (dev_info.num_irqs < VFIO_PCI_MSIX_IRQ_INDEX + 1) {
         error_report("vfio: unexpected number of irqs %u\n", dev_info.num_irqs);
         goto error;
     }