]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
pcie: Introduce pcie_sriov_num_vfs
authorAkihiko Odaki <akihiko.odaki@daynix.com>
Thu, 23 Feb 2023 10:50:50 +0000 (19:50 +0900)
committerMichael Tokarev <mjt@tls.msk.ru>
Thu, 14 Mar 2024 18:24:34 +0000 (21:24 +0300)
igb can use this function to change its behavior depending on the
number of virtual functions currently enabled.

Signed-off-by: Gal Hammer <gal.hammer@sap.com>
Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit 31180dbdca2859ae9841939f85158908453ea01d)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: needed for v8.2.0-2290-g91bb64a8d2
 "hw/nvme: Use pcie_sriov_num_vfs()" (CVE-2024-26328))

hw/pci/pcie_sriov.c
include/hw/pci/pcie_sriov.h

index 61a4e0676861b8e6839488cba00a469649cafd31..3703d250f0f406d998ba53229f8e226d371c3a65 100644 (file)
@@ -299,3 +299,8 @@ PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n)
     }
     return NULL;
 }
+
+uint16_t pcie_sriov_num_vfs(PCIDevice *dev)
+{
+    return dev->exp.sriov_pf.num_vfs;
+}
index 80f5c84e75cff279df3938d7f70e4b32e76e7c29..072a583405b75acc17cb143649e83e8b397253dc 100644 (file)
@@ -74,4 +74,7 @@ PCIDevice *pcie_sriov_get_pf(PCIDevice *dev);
  */
 PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n);
 
+/* Returns the current number of virtual functions. */
+uint16_t pcie_sriov_num_vfs(PCIDevice *dev);
+
 #endif /* QEMU_PCIE_SRIOV_H */