mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
pci: Remove redundant parameter from virPCIDeviceBindToStub()
This internal function supports, in theory, binding to a different stub driver than the one the PCI device has been configured to use. In practice, it is only ever called like virPCIDeviceBindToStub(dev, dev->stubDriver); which makes its second parameter redundant. Get rid of it, along with the extra string copy required to support it.
This commit is contained in:
parent
3245e1783c
commit
51f39c7048
@ -1177,20 +1177,18 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virPCIDeviceBindToStub(virPCIDevicePtr dev,
|
virPCIDeviceBindToStub(virPCIDevicePtr dev)
|
||||||
const char *stubDriverName)
|
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
bool reprobe = false;
|
bool reprobe = false;
|
||||||
char *stubDriverPath = NULL;
|
char *stubDriverPath = NULL;
|
||||||
char *driverLink = NULL;
|
char *driverLink = NULL;
|
||||||
char *path = NULL; /* reused for different purposes */
|
char *path = NULL; /* reused for different purposes */
|
||||||
char *newDriverName = NULL;
|
char *stubDriverName = dev->stubDriver;
|
||||||
virErrorPtr err = NULL;
|
virErrorPtr err = NULL;
|
||||||
|
|
||||||
if (!(stubDriverPath = virPCIDriverDir(stubDriverName)) ||
|
if (!(stubDriverPath = virPCIDriverDir(stubDriverName)) ||
|
||||||
!(driverLink = virPCIFile(dev->name, "driver")) ||
|
!(driverLink = virPCIFile(dev->name, "driver")))
|
||||||
VIR_STRDUP(newDriverName, stubDriverName) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virFileExists(driverLink)) {
|
if (virFileExists(driverLink)) {
|
||||||
@ -1305,13 +1303,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
|
|||||||
VIR_FREE(driverLink);
|
VIR_FREE(driverLink);
|
||||||
VIR_FREE(path);
|
VIR_FREE(path);
|
||||||
|
|
||||||
if (result < 0) {
|
if (result < 0)
|
||||||
VIR_FREE(newDriverName);
|
|
||||||
virPCIDeviceUnbindFromStub(dev);
|
virPCIDeviceUnbindFromStub(dev);
|
||||||
} else {
|
|
||||||
VIR_FREE(dev->stubDriver);
|
|
||||||
dev->stubDriver = newDriverName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
virSetError(err);
|
virSetError(err);
|
||||||
@ -1354,7 +1347,7 @@ virPCIDeviceDetach(virPCIDevicePtr dev,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virPCIDeviceBindToStub(dev, dev->stubDriver) < 0)
|
if (virPCIDeviceBindToStub(dev) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Add *a copy of* the dev into list inactiveDevs, if
|
/* Add *a copy of* the dev into list inactiveDevs, if
|
||||||
|
Loading…
Reference in New Issue
Block a user