112 lines
4.1 KiB
Diff
112 lines
4.1 KiB
Diff
|
From 2b89558946fc396c6ecb10249b69960d2a74e18f Mon Sep 17 00:00:00 2001
|
||
|
From: Bandan Das <bsd@redhat.com>
|
||
|
Date: Wed, 12 Jun 2019 16:56:23 +0100
|
||
|
Subject: [PATCH 3/3] vfio: increase the cap on number of assigned devices to
|
||
|
64
|
||
|
|
||
|
RH-Author: Bandan Das <bsd@redhat.com>
|
||
|
Message-id: <jpgy32691zc.fsf@linux.bootlegged.copy>
|
||
|
Patchwork-id: 88653
|
||
|
O-Subject: [RHEL-AV-8.1.0 qemu-kvm PATCH] vfio: increase the cap on number of assigned devices to 64
|
||
|
Bugzilla: 1719823
|
||
|
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
|
||
|
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
||
|
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
||
|
|
||
|
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1719823
|
||
|
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=22124174
|
||
|
Branch: rhel-av-8.1.0/master-4.0.0
|
||
|
Upstrea: N/A, the device limit change is downstream only
|
||
|
|
||
|
In addition to bumping up the limit, also add a property for
|
||
|
future-proofing. This needs to be set for every assigned device
|
||
|
or via "global": -global vfio-pci.x-assigned-device-limit
|
||
|
|
||
|
RHEL Notes:
|
||
|
For each vm using vfio, there is at least a container fd. For
|
||
|
each assigned device, there is likely a group fd, a device fd,
|
||
|
an error signaling fd and a device request fd. Assuming SR-IOV
|
||
|
VFs, vectors/device considering MSI/MSI-X could be ~3-5. Therefore,
|
||
|
we have ~14 file descriptors per device or 897 for 64 devices.
|
||
|
The default open fd limit is 1024 on Linux but libvirt bumps it to
|
||
|
8192 and the qemu process inherits that value as well.
|
||
|
|
||
|
Signed-off-by: Bandan Das <bsd@redhat.com>
|
||
|
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||
|
---
|
||
|
hw/vfio/pci.c | 20 +++++++++++++++++---
|
||
|
hw/vfio/pci.h | 1 +
|
||
|
2 files changed, 18 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
||
|
index 7c998af..7c0d93a 100644
|
||
|
--- a/hw/vfio/pci.c
|
||
|
+++ b/hw/vfio/pci.c
|
||
|
@@ -36,11 +36,13 @@
|
||
|
#include "qapi/error.h"
|
||
|
|
||
|
#define MSIX_CAP_LENGTH 12
|
||
|
-#define MAX_DEV_ASSIGN_CMDLINE 32
|
||
|
|
||
|
#define TYPE_VFIO_PCI "vfio-pci"
|
||
|
#define PCI_VFIO(obj) OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI)
|
||
|
|
||
|
+/* RHEL only: Set once for the first assigned dev */
|
||
|
+static uint16_t device_limit;
|
||
|
+
|
||
|
static void vfio_disable_interrupts(VFIOPCIDevice *vdev);
|
||
|
static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled);
|
||
|
|
||
|
@@ -2810,15 +2812,24 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
||
|
int ret, i = 0;
|
||
|
bool is_mdev;
|
||
|
|
||
|
+ if (device_limit && device_limit != vdev->assigned_device_limit) {
|
||
|
+ error_setg(errp, "Assigned device limit has been redefined. "
|
||
|
+ "Old:%d, New:%d",
|
||
|
+ device_limit, vdev->assigned_device_limit);
|
||
|
+ return;
|
||
|
+ } else {
|
||
|
+ device_limit = vdev->assigned_device_limit;
|
||
|
+ }
|
||
|
+
|
||
|
QLIST_FOREACH(group, &vfio_group_list, next) {
|
||
|
QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- if (i >= MAX_DEV_ASSIGN_CMDLINE) {
|
||
|
+ if (i >= vdev->assigned_device_limit) {
|
||
|
error_setg(errp, "Maximum supported vfio devices (%d) "
|
||
|
- "already attached", MAX_DEV_ASSIGN_CMDLINE);
|
||
|
+ "already attached", vdev->assigned_device_limit);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
@@ -3223,6 +3234,9 @@ static Property vfio_pci_dev_properties[] = {
|
||
|
DEFINE_PROP_BOOL("x-no-kvm-msix", VFIOPCIDevice, no_kvm_msix, false),
|
||
|
DEFINE_PROP_BOOL("x-no-geforce-quirks", VFIOPCIDevice,
|
||
|
no_geforce_quirks, false),
|
||
|
+ /* RHEL only */
|
||
|
+ DEFINE_PROP_UINT16("x-assigned-device-limit", VFIOPCIDevice,
|
||
|
+ assigned_device_limit, 64),
|
||
|
DEFINE_PROP_BOOL("x-no-kvm-ioeventfd", VFIOPCIDevice, no_kvm_ioeventfd,
|
||
|
false),
|
||
|
DEFINE_PROP_BOOL("x-no-vfio-ioeventfd", VFIOPCIDevice, no_vfio_ioeventfd,
|
||
|
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
|
||
|
index c11c3f1..29a8add 100644
|
||
|
--- a/hw/vfio/pci.h
|
||
|
+++ b/hw/vfio/pci.h
|
||
|
@@ -136,6 +136,7 @@ typedef struct VFIOPCIDevice {
|
||
|
EventNotifier err_notifier;
|
||
|
EventNotifier req_notifier;
|
||
|
int (*resetfn)(struct VFIOPCIDevice *);
|
||
|
+ uint16_t assigned_device_limit;
|
||
|
uint32_t vendor_id;
|
||
|
uint32_t device_id;
|
||
|
uint32_t sub_vendor_id;
|
||
|
--
|
||
|
1.8.3.1
|
||
|
|