aboutsummaryrefslogtreecommitdiff
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/network
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/network')
-rw-r--r--src/network/bridge_driver.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index bf809bb31..eed13a057 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -59,6 +59,7 @@
#include "dnsmasq.h"
#include "configmake.h"
#include "virnetdev.h"
+#include "pci.h"
#include "virnetdevbridge.h"
#include "virnetdevtap.h"
#include "virnetdevvportprofile.h"
@@ -2780,10 +2781,11 @@ static int
networkCreateInterfacePool(virNetworkDefPtr netdef) {
unsigned int num_virt_fns = 0;
char **vfname = NULL;
+ struct pci_config_address **virt_fns;
int ret = -1, ii = 0;
if ((virNetDevGetVirtualFunctions(netdef->forwardPfs->dev,
- &vfname, &num_virt_fns)) < 0) {
+ &vfname, &virt_fns, &num_virt_fns)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not get Virtual functions on %s"),
netdef->forwardPfs->dev);
@@ -2805,18 +2807,34 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) {
netdef->nForwardIfs = num_virt_fns;
for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- netdef->forwardIfs[ii].device.dev = strdup(vfname[ii]);
- if (!netdef->forwardIfs[ii].device.dev) {
- virReportOOMError();
- goto finish;
+ if ((netdef->forwardType == VIR_NETWORK_FORWARD_BRIDGE) ||
+ (netdef->forwardType == VIR_NETWORK_FORWARD_PRIVATE) ||
+ (netdef->forwardType == VIR_NETWORK_FORWARD_VEPA) ||
+ (netdef->forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH)) {
+ netdef->forwardIfs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
+ if(vfname[ii]) {
+ netdef->forwardIfs[ii].device.dev = strdup(vfname[ii]);
+ if (!netdef->forwardIfs[ii].device.dev) {
+ virReportOOMError();
+ goto finish;
+ }
+ }
+ else {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Direct mode types requires interface names"));
+ goto finish;
+ }
}
}
ret = 0;
finish:
- for (ii = 0; ii < num_virt_fns; ii++)
+ for (ii = 0; ii < num_virt_fns; ii++) {
VIR_FREE(vfname[ii]);
+ VIR_FREE(virt_fns[ii]);
+ }
VIR_FREE(vfname);
+ VIR_FREE(virt_fns);
return ret;
}
@@ -3008,31 +3026,22 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
} else {
/* pick an interface from the pool */
+ if (netdef->nForwardPfs > 0 && netdef->nForwardIfs == 0 &&
+ networkCreateInterfacePool(netdef) < 0) {
+ goto error;
+ }
+
/* PASSTHROUGH mode, and PRIVATE Mode + 802.1Qbh both
* require exclusive access to a device, so current
* connections count must be 0. Other modes can share, so
* just search for the one with the lowest number of
* connections.
*/
- if (netdef->forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH) {
- if ((netdef->nForwardPfs > 0) && (netdef->nForwardIfs <= 0)) {
- if ((networkCreateInterfacePool(netdef)) < 0) {
- goto error;
- }
- }
-
- /* pick first dev with 0 connections */
-
- for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- if (netdef->forwardIfs[ii].connections == 0) {
- dev = &netdef->forwardIfs[ii];
- break;
- }
- }
- } else if ((netdef->forwardType == VIR_NETWORK_FORWARD_PRIVATE) &&
- iface->data.network.actual->virtPortProfile &&
- (iface->data.network.actual->virtPortProfile->virtPortType
- == VIR_NETDEV_VPORT_PROFILE_8021QBH)) {
+ if ((netdef->forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH) ||
+ ((netdef->forwardType == VIR_NETWORK_FORWARD_PRIVATE) &&
+ iface->data.network.actual->virtPortProfile &&
+ (iface->data.network.actual->virtPortProfile->virtPortType
+ == VIR_NETDEV_VPORT_PROFILE_8021QBH))) {
/* pick first dev with 0 connections */
for (ii = 0; ii < netdef->nForwardIfs; ii++) {