vf) < 0)
goto cleanup;
} else {
+ /* In practice this should never happen, since we currently
+ * only support assigning SRIOV VFs via <interface
+ * type='hostdev'>, and it is only those devices that should
+ * end up calling this function.
+ */
if (virPCIGetNetName(sysfs_path, linkdev) < 0)
goto cleanup;
+
+ if (!linkdev) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("The device at %s has no network device name"),
+ sysfs_path);
+ goto cleanup;
+ }
+
*vf = -1;
}
}
if (virPCIGetNetName(pci_sysfs_device_link, &((*vfname)[i])) < 0)
+ goto cleanup;
+
+ if (!(*vfname)[i])
VIR_INFO("VF does not have an interface name");
}
if (virNetDevSysfsDeviceFile(&physfn_sysfs_path, ifname, "physfn") < 0)
return ret;
- ret = virPCIGetNetName(physfn_sysfs_path, pfname);
+ if (virPCIGetNetName(physfn_sysfs_path, pfname) < 0)
+ goto cleanup;
- VIR_FREE(physfn_sysfs_path);
+ if (!*pfname) {
+ /* this shouldn't be possible. A VF can't exist unless its
+ * PF device is bound to a network driver
+ */
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("The PF device for VF %s has no network device name"),
+ ifname);
+ goto cleanup;
+ }
+ ret = 0;
+ cleanup:
+ VIR_FREE(physfn_sysfs_path);
return ret;
}
return -1;
}
- if (virDirOpenQuiet(&dir, pcidev_sysfs_net_path) < 0)
+ if (virDirOpenQuiet(&dir, pcidev_sysfs_net_path) < 0) {
+ /* this *isn't* an error - caller needs to check for netname == NULL */
+ ret = 0;
goto out;
+ }
while (virDirRead(dir, &entry, pcidev_sysfs_net_path) > 0) {
/* Assume a single directory entry */
int ret = -1;
if (virPCIGetPhysicalFunction(vf_sysfs_device_path, &pf_config_address) < 0)
- return ret;
+ goto cleanup;
if (!pf_config_address)
- return ret;
+ goto cleanup;
if (virPCIDeviceAddressGetSysfsFile(pf_config_address,
&pf_sysfs_device_path) < 0) {
+ goto cleanup;
+ }
- VIR_FREE(pf_config_address);
- return ret;
+ if (virPCIGetVirtualFunctionIndex(pf_sysfs_device_path,
+ vf_sysfs_device_path, vf_index) < 0) {
+ goto cleanup;
}
- if (virPCIGetVirtualFunctionIndex(pf_sysfs_device_path, vf_sysfs_device_path,
- vf_index) < 0)
+ if (virPCIGetNetName(pf_sysfs_device_path, pfname) < 0)
goto cleanup;
- ret = virPCIGetNetName(pf_sysfs_device_path, pfname);
+ if (!*pfname) {
+ /* this shouldn't be possible. A VF can't exist unless its
+ * PF device is bound to a network driver
+ */
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("The PF device for VF %s has no network device name"),
+ vf_sysfs_device_path);
+ goto cleanup;
+ }
+ ret = 0;
cleanup:
VIR_FREE(pf_config_address);
VIR_FREE(pf_sysfs_device_path);