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>
This commit is contained in:
Laine Stump 2023-07-08 22:20:39 -04:00
parent cd2843f546
commit 1bb9617971
3 changed files with 22 additions and 0 deletions

View File

@ -3082,6 +3082,7 @@ virPCIDeviceGetManaged;
virPCIDeviceGetName; virPCIDeviceGetName;
virPCIDeviceGetRemoveSlot; virPCIDeviceGetRemoveSlot;
virPCIDeviceGetReprobe; virPCIDeviceGetReprobe;
virPCIDeviceGetStubDriverName;
virPCIDeviceGetStubDriverType; virPCIDeviceGetStubDriverType;
virPCIDeviceGetUnbindFromStub; virPCIDeviceGetUnbindFromStub;
virPCIDeviceGetUsedBy; virPCIDeviceGetUsedBy;
@ -3108,6 +3109,7 @@ virPCIDeviceReset;
virPCIDeviceSetManaged; virPCIDeviceSetManaged;
virPCIDeviceSetRemoveSlot; virPCIDeviceSetRemoveSlot;
virPCIDeviceSetReprobe; virPCIDeviceSetReprobe;
virPCIDeviceSetStubDriverName;
virPCIDeviceSetStubDriverType; virPCIDeviceSetStubDriverType;
virPCIDeviceSetUnbindFromStub; virPCIDeviceSetUnbindFromStub;
virPCIDeviceSetUsedBy; virPCIDeviceSetUsedBy;

View File

@ -88,6 +88,7 @@ struct _virPCIDevice {
bool managed; bool managed;
virPCIStubDriver stubDriverType; virPCIStubDriver stubDriverType;
char *stubDriverName; /* if blank, use default for type */
/* used by reattach function */ /* used by reattach function */
bool unbind_from_stub; bool unbind_from_stub;
@ -1508,6 +1509,7 @@ virPCIDeviceCopy(virPCIDevice *dev)
copy->path = g_strdup(dev->path); copy->path = g_strdup(dev->path);
copy->used_by_drvname = g_strdup(dev->used_by_drvname); copy->used_by_drvname = g_strdup(dev->used_by_drvname);
copy->used_by_domname = g_strdup(dev->used_by_domname); copy->used_by_domname = g_strdup(dev->used_by_domname);
copy->stubDriverName = g_strdup(dev->stubDriverName);
return copy; return copy;
} }
@ -1522,6 +1524,7 @@ virPCIDeviceFree(virPCIDevice *dev)
g_free(dev->path); g_free(dev->path);
g_free(dev->used_by_drvname); g_free(dev->used_by_drvname);
g_free(dev->used_by_domname); g_free(dev->used_by_domname);
g_free(dev->stubDriverName);
g_free(dev); g_free(dev);
} }
@ -1581,6 +1584,20 @@ virPCIDeviceGetStubDriverType(virPCIDevice *dev)
return dev->stubDriverType; 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 bool
virPCIDeviceGetUnbindFromStub(virPCIDevice *dev) virPCIDeviceGetUnbindFromStub(virPCIDevice *dev)
{ {

View File

@ -137,6 +137,9 @@ bool virPCIDeviceGetManaged(virPCIDevice *dev);
void virPCIDeviceSetStubDriverType(virPCIDevice *dev, void virPCIDeviceSetStubDriverType(virPCIDevice *dev,
virPCIStubDriver driverType); virPCIStubDriver driverType);
virPCIStubDriver virPCIDeviceGetStubDriverType(virPCIDevice *dev); virPCIStubDriver virPCIDeviceGetStubDriverType(virPCIDevice *dev);
void virPCIDeviceSetStubDriverName(virPCIDevice *dev,
const char *driverName);
const char *virPCIDeviceGetStubDriverName(virPCIDevice *dev);
virPCIDeviceAddress *virPCIDeviceGetAddress(virPCIDevice *dev); virPCIDeviceAddress *virPCIDeviceGetAddress(virPCIDevice *dev);
int virPCIDeviceSetUsedBy(virPCIDevice *dev, int virPCIDeviceSetUsedBy(virPCIDevice *dev,
const char *drv_name, const char *drv_name,