mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
util: new function virPCIDeviceRebind()
This function unbinds a device from its driver, then immediately rebinds it to its driver again. The code for this new function is just the 2nd half of virPCIDeviceBindWithDriverOverride(), so that function's 2nd half is replaced with a call to virPCIDeviceRebind().
This commit is contained in:
parent
9a238c16b3
commit
251d179bf2
@ -2233,6 +2233,7 @@ virPCIDeviceListSteal;
|
|||||||
virPCIDeviceListStealIndex;
|
virPCIDeviceListStealIndex;
|
||||||
virPCIDeviceNew;
|
virPCIDeviceNew;
|
||||||
virPCIDeviceReattach;
|
virPCIDeviceReattach;
|
||||||
|
virPCIDeviceRebind;
|
||||||
virPCIDeviceReset;
|
virPCIDeviceReset;
|
||||||
virPCIDeviceSetManaged;
|
virPCIDeviceSetManaged;
|
||||||
virPCIDeviceSetRemoveSlot;
|
virPCIDeviceSetRemoveSlot;
|
||||||
|
@ -1101,6 +1101,31 @@ virPCIDeviceUnbind(virPCIDevicePtr dev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virPCIDeviceRebind:
|
||||||
|
* @dev: virPCIDevice object describing the device to rebind
|
||||||
|
*
|
||||||
|
* unbind a device from its driver, then immediately rebind it.
|
||||||
|
*
|
||||||
|
* Returns 0 on success, -1 on failure
|
||||||
|
*/
|
||||||
|
int virPCIDeviceRebind(virPCIDevicePtr dev)
|
||||||
|
{
|
||||||
|
if (virPCIDeviceUnbind(dev) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0) {
|
||||||
|
virReportSystemError(errno,
|
||||||
|
_("Failed to trigger a probe for PCI device '%s'"),
|
||||||
|
dev->name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bind a PCI device to a driver using driver_override sysfs interface.
|
* Bind a PCI device to a driver using driver_override sysfs interface.
|
||||||
* E.g.
|
* E.g.
|
||||||
@ -1130,16 +1155,9 @@ virPCIDeviceBindWithDriverOverride(virPCIDevicePtr dev,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virPCIDeviceUnbind(dev) < 0)
|
if (virPCIDeviceRebind(dev) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0) {
|
|
||||||
virReportSystemError(errno,
|
|
||||||
_("Failed to trigger a probe for PCI device '%s'"),
|
|
||||||
dev->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -225,6 +225,7 @@ int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
|
|||||||
char **pfname, int *vf_index);
|
char **pfname, int *vf_index);
|
||||||
|
|
||||||
int virPCIDeviceUnbind(virPCIDevicePtr dev);
|
int virPCIDeviceUnbind(virPCIDevicePtr dev);
|
||||||
|
int virPCIDeviceRebind(virPCIDevicePtr dev);
|
||||||
int virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev,
|
int virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev,
|
||||||
char **path,
|
char **path,
|
||||||
char **name);
|
char **name);
|
||||||
|
Loading…
Reference in New Issue
Block a user