diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 882b77d3e2b27ef8bbef2c47882556201fb8b456..33ec37973d75401de49b5a5d7a356b2cdecd1629 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1606,6 +1606,7 @@ virPCIDeviceGetManaged; virPCIDeviceGetName; virPCIDeviceGetRemoveSlot; virPCIDeviceGetReprobe; +virPCIDeviceGetStubDriver; virPCIDeviceGetUnbindFromStub; virPCIDeviceGetUsedBy; virPCIDeviceIsAssignable; @@ -1625,6 +1626,7 @@ virPCIDeviceReset; virPCIDeviceSetManaged; virPCIDeviceSetRemoveSlot; virPCIDeviceSetReprobe; +virPCIDeviceSetStubDriver; virPCIDeviceSetUnbindFromStub; virPCIDeviceSetUsedBy; virPCIDeviceWaitForCleanup; diff --git a/src/util/virpci.c b/src/util/virpci.c index 5811f22c0518e674cb58890186ee9c715194fb0b..805406b5646222db4a1b7afb768caac62c4884d5 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -67,6 +67,7 @@ struct _virPCIDevice { bool has_flr; bool has_pm_reset; bool managed; + const char *stubDriver; /* used by reattach function */ bool unbind_from_stub; @@ -1152,6 +1153,9 @@ virPCIDeviceDetach(virPCIDevicePtr dev, virPCIDeviceList *inactiveDevs, const char *driver) { + if (!driver && dev->stubDriver) + driver = dev->stubDriver; + if (virPCIProbeStubDriver(driver) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to load PCI stub module %s"), driver); @@ -1182,6 +1186,9 @@ virPCIDeviceReattach(virPCIDevicePtr dev, virPCIDeviceListPtr inactiveDevs, const char *driver) { + if (!driver && dev->stubDriver) + driver = dev->stubDriver; + if (virPCIProbeStubDriver(driver) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to load PCI stub module %s"), driver); @@ -1467,6 +1474,18 @@ virPCIDeviceGetManaged(virPCIDevicePtr dev) return dev->managed; } +void +virPCIDeviceSetStubDriver(virPCIDevicePtr dev, const char *driver) +{ + dev->stubDriver = driver; +} + +const char * +virPCIDeviceGetStubDriver(virPCIDevicePtr dev) +{ + return dev->stubDriver; +} + unsigned int virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev) { diff --git a/src/util/virpci.h b/src/util/virpci.h index 67bee3d77f3c589005b0452ddde0b664f4c029bc..db0be35990655679d33dd64f611ede0495e4022a 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -1,7 +1,7 @@ /* * virpci.h: helper APIs for managing host PCI devices * - * Copyright (C) 2009, 2011-2012 Red Hat, Inc. + * Copyright (C) 2009, 2011-2013 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -63,6 +63,9 @@ int virPCIDeviceReset(virPCIDevicePtr dev, void virPCIDeviceSetManaged(virPCIDevice *dev, bool managed); unsigned int virPCIDeviceGetManaged(virPCIDevice *dev); +void virPCIDeviceSetStubDriver(virPCIDevicePtr dev, + const char *driver); +const char *virPCIDeviceGetStubDriver(virPCIDevicePtr dev); void virPCIDeviceSetUsedBy(virPCIDevice *dev, const char *used_by); const char *virPCIDeviceGetUsedBy(virPCIDevice *dev);