Since we moved the helpers from nodedev driver to src/conf, the actual
'update' function using those helpers should be moved as well so that we
don't need to call back into the driver.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
src/conf/node_device_conf.c | 54 ++++++++++++++++++++++++++++++++++++
src/conf/node_device_conf.h | 3 ++
src/libvirt_private.syms | 1 +
src/node_device/node_device_driver.c | 54 +-----------------------------------
4 files changed, 59 insertions(+), 53 deletions(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 5b0af559a..217673a56 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2433,6 +2433,60 @@ virNodeDeviceDeleteVport(virConnectPtr conn,
}
+int
+virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def)
+{
+ virNodeDevCapsDefPtr cap = def->caps;
+
+ while (cap) {
+ switch (cap->data.type) {
+ case VIR_NODE_DEV_CAP_SCSI_HOST:
+ virNodeDeviceGetSCSIHostCaps(&cap->data.scsi_host);
+ break;
+ case VIR_NODE_DEV_CAP_SCSI_TARGET:
+ virNodeDeviceGetSCSITargetCaps(def->sysfs_path,
+ &cap->data.scsi_target);
+ break;
+ case VIR_NODE_DEV_CAP_NET:
+ if (virNetDevGetLinkInfo(cap->data.net.ifname,
+ &cap->data.net.lnk) < 0)
+ return -1;
+ virBitmapFree(cap->data.net.features);
+ if (virNetDevGetFeatures(cap->data.net.ifname,
+ &cap->data.net.features) < 0)
+ return -1;
+ break;
+ case VIR_NODE_DEV_CAP_PCI_DEV:
+ if (virNodeDeviceGetPCIDynamicCaps(def->sysfs_path,
+ &cap->data.pci_dev) < 0)
+ return -1;
+ break;
+
+ /* all types that (supposedly) don't require any updates
+ * relative to what's in the cache.
+ */
+ case VIR_NODE_DEV_CAP_DRM:
+ case VIR_NODE_DEV_CAP_SYSTEM:
+ case VIR_NODE_DEV_CAP_USB_DEV:
+ case VIR_NODE_DEV_CAP_USB_INTERFACE:
+ case VIR_NODE_DEV_CAP_SCSI:
+ case VIR_NODE_DEV_CAP_STORAGE:
+ case VIR_NODE_DEV_CAP_FC_HOST:
+ case VIR_NODE_DEV_CAP_VPORTS:
+ case VIR_NODE_DEV_CAP_SCSI_GENERIC:
+ case VIR_NODE_DEV_CAP_MDEV_TYPES:
+ case VIR_NODE_DEV_CAP_MDEV:
+ case VIR_NODE_DEV_CAP_CCW_DEV:
+ case VIR_NODE_DEV_CAP_LAST:
+ break;
+ }
+ cap = cap->next;
+ }
+
+ return 0;
+}
+
+
#ifdef __linux__
int
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 4e3154875..7e32f5c05 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -400,4 +400,7 @@ virNodeDeviceGetSCSITargetCaps(const char *sysfsPath,
int
virNodeDeviceGetPCIDynamicCaps(const char *sysfsPath,
virNodeDevCapPCIDevPtr pci_dev);
+
+int
+virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def);
#endif /* __VIR_NODE_DEVICE_CONF_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0cd8086a6..6098cf121 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -711,6 +711,7 @@ virNodeDeviceGetPCIDynamicCaps;
virNodeDeviceGetSCSIHostCaps;
virNodeDeviceGetSCSITargetCaps;
virNodeDeviceGetWWNs;
+virNodeDeviceUpdateCaps;
# conf/node_device_event.h
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 2e42d3527..48f45474c 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -47,58 +47,6 @@
virNodeDeviceDriverStatePtr driver;
-static int
-nodeDeviceUpdateCaps(virNodeDeviceDefPtr def)
-{
- virNodeDevCapsDefPtr cap = def->caps;
-
- while (cap) {
- switch (cap->data.type) {
- case VIR_NODE_DEV_CAP_SCSI_HOST:
- virNodeDeviceGetSCSIHostCaps(&cap->data.scsi_host);
- break;
- case VIR_NODE_DEV_CAP_SCSI_TARGET:
- virNodeDeviceGetSCSITargetCaps(def->sysfs_path,
- &cap->data.scsi_target);
- break;
- case VIR_NODE_DEV_CAP_NET:
- if (virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.lnk)
< 0)
- return -1;
- virBitmapFree(cap->data.net.features);
- if (virNetDevGetFeatures(cap->data.net.ifname,
&cap->data.net.features) < 0)
- return -1;
- break;
- case VIR_NODE_DEV_CAP_PCI_DEV:
- if (virNodeDeviceGetPCIDynamicCaps(def->sysfs_path,
- &cap->data.pci_dev) < 0)
- return -1;
- break;
-
- /* all types that (supposedly) don't require any updates
- * relative to what's in the cache.
- */
- case VIR_NODE_DEV_CAP_DRM:
- case VIR_NODE_DEV_CAP_SYSTEM:
- case VIR_NODE_DEV_CAP_USB_DEV:
- case VIR_NODE_DEV_CAP_USB_INTERFACE:
- case VIR_NODE_DEV_CAP_SCSI:
- case VIR_NODE_DEV_CAP_STORAGE:
- case VIR_NODE_DEV_CAP_FC_HOST:
- case VIR_NODE_DEV_CAP_VPORTS:
- case VIR_NODE_DEV_CAP_SCSI_GENERIC:
- case VIR_NODE_DEV_CAP_MDEV_TYPES:
- case VIR_NODE_DEV_CAP_MDEV:
- case VIR_NODE_DEV_CAP_CCW_DEV:
- case VIR_NODE_DEV_CAP_LAST:
- break;
- }
- cap = cap->next;
- }
-
- return 0;
-}
-
-
#if defined (__linux__) && ( defined (WITH_HAL) || defined(WITH_UDEV))
/* NB: It was previously believed that changes in driver name were
* relayed to libvirt as "change" events by udev, and the udev event
@@ -314,7 +262,7 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr device,
if (nodeDeviceUpdateDriverName(def) < 0)
goto cleanup;
- if (nodeDeviceUpdateCaps(def) < 0)
+ if (virNodeDeviceUpdateCaps(def) < 0)
goto cleanup;
ret = virNodeDeviceDefFormat(def);
--
2.13.6