libvirt/SOURCES/libvirt-util-rename-virPCIDeviceGetDriverPathAndName.patch
2023-12-07 16:52:11 +03:00

133 lines
5.3 KiB
Diff

From 222b66974e8256965c089fb0f244dc1e01f708e7 Mon Sep 17 00:00:00 2001
From: Laine Stump <laine@redhat.com>
Date: Sat, 8 Jul 2023 23:12:09 -0400
Subject: [PATCH] util: rename virPCIDeviceGetDriverPathAndName
Instead, call it virPCIDeviceGetCurrentDriverPathAndName() to avoid
confusion with the device name that is stored in the virPCIDevice
object - that one is not necessarily the name of the current driver
for the device, but could instead be the driver that we want to be
bound to the device in the future.
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/hypervisor/virhostdev.c | 7 ++++---
src/libvirt_private.syms | 2 +-
src/util/virpci.c | 10 ++++++----
src/util/virpci.h | 6 +++---
tests/virpcitest.c | 2 +-
5 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index c437ca9d22d..244f057c6ce 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -765,9 +765,10 @@ virHostdevPreparePCIDevicesImpl(virHostdevManager *mgr,
* information about active / inactive device across
* daemon restarts has been implemented */
- if (virPCIDeviceGetDriverPathAndName(pci,
- &driverPath, &driverName) < 0)
+ if (virPCIDeviceGetCurrentDriverPathAndName(pci, &driverPath,
+ &driverName) < 0) {
goto reattachdevs;
+ }
stub = virPCIStubDriverTypeFromString(driverName);
@@ -2294,7 +2295,7 @@ virHostdevPrepareOneNVMeDevice(virHostdevManager *hostdev_mgr,
g_autofree char *drvName = NULL;
int stub = VIR_PCI_STUB_DRIVER_NONE;
- if (virPCIDeviceGetDriverPathAndName(pci, &drvPath, &drvName) < 0)
+ if (virPCIDeviceGetCurrentDriverPathAndName(pci, &drvPath, &drvName) < 0)
goto cleanup;
if (drvName)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0ca63f09552..cc564928170 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3074,7 +3074,7 @@ virPCIDeviceFileIterate;
virPCIDeviceFree;
virPCIDeviceGetAddress;
virPCIDeviceGetConfigPath;
-virPCIDeviceGetDriverPathAndName;
+virPCIDeviceGetCurrentDriverPathAndName;
virPCIDeviceGetIOMMUGroupDev;
virPCIDeviceGetIOMMUGroupList;
virPCIDeviceGetLinkCapSta;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index a53a51d55e2..e6f7554b232 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -228,7 +228,7 @@ virPCIFile(const char *device, const char *file)
}
-/* virPCIDeviceGetDriverPathAndName - put the path to the driver
+/* virPCIDeviceGetCurrentDriverPathAndName - put the path to the driver
* directory of the driver in use for this device in @path and the
* name of the driver in @name. Both could be NULL if it's not bound
* to any driver.
@@ -236,7 +236,9 @@ virPCIFile(const char *device, const char *file)
* Return 0 for success, -1 for error.
*/
int
-virPCIDeviceGetDriverPathAndName(virPCIDevice *dev, char **path, char **name)
+virPCIDeviceGetCurrentDriverPathAndName(virPCIDevice *dev,
+ char **path,
+ char **name)
{
int ret = -1;
g_autofree char *drvlink = NULL;
@@ -1032,7 +1034,7 @@ virPCIDeviceReset(virPCIDevice *dev,
* reset it whenever appropriate, so doing it ourselves would just
* be redundant.
*/
- if (virPCIDeviceGetDriverPathAndName(dev, &drvPath, &drvName) < 0)
+ if (virPCIDeviceGetCurrentDriverPathAndName(dev, &drvPath, &drvName) < 0)
goto cleanup;
if (virPCIStubDriverTypeFromString(drvName) == VIR_PCI_STUB_DRIVER_VFIO) {
@@ -1137,7 +1139,7 @@ virPCIDeviceUnbind(virPCIDevice *dev)
g_autofree char *drvpath = NULL;
g_autofree char *driver = NULL;
- if (virPCIDeviceGetDriverPathAndName(dev, &drvpath, &driver) < 0)
+ if (virPCIDeviceGetCurrentDriverPathAndName(dev, &drvpath, &driver) < 0)
return -1;
if (!driver)
diff --git a/src/util/virpci.h b/src/util/virpci.h
index f8f98f39de7..19c910202a2 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -280,9 +280,9 @@ virPCIVPDResource * virPCIDeviceGetVPD(virPCIDevice *dev);
int virPCIDeviceUnbind(virPCIDevice *dev);
int virPCIDeviceRebind(virPCIDevice *dev);
-int virPCIDeviceGetDriverPathAndName(virPCIDevice *dev,
- char **path,
- char **name);
+int virPCIDeviceGetCurrentDriverPathAndName(virPCIDevice *dev,
+ char **path,
+ char **name);
int virPCIDeviceIsPCIExpress(virPCIDevice *dev);
int virPCIDeviceHasPCIExpressLink(virPCIDevice *dev);
diff --git a/tests/virpcitest.c b/tests/virpcitest.c
index 92cc8c07c6f..d69a1b51183 100644
--- a/tests/virpcitest.c
+++ b/tests/virpcitest.c
@@ -37,7 +37,7 @@ testVirPCIDeviceCheckDriver(virPCIDevice *dev, const char *expected)
g_autofree char *path = NULL;
g_autofree char *driver = NULL;
- if (virPCIDeviceGetDriverPathAndName(dev, &path, &driver) < 0)
+ if (virPCIDeviceGetCurrentDriverPathAndName(dev, &path, &driver) < 0)
return -1;
if (STRNEQ_NULLABLE(driver, expected)) {