aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorShradha Shah <sshah@solarflare.com>2012-08-16 16:41:58 +0100
committerLaine Stump <laine@laine.org>2012-08-17 15:43:26 -0400
commit2b51a63bab94ea0ce51c70dcc5e8a22dbf117e89 (patch)
tree75e8b5c6f0b29e9f1d1dd8c95d43a6de110afb84 /src/util
parentconf: parser/formatter/rng for <forward mode='hostdev'> (diff)
downloadlibvirt-2b51a63bab94ea0ce51c70dcc5e8a22dbf117e89.tar.gz
libvirt-2b51a63bab94ea0ce51c70dcc5e8a22dbf117e89.tar.bz2
libvirt-2b51a63bab94ea0ce51c70dcc5e8a22dbf117e89.zip
network: return netdev name or pci addr of the VF in actualDevice
The network pool should be able to keep track of both network device names and PCI addresses, and return the appropriate one in the actualDevice when networkAllocateActualDevice is called. Signed-off-by: Shradha Shah <sshah@solarflare.com>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/virnetdev.c25
-rw-r--r--src/util/virnetdev.h4
2 files changed, 15 insertions, 14 deletions
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 25bdf01e8..f9eba1afb 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -29,6 +29,7 @@
#include "command.h"
#include "memory.h"
#include "pci.h"
+#include "logging.h"
#include <sys/ioctl.h>
#ifdef HAVE_NET_IF_H
@@ -981,18 +982,18 @@ virNetDevSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname,
int
virNetDevGetVirtualFunctions(const char *pfname,
char ***vfname,
+ struct pci_config_address ***virt_fns,
unsigned int *n_vfname)
{
int ret = -1, i;
char *pf_sysfs_device_link = NULL;
char *pci_sysfs_device_link = NULL;
- struct pci_config_address **virt_fns;
char *pciConfigAddr;
if (virNetDevSysfsFile(&pf_sysfs_device_link, pfname, "device") < 0)
return ret;
- if (pciGetVirtualFunctions(pf_sysfs_device_link, &virt_fns,
+ if (pciGetVirtualFunctions(pf_sysfs_device_link, virt_fns,
n_vfname) < 0)
goto cleanup;
@@ -1003,10 +1004,10 @@ virNetDevGetVirtualFunctions(const char *pfname,
for (i = 0; i < *n_vfname; i++)
{
- if (pciGetDeviceAddrString(virt_fns[i]->domain,
- virt_fns[i]->bus,
- virt_fns[i]->slot,
- virt_fns[i]->function,
+ if (pciGetDeviceAddrString((*virt_fns)[i]->domain,
+ (*virt_fns)[i]->bus,
+ (*virt_fns)[i]->slot,
+ (*virt_fns)[i]->function,
&pciConfigAddr) < 0) {
virReportSystemError(ENOSYS, "%s",
_("Failed to get PCI Config Address String"));
@@ -1019,20 +1020,17 @@ virNetDevGetVirtualFunctions(const char *pfname,
}
if (pciDeviceNetName(pci_sysfs_device_link, &((*vfname)[i])) < 0) {
- virReportSystemError(ENOSYS, "%s",
- _("Failed to get interface name of the VF"));
- goto cleanup;
+ VIR_INFO("VF does not have an interface name");
}
}
ret = 0;
cleanup:
- if (ret < 0)
+ if (ret < 0) {
VIR_FREE(*vfname);
- for (i = 0; i < *n_vfname; i++)
- VIR_FREE(virt_fns[i]);
- VIR_FREE(virt_fns);
+ VIR_FREE(*virt_fns);
+ }
VIR_FREE(pf_sysfs_device_link);
VIR_FREE(pci_sysfs_device_link);
VIR_FREE(pciConfigAddr);
@@ -1169,6 +1167,7 @@ cleanup:
int
virNetDevGetVirtualFunctions(const char *pfname ATTRIBUTE_UNUSED,
char ***vfname ATTRIBUTE_UNUSED,
+ struct pci_config_address ***virt_fns ATTRIBUTE_UNUSED,
unsigned int *n_vfname ATTRIBUTE_UNUSED)
{
virReportSystemError(ENOSYS, "%s",
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index c663e49a8..705ad9c49 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -26,6 +26,7 @@
# include "virsocketaddr.h"
# include "virnetlink.h"
# include "virmacaddr.h"
+# include "pci.h"
int virNetDevExists(const char *brname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
@@ -103,9 +104,10 @@ int virNetDevGetPhysicalFunction(const char *ifname, char **pfname)
int virNetDevGetVirtualFunctions(const char *pfname,
char ***vfname,
+ struct pci_config_address ***virt_fns,
unsigned int *n_vfname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
- ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
int virNetDevLinkDump(const char *ifname, int ifindex,
struct nlattr **tb,