forked from pool/libvirt
91a43d315c
Add some SLE12 SP2 fixes to the Factory/Tumbleweed libvirt package. - BuildRequires: use librbd-devel instead of ceph-devel - Enable rbd support for aarch64 bsc#979473 - Use driver_override sysfs interface for binding/unbinding PCI stub drivers pci-simplify-stub.patch, pci-use-driver-override-sysfs.patch bsc#986718 OBS-URL: https://build.opensuse.org/request/show/408966 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=551
119 lines
4.2 KiB
Diff
119 lines
4.2 KiB
Diff
commit caba00f00fb18d8ffc388f4fc8b82527ef98d3b0
|
|
Author: Jim Fehlig <jfehlig@suse.com>
|
|
Date: Wed Jul 6 14:06:37 2016 -0600
|
|
|
|
virpci: simplify virPCIDeviceBindToStub
|
|
|
|
Early in virPCIDeviceBindToStub, there is a check to see if the
|
|
stub is already bound to the device, returning success with no
|
|
further actions if that is the case.
|
|
|
|
The same condition is unnecessarily checked later in the function.
|
|
Remove the unneeded checks to simplify the logic a bit.
|
|
|
|
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
|
|
|
Index: libvirt-2.0.0/src/util/virpci.c
|
|
===================================================================
|
|
--- libvirt-2.0.0.orig/src/util/virpci.c
|
|
+++ libvirt-2.0.0/src/util/virpci.c
|
|
@@ -1196,7 +1196,6 @@ static int
|
|
virPCIDeviceBindToStub(virPCIDevicePtr dev)
|
|
{
|
|
int result = -1;
|
|
- bool reprobe = false;
|
|
char *stubDriverPath = NULL;
|
|
char *driverLink = NULL;
|
|
char *path = NULL; /* reused for different purposes */
|
|
@@ -1225,10 +1224,16 @@ virPCIDeviceBindToStub(virPCIDevicePtr d
|
|
/* The device is already bound to the correct driver */
|
|
VIR_DEBUG("Device %s is already bound to %s",
|
|
dev->name, stubDriverName);
|
|
+ dev->unbind_from_stub = true;
|
|
+ dev->remove_slot = true;
|
|
result = 0;
|
|
goto cleanup;
|
|
}
|
|
- reprobe = true;
|
|
+ /*
|
|
+ * If the device is bound to a driver that is not the stub, we'll
|
|
+ * need to reprobe later
|
|
+ */
|
|
+ dev->reprobe = true;
|
|
}
|
|
|
|
/* Add the PCI device ID to the stub's dynamic ID table;
|
|
@@ -1249,51 +1254,34 @@ virPCIDeviceBindToStub(virPCIDevicePtr d
|
|
goto cleanup;
|
|
}
|
|
|
|
- /* check whether the device is bound to pci-stub when we write dev->id to
|
|
- * ${stubDriver}/new_id.
|
|
- */
|
|
- if (virFileLinkPointsTo(driverLink, stubDriverPath)) {
|
|
- dev->unbind_from_stub = true;
|
|
- dev->remove_slot = true;
|
|
- result = 0;
|
|
+ if (virPCIDeviceUnbind(dev) < 0)
|
|
goto remove_id;
|
|
- }
|
|
|
|
- if (virPCIDeviceUnbind(dev) < 0)
|
|
+ /* Xen's pciback.ko wants you to use new_slot first */
|
|
+ VIR_FREE(path);
|
|
+ if (!(path = virPCIDriverFile(stubDriverName, "new_slot")))
|
|
goto remove_id;
|
|
|
|
- /* If the device was bound to a driver we'll need to reprobe later */
|
|
- dev->reprobe = reprobe;
|
|
+ if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
|
|
+ virReportSystemError(errno,
|
|
+ _("Failed to add slot for "
|
|
+ "PCI device '%s' to %s"),
|
|
+ dev->name, stubDriverName);
|
|
+ goto remove_id;
|
|
+ }
|
|
+ dev->remove_slot = true;
|
|
|
|
- /* If the device isn't already bound to pci-stub, try binding it now.
|
|
- */
|
|
- if (!virFileLinkPointsTo(driverLink, stubDriverPath)) {
|
|
- /* Xen's pciback.ko wants you to use new_slot first */
|
|
- VIR_FREE(path);
|
|
- if (!(path = virPCIDriverFile(stubDriverName, "new_slot")))
|
|
- goto remove_id;
|
|
-
|
|
- if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
|
|
- virReportSystemError(errno,
|
|
- _("Failed to add slot for "
|
|
- "PCI device '%s' to %s"),
|
|
- dev->name, stubDriverName);
|
|
- goto remove_id;
|
|
- }
|
|
- dev->remove_slot = true;
|
|
+ VIR_FREE(path);
|
|
+ if (!(path = virPCIDriverFile(stubDriverName, "bind")))
|
|
+ goto remove_id;
|
|
|
|
- VIR_FREE(path);
|
|
- if (!(path = virPCIDriverFile(stubDriverName, "bind")))
|
|
- goto remove_id;
|
|
-
|
|
- if (virFileWriteStr(path, dev->name, 0) < 0) {
|
|
- virReportSystemError(errno,
|
|
- _("Failed to bind PCI device '%s' to %s"),
|
|
- dev->name, stubDriverName);
|
|
- goto remove_id;
|
|
- }
|
|
- dev->unbind_from_stub = true;
|
|
+ if (virFileWriteStr(path, dev->name, 0) < 0) {
|
|
+ virReportSystemError(errno,
|
|
+ _("Failed to bind PCI device '%s' to %s"),
|
|
+ dev->name, stubDriverName);
|
|
+ goto remove_id;
|
|
}
|
|
+ dev->unbind_from_stub = true;
|
|
|
|
result = 0;
|
|
|