libvirt/SOURCES/libvirt-util-add-stub-driver-name-to-virPCIDevice-object.patch

100 lines
3.3 KiB
Diff

From 1bb961797153a92a40a3c517114e4920c65672d4 Mon Sep 17 00:00:00 2001
From: Laine Stump <laine@redhat.com>
Date: Sat, 8 Jul 2023 22:20:39 -0400
Subject: [PATCH] util: add stub driver name to virPCIDevice object
There can be many different drivers that are of the type "VFIO", so
add the driver name to the object and allow getting/setting it.
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/libvirt_private.syms | 2 ++
src/util/virpci.c | 17 +++++++++++++++++
src/util/virpci.h | 3 +++
3 files changed, 22 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 190bebdd625..0ca63f09552 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3082,6 +3082,7 @@ virPCIDeviceGetManaged;
virPCIDeviceGetName;
virPCIDeviceGetRemoveSlot;
virPCIDeviceGetReprobe;
+virPCIDeviceGetStubDriverName;
virPCIDeviceGetStubDriverType;
virPCIDeviceGetUnbindFromStub;
virPCIDeviceGetUsedBy;
@@ -3108,6 +3109,7 @@ virPCIDeviceReset;
virPCIDeviceSetManaged;
virPCIDeviceSetRemoveSlot;
virPCIDeviceSetReprobe;
+virPCIDeviceSetStubDriverName;
virPCIDeviceSetStubDriverType;
virPCIDeviceSetUnbindFromStub;
virPCIDeviceSetUsedBy;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index d86a81c2b1d..a53a51d55e2 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -88,6 +88,7 @@ struct _virPCIDevice {
bool managed;
virPCIStubDriver stubDriverType;
+ char *stubDriverName; /* if blank, use default for type */
/* used by reattach function */
bool unbind_from_stub;
@@ -1508,6 +1509,7 @@ virPCIDeviceCopy(virPCIDevice *dev)
copy->path = g_strdup(dev->path);
copy->used_by_drvname = g_strdup(dev->used_by_drvname);
copy->used_by_domname = g_strdup(dev->used_by_domname);
+ copy->stubDriverName = g_strdup(dev->stubDriverName);
return copy;
}
@@ -1522,6 +1524,7 @@ virPCIDeviceFree(virPCIDevice *dev)
g_free(dev->path);
g_free(dev->used_by_drvname);
g_free(dev->used_by_domname);
+ g_free(dev->stubDriverName);
g_free(dev);
}
@@ -1581,6 +1584,20 @@ virPCIDeviceGetStubDriverType(virPCIDevice *dev)
return dev->stubDriverType;
}
+void
+virPCIDeviceSetStubDriverName(virPCIDevice *dev,
+ const char *driverName)
+{
+ g_free(dev->stubDriverName);
+ dev->stubDriverName = g_strdup(driverName);
+}
+
+const char *
+virPCIDeviceGetStubDriverName(virPCIDevice *dev)
+{
+ return dev->stubDriverName;
+}
+
bool
virPCIDeviceGetUnbindFromStub(virPCIDevice *dev)
{
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 485f535bc91..f8f98f39de7 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -137,6 +137,9 @@ bool virPCIDeviceGetManaged(virPCIDevice *dev);
void virPCIDeviceSetStubDriverType(virPCIDevice *dev,
virPCIStubDriver driverType);
virPCIStubDriver virPCIDeviceGetStubDriverType(virPCIDevice *dev);
+void virPCIDeviceSetStubDriverName(virPCIDevice *dev,
+ const char *driverName);
+const char *virPCIDeviceGetStubDriverName(virPCIDevice *dev);
virPCIDeviceAddress *virPCIDeviceGetAddress(virPCIDevice *dev);
int virPCIDeviceSetUsedBy(virPCIDevice *dev,
const char *drv_name,