[libvirt] [PATCH] fix the failure of nodedev-reattach caused by the variables from nodedev-attach

the "virsh nodedev-reattch" command could return successfully, but the pci device is still bound to pci-stub driver. The reason is noddev-reattach trys to use the variables set by nodedev-dettach commands. Becuase these variables is not persistent, this is not we expected. the patch try to fix it. --- src/util/pci.c | 74 +++++++++++++++++++------------------------------------ 1 files changed, 26 insertions(+), 48 deletions(-) diff --git a/src/util/pci.c b/src/util/pci.c index 46a3a83..d345c3e 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -67,9 +67,6 @@ struct _pciDevice { unsigned managed : 1; /* used by reattach function */ - unsigned unbind_from_stub : 1; - unsigned remove_slot : 1; - unsigned reprobe : 1; }; struct _pciDeviceList { @@ -882,14 +879,23 @@ pciUnbindDeviceFromStub(pciDevice *dev, const char *driver) if (pciDriverDir(&drvdir, driver) < 0) goto cleanup; - if (!dev->unbind_from_stub) - goto remove_slot; - - /* If the device is bound to stub, unbind it. - */ if (pciDeviceFile(&path, dev->name, "driver") < 0) goto cleanup; + /* If the device is bound to a driver instead of pci-stub, do nothing. + */ + if (virFileExists(path) && ! virFileLinkPointsTo(path, drvdir)){ + result = 0; + goto cleanup; + } + + /* If the device is not bound to any driver, reprobe it. + */ + if (!virFileExists(path)) + goto reprobe; + + /* If the device is bound to stub, unbind it. + */ if (virFileExists(drvdir) && virFileLinkPointsTo(path, drvdir)) { if (pciDriverFile(&path, driver, "unbind") < 0) { goto cleanup; @@ -902,11 +908,6 @@ pciUnbindDeviceFromStub(pciDevice *dev, const char *driver) goto cleanup; } } - dev->unbind_from_stub = 0; - -remove_slot: - if (!dev->remove_slot) - goto reprobe; /* Xen's pciback.ko wants you to use remove_slot on the specific device */ if (pciDriverFile(&path, driver, "remove_slot") < 0) { @@ -919,14 +920,8 @@ remove_slot: dev->name, driver); goto cleanup; } - dev->remove_slot = 0; reprobe: - if (!dev->reprobe) { - result = 0; - goto cleanup; - } - /* Trigger a re-probe of the device is not in the stub's dynamic * ID table. If the stub is available, but 'remove_id' isn't * available, then re-probing would just cause the device to be @@ -935,6 +930,12 @@ reprobe: if (pciDriverFile(&path, driver, "remove_id") < 0) { goto cleanup; } + + /* If the device is still in stub's dynamic ID table,remove it, + * otherwise, ignore the error. + */ + if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0){ + } if (!virFileExists(drvdir) || virFileExists(path)) { if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0) { @@ -948,11 +949,6 @@ reprobe: result = 0; cleanup: - /* do not do it again */ - dev->unbind_from_stub = 0; - dev->remove_slot = 0; - dev->reprobe = 0; - VIR_FREE(drvdir); VIR_FREE(path); @@ -966,7 +962,6 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) int result = -1; char *drvdir = NULL; char *path = NULL; - int reprobe = 0; /* check whether the device is already bound to a driver */ if (pciDriverDir(&drvdir, driver) < 0 || @@ -980,7 +975,6 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) result = 0; goto cleanup; } - reprobe = 1; } /* Add the PCI device ID to the stub's dynamic ID table; @@ -1011,8 +1005,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) } if (virFileLinkPointsTo(path, drvdir)) { - dev->unbind_from_stub = 1; - dev->remove_slot = 1; + result = 0; goto remove_id; } @@ -1022,7 +1015,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) * your root filesystem. */ if (pciDeviceFile(&path, dev->name, "driver/unbind") < 0) { - goto cleanup; + goto remove_id; } if (virFileExists(path)) { @@ -1030,9 +1023,8 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) virReportSystemError(errno, _("Failed to unbind PCI device '%s'"), dev->name); - goto cleanup; + goto remove_id; } - dev->reprobe = reprobe; } /* If the device isn't already bound to pci-stub, try binding it now. @@ -1054,7 +1046,6 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) dev->name, driver); goto remove_id; } - dev->remove_slot = 1; if (pciDriverFile(&path, driver, "bind") < 0) { goto remove_id; @@ -1066,20 +1057,15 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) dev->name, driver); goto remove_id; } - dev->unbind_from_stub = 1; } + result = 0; remove_id: /* If 'remove_id' exists, remove the device id from pci-stub's dynamic * ID table so that 'drivers_probe' works below. */ if (pciDriverFile(&path, driver, "remove_id") < 0) { - /* We do not remove PCI ID from pci-stub, and we cannot reprobe it */ - if (dev->reprobe) { - VIR_WARN("Could not remove PCI ID '%s' from %s, and the device " - "cannot be probed again.", dev->id, driver); - } - dev->reprobe = 0; + result = -1; goto cleanup; } @@ -1087,18 +1073,10 @@ remove_id: virReportSystemError(errno, _("Failed to remove PCI ID '%s' from %s"), dev->id, driver); - - /* remove PCI ID from pci-stub failed, and we cannot reprobe it */ - if (dev->reprobe) { - VIR_WARN("Failed to remove PCI ID '%s' from %s, and the device " - "cannot be probed again.", dev->id, driver); - } - dev->reprobe = 0; + result = -1; goto cleanup; } - result = 0; - cleanup: VIR_FREE(drvdir); VIR_FREE(path); -- 1.7.1

At 2011-7-1 18:24, Guannan Ren write:
the "virsh nodedev-reattch" command could return successfully, but the pci device is still bound to pci-stub driver. The reason is noddev-reattach trys to use the variables set by nodedev-dettach commands. Becuase these variables is not persistent, this is not we expected. the patch try to fix it.
I do not agree with this patch. You should read this mail: https://www.redhat.com/archives/libvir-list/2011-April/msg00315.html This patch will cause regression about hotpluging host pci device. I think the problem is that: the init value of these variables is wrong. We can fix this bug by modifing pciGetDevice() or its caller.
--- src/util/pci.c | 74 +++++++++++++++++++------------------------------------ 1 files changed, 26 insertions(+), 48 deletions(-)
diff --git a/src/util/pci.c b/src/util/pci.c index 46a3a83..d345c3e 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -67,9 +67,6 @@ struct _pciDevice { unsigned managed : 1;
/* used by reattach function */ - unsigned unbind_from_stub : 1; - unsigned remove_slot : 1; - unsigned reprobe : 1; };
struct _pciDeviceList { @@ -882,14 +879,23 @@ pciUnbindDeviceFromStub(pciDevice *dev, const char *driver) if (pciDriverDir(&drvdir, driver)< 0) goto cleanup;
- if (!dev->unbind_from_stub) - goto remove_slot; - - /* If the device is bound to stub, unbind it. - */ if (pciDeviceFile(&path, dev->name, "driver")< 0) goto cleanup;
+ /* If the device is bound to a driver instead of pci-stub, do nothing. + */ + if (virFileExists(path)&& ! virFileLinkPointsTo(path, drvdir)){ + result = 0; + goto cleanup; + } + + /* If the device is not bound to any driver, reprobe it. + */ + if (!virFileExists(path)) + goto reprobe; + + /* If the device is bound to stub, unbind it. + */ if (virFileExists(drvdir)&& virFileLinkPointsTo(path, drvdir)) { if (pciDriverFile(&path, driver, "unbind")< 0) { goto cleanup; @@ -902,11 +908,6 @@ pciUnbindDeviceFromStub(pciDevice *dev, const char *driver) goto cleanup; } } - dev->unbind_from_stub = 0; - -remove_slot: - if (!dev->remove_slot) - goto reprobe;
/* Xen's pciback.ko wants you to use remove_slot on the specific device */ if (pciDriverFile(&path, driver, "remove_slot")< 0) { @@ -919,14 +920,8 @@ remove_slot: dev->name, driver); goto cleanup; } - dev->remove_slot = 0;
reprobe: - if (!dev->reprobe) { - result = 0; - goto cleanup; - } - /* Trigger a re-probe of the device is not in the stub's dynamic * ID table. If the stub is available, but 'remove_id' isn't * available, then re-probing would just cause the device to be @@ -935,6 +930,12 @@ reprobe: if (pciDriverFile(&path, driver, "remove_id")< 0) { goto cleanup; } + + /* If the device is still in stub's dynamic ID table,remove it, + * otherwise, ignore the error. + */ + if (virFileExists(path)&& virFileWriteStr(path, dev->name, 0)< 0){ + }
if (!virFileExists(drvdir) || virFileExists(path)) { if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0)< 0) { @@ -948,11 +949,6 @@ reprobe: result = 0;
cleanup: - /* do not do it again */ - dev->unbind_from_stub = 0; - dev->remove_slot = 0; - dev->reprobe = 0; - VIR_FREE(drvdir); VIR_FREE(path);
@@ -966,7 +962,6 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) int result = -1; char *drvdir = NULL; char *path = NULL; - int reprobe = 0;
/* check whether the device is already bound to a driver */ if (pciDriverDir(&drvdir, driver)< 0 || @@ -980,7 +975,6 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) result = 0; goto cleanup; } - reprobe = 1; }
/* Add the PCI device ID to the stub's dynamic ID table; @@ -1011,8 +1005,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) }
if (virFileLinkPointsTo(path, drvdir)) { - dev->unbind_from_stub = 1; - dev->remove_slot = 1; + result = 0; goto remove_id; }
@@ -1022,7 +1015,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) * your root filesystem. */ if (pciDeviceFile(&path, dev->name, "driver/unbind")< 0) { - goto cleanup; + goto remove_id; }
if (virFileExists(path)) { @@ -1030,9 +1023,8 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) virReportSystemError(errno, _("Failed to unbind PCI device '%s'"), dev->name); - goto cleanup; + goto remove_id; } - dev->reprobe = reprobe; }
/* If the device isn't already bound to pci-stub, try binding it now. @@ -1054,7 +1046,6 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) dev->name, driver); goto remove_id; } - dev->remove_slot = 1;
if (pciDriverFile(&path, driver, "bind")< 0) { goto remove_id; @@ -1066,20 +1057,15 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) dev->name, driver); goto remove_id; } - dev->unbind_from_stub = 1; }
+ result = 0; remove_id: /* If 'remove_id' exists, remove the device id from pci-stub's dynamic * ID table so that 'drivers_probe' works below. */ if (pciDriverFile(&path, driver, "remove_id")< 0) { - /* We do not remove PCI ID from pci-stub, and we cannot reprobe it */ - if (dev->reprobe) { - VIR_WARN("Could not remove PCI ID '%s' from %s, and the device " - "cannot be probed again.", dev->id, driver); - } - dev->reprobe = 0; + result = -1; goto cleanup; }
@@ -1087,18 +1073,10 @@ remove_id: virReportSystemError(errno, _("Failed to remove PCI ID '%s' from %s"), dev->id, driver); - - /* remove PCI ID from pci-stub failed, and we cannot reprobe it */ - if (dev->reprobe) { - VIR_WARN("Failed to remove PCI ID '%s' from %s, and the device " - "cannot be probed again.", dev->id, driver); - } - dev->reprobe = 0; + result = -1; goto cleanup; }
- result = 0; - cleanup: VIR_FREE(drvdir); VIR_FREE(path);

On 07/01/2011 11:30 PM, ghostwcy wrote:
At 2011-7-1 18:24, Guannan Ren write:
the "virsh nodedev-reattch" command could return successfully, but the pci device is still bound to pci-stub driver. The reason is noddev-reattach trys to use the variables set by nodedev-dettach commands. Becuase these variables is not persistent, this is not we expected. the patch try to fix it.
I do not agree with this patch. You should read this mail: https://www.redhat.com/archives/libvir-list/2011-April/msg00315.html
This patch will cause regression about hotpluging host pci device.
I think the problem is that: the init value of these variables is wrong. We can fix this bug by modifing pciGetDevice() or its caller.
I read the patch, it introduced the mechanism to check whether the device is bound to pci-stub when we write dev-id to new_id if a new device with this ID is hotpluggged, or if a probe is triggered for such a device, I think my patch kept it working. The overall idea is as follows: If the device is already bound to pci-stub, then do nothing. If not, try to write dev-id to "new_id", then check the state of its driver(hotplug issue) Unbind from its original driver , then bind to pci-stub driver Anyway, we should write dev-id to "remove_id" to protect the device from causing problems when reattaching it. About fixing the problem from pciGetDevice(), unless we feedback the state of pci device to libvirtd but I don't think it is easier.

At 2011-7-2 13:27, Guannan Ren write:
On 07/01/2011 11:30 PM, ghostwcy wrote:
At 2011-7-1 18:24, Guannan Ren write:
the "virsh nodedev-reattch" command could return successfully, but the pci device is still bound to pci-stub driver. The reason is noddev-reattach trys to use the variables set by nodedev-dettach commands. Becuase these variables is not persistent, this is not we expected. the patch try to fix it.
I do not agree with this patch. You should read this mail: https://www.redhat.com/archives/libvir-list/2011-April/msg00315.html
This patch will cause regression about hotpluging host pci device.
I think the problem is that: the init value of these variables is wrong. We can fix this bug by modifing pciGetDevice() or its caller.
I read the patch, it introduced the mechanism to check whether the device is bound to pci-stub when we write dev-id to new_id if a new device with this ID is hotpluggged, or if a probe is triggered for such a device, I think my patch kept it working.
I think my explanation is not detailed. For example: The user runs 'virsh attach-device' to pass through host pci device to guest os. We will call the function qemuPrepareHostdevPCIDevices() to bind the pci device to pci-stub, and reset it. If the pci device does not support reset function, we will call pciReAttachDevice() to rollback the things we have done. If the device is alread bound to pci-stub before the user runs 'virsh attach-device', we should do nothing. If the device is not bound to any driver, we should unbound it from pci-stub. If the device is bound to other driver, we should unbound it from pci-stub, and reprobe it. When we call pciReAttachDevice(), the device is bound to pci-stub, but we do the different thing, because the origin state of the pci device is different. So I add these three variables to remember what we do in pciDettachDevice().
The overall idea is as follows: If the device is already bound to pci-stub, then do nothing. If not, try to write dev-id to "new_id", then check the state of its driver(hotplug issue) Unbind from its original driver , then bind to pci-stub driver Anyway, we should write dev-id to "remove_id" to protect the device from causing problems when reattaching it. About fixing the problem from pciGetDevice(), unless we feedback the state of pci device to libvirtd but I don't think it is easier.
We already have pciDeviceSetManaged() and pciDeviceGetManaged(). I think we should add some similar APIs in util/pci.c to modify and read these three variables. And we call these new APIs in qemudNodeDeviceDettach() to set these three variables to correct value(I think these three variables should be 1).

On 07/02/2011 06:10 PM, Wen Congyang wrote:
At 2011-7-2 13:27, Guannan Ren write:
On 07/01/2011 11:30 PM, ghostwcy wrote:
At 2011-7-1 18:24, Guannan Ren write:
the "virsh nodedev-reattch" command could return successfully, but the pci device is still bound to pci-stub driver. The reason is noddev-reattach trys to use the variables set by nodedev-dettach commands. Becuase these variables is not persistent, this is not we expected. the patch try to fix it.
I do not agree with this patch. You should read this mail: https://www.redhat.com/archives/libvir-list/2011-April/msg00315.html
This patch will cause regression about hotpluging host pci device.
I think the problem is that: the init value of these variables is wrong. We can fix this bug by modifing pciGetDevice() or its caller.
I read the patch, it introduced the mechanism to check whether the device is bound to pci-stub when we write dev-id to new_id if a new device with this ID is hotpluggged, or if a probe is triggered for such a device, I think my patch kept it working.
I think my explanation is not detailed. For example:
The user runs 'virsh attach-device' to pass through host pci device to guest os. We will call the function qemuPrepareHostdevPCIDevices() to bind the pci device to pci-stub, and reset it. If the pci device does not support reset function, we will call pciReAttachDevice() to rollback the things we have done.
If the device is alread bound to pci-stub before the user runs 'virsh attach-device', we should do nothing. If the device is not bound to any driver, we should unbound it from pci-stub. If the device is bound to other driver, we should unbound it from pci-stub, and reprobe it.
When we call pciReAttachDevice(), the device is bound to pci-stub, but we do the different thing, because the origin state of the pci device is different. So I add these three variables to remember what we do in pciDettachDevice().
Yep, the state of the pci device is different possibly or probably, I made the determination in pciUnbindDeviceFromStub() by examining the name and existence of pci device driver.
The overall idea is as follows: If the device is already bound to pci-stub, then do nothing. If not, try to write dev-id to "new_id", then check the state of its driver(hotplug issue) Unbind from its original driver , then bind to pci-stub driver Anyway, we should write dev-id to "remove_id" to protect the device from causing problems when reattaching it. About fixing the problem from pciGetDevice(), unless we feedback the state of pci device to libvirtd but I don't think it is easier.
We already have pciDeviceSetManaged() and pciDeviceGetManaged(). I think we should add some similar APIs in util/pci.c to modify and read these three variables.
The "managed" is from the xml file to "virsh attach-device" executed each time, but the values of these three variables are generated in running time , it is hard to keep them to the next command.
And we call these new APIs in qemudNodeDeviceDettach() to set these three variables to correct value(I think these three variables should be 1).

On 07/03/2011 05:43 PM, Guannan Ren wrote:
On 07/02/2011 06:10 PM, Wen Congyang wrote:
At 2011-7-2 13:27, Guannan Ren write:
On 07/01/2011 11:30 PM, ghostwcy wrote:
At 2011-7-1 18:24, Guannan Ren write:
the "virsh nodedev-reattch" command could return successfully, but the pci device is still bound to pci-stub driver. The reason is noddev-reattach trys to use the variables set by nodedev-dettach commands. Becuase these variables is not persistent, this is not we expected. the patch try to fix it.
I do not agree with this patch. You should read this mail: https://www.redhat.com/archives/libvir-list/2011-April/msg00315.html
This patch will cause regression about hotpluging host pci device.
I think the problem is that: the init value of these variables is wrong. We can fix this bug by modifing pciGetDevice() or its caller.
I read the patch, it introduced the mechanism to check whether the device is bound to pci-stub when we write dev-id to new_id if a new device with this ID is hotpluggged, or if a probe is triggered for such a device, I think my patch kept it working.
I think my explanation is not detailed. For example:
The user runs 'virsh attach-device' to pass through host pci device to guest os. We will call the function qemuPrepareHostdevPCIDevices() to bind the pci device to pci-stub, and reset it. If the pci device does not support reset function, we will call pciReAttachDevice() to rollback the things we have done.
If the device is alread bound to pci-stub before the user runs 'virsh attach-device', we should do nothing. If the device is not bound to any driver, we should unbound it from pci-stub. If the device is bound to other driver, we should unbound it from pci-stub, and reprobe it.
When we call pciReAttachDevice(), the device is bound to pci-stub, but we do the different thing, because the origin state of the pci device is different. So I add these three variables to remember what we do in pciDettachDevice().
Yep, the state of the pci device is different possibly or probably, I made the determination in pciUnbindDeviceFromStub() by examining the name and existence of pci device driver.
The overall idea is as follows: If the device is already bound to pci-stub, then do nothing. If not, try to write dev-id to "new_id", then check the state of its driver(hotplug issue) Unbind from its original driver , then bind to pci-stub driver Anyway, we should write dev-id to "remove_id" to protect the device from causing problems when reattaching it. About fixing the problem from pciGetDevice(), unless we feedback the state of pci device to libvirtd but I don't think it is easier.
We already have pciDeviceSetManaged() and pciDeviceGetManaged(). I think we should add some similar APIs in util/pci.c to modify and read these three variables.
The "managed" is from the xml file to "virsh attach-device" executed each time, but the values of these three variables are generated in running time , it is hard to keep them to the next command.
And we call these new APIs in qemudNodeDeviceDettach() to set these three variables to correct value(I think these three variables should be 1).
sorry I missed above words, I will try to add a function to set these three values to 1 by default. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Initilize three state value of device driver to 1. This is just for a new call to qemudNodeDeviceReAttach() --- src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 2 ++ src/util/pci.c | 8 ++++++++ src/util/pci.h | 1 + 4 files changed, 12 insertions(+), 0 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 626ac6c..062dcff 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -807,6 +807,7 @@ pciGetDevice; pciReAttachDevice; pciResetDevice; pciWaitForDeviceCleanup; +pciDeviceReAttachInit; # processinfo.h diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 363a361..56ccf44 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7193,6 +7193,8 @@ qemudNodeDeviceReAttach (virNodeDevicePtr dev) if (!pci) return -1; + pciDeviceReAttachInit(pci); + qemuDriverLock(driver); if (pciReAttachDevice(pci, driver->activePciHostdevs) < 0) goto out; diff --git a/src/util/pci.c b/src/util/pci.c index 21c12b9..e3f978c 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -1382,6 +1382,14 @@ unsigned pciDeviceGetManaged(pciDevice *dev) return dev->managed; } +void pciDeviceReAttachInit(pciDevice *pci) +{ + pci->unbind_from_stub = 1; + pci->remove_slot = 1; + pci->reprobe = 1; +} + + pciDeviceList * pciDeviceListNew(void) { diff --git a/src/util/pci.h b/src/util/pci.h index b767930..a351baf 100644 --- a/src/util/pci.h +++ b/src/util/pci.h @@ -40,6 +40,7 @@ int pciResetDevice (pciDevice *dev, void pciDeviceSetManaged(pciDevice *dev, unsigned managed); unsigned pciDeviceGetManaged(pciDevice *dev); +void pciDeviceReAttachInit(pciDevice *dev); pciDeviceList *pciDeviceListNew (void); void pciDeviceListFree (pciDeviceList *list); -- 1.7.1

At 07/03/2011 08:09 PM, Guannan Ren Write:
Initilize three state value of device driver to 1. This is just for a new call to qemudNodeDeviceReAttach()
--- src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 2 ++ src/util/pci.c | 8 ++++++++ src/util/pci.h | 1 + 4 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 626ac6c..062dcff 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -807,6 +807,7 @@ pciGetDevice; pciReAttachDevice; pciResetDevice; pciWaitForDeviceCleanup; +pciDeviceReAttachInit;
# processinfo.h diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 363a361..56ccf44 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7193,6 +7193,8 @@ qemudNodeDeviceReAttach (virNodeDevicePtr dev) if (!pci) return -1;
+ pciDeviceReAttachInit(pci); + qemuDriverLock(driver); if (pciReAttachDevice(pci, driver->activePciHostdevs) < 0) goto out; diff --git a/src/util/pci.c b/src/util/pci.c index 21c12b9..e3f978c 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -1382,6 +1382,14 @@ unsigned pciDeviceGetManaged(pciDevice *dev) return dev->managed; }
+void pciDeviceReAttachInit(pciDevice *pci) +{ + pci->unbind_from_stub = 1; + pci->remove_slot = 1; + pci->reprobe = 1; +} + + pciDeviceList * pciDeviceListNew(void) { diff --git a/src/util/pci.h b/src/util/pci.h index b767930..a351baf 100644 --- a/src/util/pci.h +++ b/src/util/pci.h @@ -40,6 +40,7 @@ int pciResetDevice (pciDevice *dev, void pciDeviceSetManaged(pciDevice *dev, unsigned managed); unsigned pciDeviceGetManaged(pciDevice *dev); +void pciDeviceReAttachInit(pciDevice *dev);
pciDeviceList *pciDeviceListNew (void); void pciDeviceListFree (pciDeviceList *list);
This patch works for me. ACK

On 07/03/2011 08:14 PM, Wen Congyang wrote:
At 07/03/2011 08:09 PM, Guannan Ren Write:
Initilize three state value of device driver to 1. This is just for a new call to
s/initilize/initialize/
qemudNodeDeviceReAttach()
--- src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 2 ++ src/util/pci.c | 8 ++++++++ src/util/pci.h | 1 + 4 files changed, 12 insertions(+), 0 deletions(-)
This patch works for me. ACK
I also added Guannan to AUTHORS; let me know if I need to update anything there. Pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (5)
-
Eric Blake
-
ghostwcy
-
Guannan Ren
-
Wen Congyang
-
Wen Congyang