[PATCH 1/7] pci: keep a stubDriver in each virPCIDevice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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).
---
 src/libvirt_private.syms |  2 ++
 src/util/virpci.c        | 19 +++++++++++++++++++
 src/util/virpci.h        |  5 ++++-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b3f8521..bbf15f6 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1604,6 +1604,7 @@ virPCIDeviceGetManaged;
 virPCIDeviceGetName;
 virPCIDeviceGetRemoveSlot;
 virPCIDeviceGetReprobe;
+virPCIDeviceGetStubDriver;
 virPCIDeviceGetUnbindFromStub;
 virPCIDeviceGetUsedBy;
 virPCIDeviceIsAssignable;
@@ -1623,6 +1624,7 @@ virPCIDeviceReset;
 virPCIDeviceSetManaged;
 virPCIDeviceSetRemoveSlot;
 virPCIDeviceSetReprobe;
+virPCIDeviceSetStubDriver;
 virPCIDeviceSetUnbindFromStub;
 virPCIDeviceSetUsedBy;
 virPCIDeviceWaitForCleanup;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index e58010b..73f36d0 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -66,6 +66,7 @@ struct _virPCIDevice {
     bool          has_flr;
     bool          has_pm_reset;
     bool          managed;
+    const char   *stubDriver;
 
     /* used by reattach function */
     bool          unbind_from_stub;
@@ -1151,6 +1152,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);
@@ -1181,6 +1185,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);
@@ -1466,6 +1473,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 67bee3d..db0be35 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);
-- 
1.7.11.7

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]