thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-vfio-cap-number-of-devices-that-can-be-assigned.patch

0a122b
From 4110ee428550f672ee1a1a73a634d5392bf9c55f Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <4110ee428550f672ee1a1a73a634d5392bf9c55f.1387382496.git.minovotn@redhat.com>
0a122b
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
0a122b
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
0a122b
From: Bandan Das <bsd@redhat.com>
0a122b
Date: Tue, 3 Dec 2013 20:05:13 +0100
0a122b
Subject: [PATCH 44/46] vfio: cap number of devices that can be assigned
0a122b
0a122b
RH-Author: Bandan Das <bsd@redhat.com>
0a122b
Message-id: <1386101113-31560-3-git-send-email-bsd@redhat.com>
0a122b
Patchwork-id: 55984
0a122b
O-Subject: [PATCH RHEL7 qemu-kvm v2 2/2] vfio: cap number of devices that can be assigned
0a122b
Bugzilla: 678368
0a122b
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
0a122b
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
0a122b
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
0a122b
0a122b
Go through all groups to get count of total number of devices
0a122b
active to enforce limit
0a122b
0a122b
Reasoning from Alex for the limit(32) - Assuming 3 slots per
0a122b
device, with 125 slots (number of memory slots for RHEL 7),
0a122b
we can support almost 40 devices and still have few slots left
0a122b
for other uses. Stepping down a bit, the number 32 arbitrarily
0a122b
matches the number of slots on a PCI bus and is also a nice power
0a122b
of two.
0a122b
0a122b
Signed-off-by: Bandan Das <bsd@redhat.com>
0a122b
---
0a122b
 hw/misc/vfio.c | 15 ++++++++++++++-
0a122b
 1 file changed, 14 insertions(+), 1 deletion(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 hw/misc/vfio.c | 15 ++++++++++++++-
0a122b
 1 file changed, 14 insertions(+), 1 deletion(-)
0a122b
0a122b
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
0a122b
index 250f96f..bd30130 100644
0a122b
--- a/hw/misc/vfio.c
0a122b
+++ b/hw/misc/vfio.c
0a122b
@@ -201,6 +201,7 @@ typedef struct VFIOGroup {
0a122b
 } VFIOGroup;
0a122b
 
0a122b
 #define MSIX_CAP_LENGTH 12
0a122b
+#define MAX_DEV_ASSIGN_CMDLINE 32
0a122b
 
0a122b
 static QLIST_HEAD(, VFIOContainer)
0a122b
     container_list = QLIST_HEAD_INITIALIZER(container_list);
0a122b
@@ -3557,7 +3558,19 @@ static int vfio_initfn(PCIDevice *pdev)
0a122b
     ssize_t len;
0a122b
     struct stat st;
0a122b
     int groupid;
0a122b
-    int ret;
0a122b
+    int ret, i = 0;
0a122b
+
0a122b
+    QLIST_FOREACH(group, &group_list, next) {
0a122b
+        QLIST_FOREACH(pvdev, &group->device_list, next) {
0a122b
+            i++;
0a122b
+        }
0a122b
+    }
0a122b
+
0a122b
+    if (i >= MAX_DEV_ASSIGN_CMDLINE) {
0a122b
+        error_report("vfio: Maximum supported vfio devices (%d) "
0a122b
+                     "already attached\n", MAX_DEV_ASSIGN_CMDLINE);
0a122b
+        return -1;
0a122b
+    }
0a122b
 
0a122b
     /* Check that the host device exists */
0a122b
     snprintf(path, sizeof(path),
0a122b
-- 
0a122b
1.7.11.7
0a122b