提交 be64199e 编写于 作者: L Laine Stump

pci: keep a stubDriver in each virPCIDevice

This can be set when the virPCIDevice is created and placed on a list,
then used later when traversing the list to determine which stub
driver to bind/unbind for managed devices.

The existing Detach and Attach functions' signatures haven't been
changed (they still accept a stub driver name in the arg list), but if
the arg list has NULL for stub driver and one is available in the
device's object, that will be used. (we may later deprecate and remove
the arg from those functions).
上级 731b0f36
...@@ -1606,6 +1606,7 @@ virPCIDeviceGetManaged; ...@@ -1606,6 +1606,7 @@ virPCIDeviceGetManaged;
virPCIDeviceGetName; virPCIDeviceGetName;
virPCIDeviceGetRemoveSlot; virPCIDeviceGetRemoveSlot;
virPCIDeviceGetReprobe; virPCIDeviceGetReprobe;
virPCIDeviceGetStubDriver;
virPCIDeviceGetUnbindFromStub; virPCIDeviceGetUnbindFromStub;
virPCIDeviceGetUsedBy; virPCIDeviceGetUsedBy;
virPCIDeviceIsAssignable; virPCIDeviceIsAssignable;
...@@ -1625,6 +1626,7 @@ virPCIDeviceReset; ...@@ -1625,6 +1626,7 @@ virPCIDeviceReset;
virPCIDeviceSetManaged; virPCIDeviceSetManaged;
virPCIDeviceSetRemoveSlot; virPCIDeviceSetRemoveSlot;
virPCIDeviceSetReprobe; virPCIDeviceSetReprobe;
virPCIDeviceSetStubDriver;
virPCIDeviceSetUnbindFromStub; virPCIDeviceSetUnbindFromStub;
virPCIDeviceSetUsedBy; virPCIDeviceSetUsedBy;
virPCIDeviceWaitForCleanup; virPCIDeviceWaitForCleanup;
......
...@@ -67,6 +67,7 @@ struct _virPCIDevice { ...@@ -67,6 +67,7 @@ struct _virPCIDevice {
bool has_flr; bool has_flr;
bool has_pm_reset; bool has_pm_reset;
bool managed; bool managed;
const char *stubDriver;
/* used by reattach function */ /* used by reattach function */
bool unbind_from_stub; bool unbind_from_stub;
...@@ -1152,6 +1153,9 @@ virPCIDeviceDetach(virPCIDevicePtr dev, ...@@ -1152,6 +1153,9 @@ virPCIDeviceDetach(virPCIDevicePtr dev,
virPCIDeviceList *inactiveDevs, virPCIDeviceList *inactiveDevs,
const char *driver) const char *driver)
{ {
if (!driver && dev->stubDriver)
driver = dev->stubDriver;
if (virPCIProbeStubDriver(driver) < 0) { if (virPCIProbeStubDriver(driver) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to load PCI stub module %s"), driver); _("Failed to load PCI stub module %s"), driver);
...@@ -1182,6 +1186,9 @@ virPCIDeviceReattach(virPCIDevicePtr dev, ...@@ -1182,6 +1186,9 @@ virPCIDeviceReattach(virPCIDevicePtr dev,
virPCIDeviceListPtr inactiveDevs, virPCIDeviceListPtr inactiveDevs,
const char *driver) const char *driver)
{ {
if (!driver && dev->stubDriver)
driver = dev->stubDriver;
if (virPCIProbeStubDriver(driver) < 0) { if (virPCIProbeStubDriver(driver) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to load PCI stub module %s"), driver); _("Failed to load PCI stub module %s"), driver);
...@@ -1467,6 +1474,18 @@ virPCIDeviceGetManaged(virPCIDevicePtr dev) ...@@ -1467,6 +1474,18 @@ virPCIDeviceGetManaged(virPCIDevicePtr dev)
return dev->managed; return dev->managed;
} }
void
virPCIDeviceSetStubDriver(virPCIDevicePtr dev, const char *driver)
{
dev->stubDriver = driver;
}
const char *
virPCIDeviceGetStubDriver(virPCIDevicePtr dev)
{
return dev->stubDriver;
}
unsigned int unsigned int
virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev) virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev)
{ {
......
/* /*
* virpci.h: helper APIs for managing host PCI devices * 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -63,6 +63,9 @@ int virPCIDeviceReset(virPCIDevicePtr dev, ...@@ -63,6 +63,9 @@ int virPCIDeviceReset(virPCIDevicePtr dev,
void virPCIDeviceSetManaged(virPCIDevice *dev, void virPCIDeviceSetManaged(virPCIDevice *dev,
bool managed); bool managed);
unsigned int virPCIDeviceGetManaged(virPCIDevice *dev); unsigned int virPCIDeviceGetManaged(virPCIDevice *dev);
void virPCIDeviceSetStubDriver(virPCIDevicePtr dev,
const char *driver);
const char *virPCIDeviceGetStubDriver(virPCIDevicePtr dev);
void virPCIDeviceSetUsedBy(virPCIDevice *dev, void virPCIDeviceSetUsedBy(virPCIDevice *dev,
const char *used_by); const char *used_by);
const char *virPCIDeviceGetUsedBy(virPCIDevice *dev); const char *virPCIDeviceGetUsedBy(virPCIDevice *dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册