Rename APIs for dealing with virtual/physical functions

Rename ifaceIsVirtualFunction to virNetDevIsVirtualFunction,
ifaceGetVirtualFunctionIndex to virNetDevGetVirtualFunctionIndex
and ifaceGetPhysicalFunction to virNetDevGetPhysicalFunction

* src/util/interface.c, src/util/interface.h: Rename APIs
* src/util/virnetdevvportprofile.c: Update for API rename
This commit is contained in:
Daniel P. Berrange 2011-11-03 12:37:07 +00:00
parent 5373cb74bd
commit 8f688c85af
4 changed files with 39 additions and 39 deletions

View File

@ -579,10 +579,10 @@ virNetDevValidateConfig;
virNetDevGetIndex; virNetDevGetIndex;
virNetDevGetIPv4Address; virNetDevGetIPv4Address;
ifaceGetNthParent; ifaceGetNthParent;
ifaceGetPhysicalFunction; virNetDevGetPhysicalFunction;
ifaceGetVirtualFunctionIndex; virNetDevGetVirtualFunctionIndex;
virNetDevGetVLanID; virNetDevGetVLanID;
ifaceIsVirtualFunction; virNetDevIsVirtualFunction;
virNetDevMacVLanCreate; virNetDevMacVLanCreate;
virNetDevMacVLanDelete; virNetDevMacVLanDelete;
ifaceMacvtapLinkDump; ifaceMacvtapLinkDump;

View File

@ -299,7 +299,7 @@ ifaceGetNthParent(int ifindex ATTRIBUTE_UNUSED,
#ifdef __linux__ #ifdef __linux__
static int static int
ifaceSysfsFile(char **pf_sysfs_device_link, const char *ifname, virNetDevSysfsFile(char **pf_sysfs_device_link, const char *ifname,
const char *file) const char *file)
{ {
@ -313,7 +313,7 @@ ifaceSysfsFile(char **pf_sysfs_device_link, const char *ifname,
} }
static int static int
ifaceSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname, virNetDevSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname,
const char *file) const char *file)
{ {
@ -327,8 +327,7 @@ ifaceSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname,
} }
/** /**
* ifaceIsVirtualFunction * virNetDevIsVirtualFunction:
*
* @ifname : name of the interface * @ifname : name of the interface
* *
* Checks if an interface is a SRIOV virtual function. * Checks if an interface is a SRIOV virtual function.
@ -337,12 +336,12 @@ ifaceSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname,
* *
*/ */
int int
ifaceIsVirtualFunction(const char *ifname) virNetDevIsVirtualFunction(const char *ifname)
{ {
char *if_sysfs_device_link = NULL; char *if_sysfs_device_link = NULL;
int ret = -1; int ret = -1;
if (ifaceSysfsFile(&if_sysfs_device_link, ifname, "device") < 0) if (virNetDevSysfsFile(&if_sysfs_device_link, ifname, "device") < 0)
return ret; return ret;
ret = pciDeviceIsVirtualFunction(if_sysfs_device_link); ret = pciDeviceIsVirtualFunction(if_sysfs_device_link);
@ -353,7 +352,7 @@ ifaceIsVirtualFunction(const char *ifname)
} }
/** /**
* ifaceGetVirtualFunctionIndex * virNetDevGetVirtualFunctionIndex
* *
* @pfname : name of the physical function interface name * @pfname : name of the physical function interface name
* @vfname : name of the virtual function interface name * @vfname : name of the virtual function interface name
@ -364,16 +363,16 @@ ifaceIsVirtualFunction(const char *ifname)
* *
*/ */
int int
ifaceGetVirtualFunctionIndex(const char *pfname, const char *vfname, virNetDevGetVirtualFunctionIndex(const char *pfname, const char *vfname,
int *vf_index) int *vf_index)
{ {
char *pf_sysfs_device_link = NULL, *vf_sysfs_device_link = NULL; char *pf_sysfs_device_link = NULL, *vf_sysfs_device_link = NULL;
int ret = -1; int ret = -1;
if (ifaceSysfsFile(&pf_sysfs_device_link, pfname, "device") < 0) if (virNetDevSysfsFile(&pf_sysfs_device_link, pfname, "device") < 0)
return ret; return ret;
if (ifaceSysfsFile(&vf_sysfs_device_link, vfname, "device") < 0) { if (virNetDevSysfsFile(&vf_sysfs_device_link, vfname, "device") < 0) {
VIR_FREE(pf_sysfs_device_link); VIR_FREE(pf_sysfs_device_link);
return ret; return ret;
} }
@ -389,7 +388,7 @@ ifaceGetVirtualFunctionIndex(const char *pfname, const char *vfname,
} }
/** /**
* ifaceGetPhysicalFunction * virNetDevGetPhysicalFunction
* *
* @ifname : name of the physical function interface name * @ifname : name of the physical function interface name
* @pfname : Contains sriov physical function for interface ifname * @pfname : Contains sriov physical function for interface ifname
@ -399,12 +398,12 @@ ifaceGetVirtualFunctionIndex(const char *pfname, const char *vfname,
* *
*/ */
int int
ifaceGetPhysicalFunction(const char *ifname, char **pfname) virNetDevGetPhysicalFunction(const char *ifname, char **pfname)
{ {
char *physfn_sysfs_path = NULL; char *physfn_sysfs_path = NULL;
int ret = -1; int ret = -1;
if (ifaceSysfsDeviceFile(&physfn_sysfs_path, ifname, "physfn") < 0) if (virNetDevSysfsDeviceFile(&physfn_sysfs_path, ifname, "physfn") < 0)
return ret; return ret;
ret = pciDeviceNetName(physfn_sysfs_path, pfname); ret = pciDeviceNetName(physfn_sysfs_path, pfname);
@ -413,34 +412,31 @@ ifaceGetPhysicalFunction(const char *ifname, char **pfname)
return ret; return ret;
} }
#else #else /* !__linux__ */
int int
ifaceIsVirtualFunction(const char *ifname ATTRIBUTE_UNUSED) virNetDevIsVirtualFunction(const char *ifname ATTRIBUTE_UNUSED)
{ {
ifaceError(VIR_ERR_INTERNAL_ERROR, "%s", virReportSystemError(ENOSYS, "%s",
_("ifaceIsVirtualFunction is not supported on non-linux " _("Unable to check virtual function status on this platfornm"));
"platforms"));
return -1; return -1;
} }
int int
ifaceGetVirtualFunctionIndex(const char *pfname ATTRIBUTE_UNUSED, virNetDevGetVirtualFunctionIndex(const char *pfname ATTRIBUTE_UNUSED,
const char *vfname ATTRIBUTE_UNUSED, const char *vfname ATTRIBUTE_UNUSED,
int *vf_index ATTRIBUTE_UNUSED) int *vf_index ATTRIBUTE_UNUSED)
{ {
ifaceError(VIR_ERR_INTERNAL_ERROR, "%s", virReportSystemError(ENOSYS, "%s",
_("ifaceGetVirtualFunctionIndex is not supported on non-linux " _("Unable to get virtual function index on this platfornm"));
"platforms"));
return -1; return -1;
} }
int int
ifaceGetPhysicalFunction(const char *ifname ATTRIBUTE_UNUSED, virNetDevGetPhysicalFunction(const char *ifname ATTRIBUTE_UNUSED,
char **pfname ATTRIBUTE_UNUSED) char **pfname ATTRIBUTE_UNUSED)
{ {
ifaceError(VIR_ERR_INTERNAL_ERROR, "%s", virReportSystemError(ENOSYS, "%s",
_("ifaceGetPhysicalFunction is not supported on non-linux " _("Unable to get physical function status on this platfornm"));
"platforms"));
return -1; return -1;
} }
#endif /* __linux__ */ #endif /* !__linux__ */

View File

@ -40,11 +40,15 @@ int ifaceGetNthParent(int ifindex, const char *ifname, unsigned int nthParent,
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5)
ATTRIBUTE_NONNULL(6); ATTRIBUTE_NONNULL(6);
int ifaceIsVirtualFunction(const char *ifname); int virNetDevIsVirtualFunction(const char *ifname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int ifaceGetVirtualFunctionIndex(const char *pfname, const char *vfname, int virNetDevGetVirtualFunctionIndex(const char *pfname, const char *vfname,
int *vf_index); int *vf_index)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_RETURN_CHECK;
int ifaceGetPhysicalFunction(const char *ifname, char **pfname); int virNetDevGetPhysicalFunction(const char *ifname, char **pfname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
#endif /* __VIR_INTERFACE_H__ */ #endif /* __VIR_INTERFACE_H__ */

View File

@ -630,13 +630,13 @@ virNetDevVPortProfileGetPhysfnDev(const char *linkdev,
{ {
int rc = -1; int rc = -1;
if (ifaceIsVirtualFunction(linkdev) == 1) { if (virNetDevIsVirtualFunction(linkdev) == 1) {
/* if linkdev is SR-IOV VF, then set vf = VF index */ /* if linkdev is SR-IOV VF, then set vf = VF index */
/* and set linkdev = PF device */ /* and set linkdev = PF device */
rc = ifaceGetPhysicalFunction(linkdev, physfndev); rc = virNetDevGetPhysicalFunction(linkdev, physfndev);
if (!rc) if (!rc)
rc = ifaceGetVirtualFunctionIndex(*physfndev, linkdev, vf); rc = virNetDevGetVirtualFunctionIndex(*physfndev, linkdev, vf);
} else { } else {
/* Not SR-IOV VF: physfndev is linkdev and VF index /* Not SR-IOV VF: physfndev is linkdev and VF index