diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index d3c3618281..43a08f27d8 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 4e3154875e..7e32f5c050 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 1467796d4b..1bcc2fc82b 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 2e42d35274..48f45474c3 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); diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c index 26fcd7918c..f98fd08563 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -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; }