nodedev: Export nodeDeviceUpdateCaps from node_device_conf.c

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@redhat.com>
This commit is contained in:
Erik Skultety 2018-01-18 11:07:25 +01:00
parent f83c7c88c5
commit 349dda1fc8
5 changed files with 60 additions and 54 deletions

View File

@ -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__ #ifdef __linux__
int int

View File

@ -400,4 +400,7 @@ virNodeDeviceGetSCSITargetCaps(const char *sysfsPath,
int int
virNodeDeviceGetPCIDynamicCaps(const char *sysfsPath, virNodeDeviceGetPCIDynamicCaps(const char *sysfsPath,
virNodeDevCapPCIDevPtr pci_dev); virNodeDevCapPCIDevPtr pci_dev);
int
virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def);
#endif /* __VIR_NODE_DEVICE_CONF_H__ */ #endif /* __VIR_NODE_DEVICE_CONF_H__ */

View File

@ -711,6 +711,7 @@ virNodeDeviceGetPCIDynamicCaps;
virNodeDeviceGetSCSIHostCaps; virNodeDeviceGetSCSIHostCaps;
virNodeDeviceGetSCSITargetCaps; virNodeDeviceGetSCSITargetCaps;
virNodeDeviceGetWWNs; virNodeDeviceGetWWNs;
virNodeDeviceUpdateCaps;
# conf/node_device_event.h # conf/node_device_event.h

View File

@ -47,58 +47,6 @@
virNodeDeviceDriverStatePtr driver; 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)) #if defined (__linux__) && ( defined (WITH_HAL) || defined(WITH_UDEV))
/* NB: It was previously believed that changes in driver name were /* NB: It was previously believed that changes in driver name were
* relayed to libvirt as "change" events by udev, and the udev event * relayed to libvirt as "change" events by udev, and the udev event
@ -314,7 +262,7 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr device,
if (nodeDeviceUpdateDriverName(def) < 0) if (nodeDeviceUpdateDriverName(def) < 0)
goto cleanup; goto cleanup;
if (nodeDeviceUpdateCaps(def) < 0) if (virNodeDeviceUpdateCaps(def) < 0)
goto cleanup; goto cleanup;
ret = virNodeDeviceDefFormat(def); ret = virNodeDeviceDefFormat(def);

View File

@ -150,7 +150,7 @@ gather_pci_cap(LibHalContext *ctx, const char *udi,
ignore_value(virStrToLong_ui(p+1, &p, 16, &d->pci_dev.function)); ignore_value(virStrToLong_ui(p+1, &p, 16, &d->pci_dev.function));
} }
if (nodeDeviceSysfsGetPCIRelatedDevCaps(sysfs_path, &d->pci_dev) < 0) { if (virNodeDeviceGetPCIDynamicCaps(sysfs_path, &d->pci_dev) < 0) {
VIR_FREE(sysfs_path); VIR_FREE(sysfs_path);
return -1; return -1;
} }