提交 349dda1f 编写于 作者: E Erik Skultety

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: NErik Skultety <eskultet@redhat.com>
上级 f83c7c88
......@@ -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
......
......@@ -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__ */
......@@ -711,6 +711,7 @@ virNodeDeviceGetPCIDynamicCaps;
virNodeDeviceGetSCSIHostCaps;
virNodeDeviceGetSCSITargetCaps;
virNodeDeviceGetWWNs;
virNodeDeviceUpdateCaps;
# conf/node_device_event.h
......
......@@ -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);
......
......@@ -150,7 +150,7 @@ gather_pci_cap(LibHalContext *ctx, const char *udi,
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);
return -1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册