[libvirt] [PATCH 3/3 RFC] macvtap: Fix getPhysfn to get the PF of a direct attach network interface

Roopa Prabhu roprabhu at cisco.com
Mon Aug 1 23:57:14 UTC 2011


From: Roopa Prabhu <roprabhu at cisco.com>

This patch adds code to the existing getPhysfn to get the PF device name
and VF index if the linkdev is a sriov VF.
The idea is to send the port profile message to a PF if the direct attach
interface is a VF. Eventually interface.c is probably the right place for
getPhysfn

Signed-off-by: Roopa Prabhu <roprabhu at cisco.com>
Signed-off-by: Christian Benvenuti <benve at cisco.com>
Signed-off-by: David Wang <dwang2 at cisco.com>
---
 src/util/macvtap.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)


diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 0b00776..7fcea0d 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -948,18 +948,15 @@ getPhysfn(const char *linkdev,
           char **physfndev)
 {
     int rc = 0;
-    bool virtfn = false;
 
-    if (virtfn) {
+    if (ifaceIsVF(linkdev)) {
 
-        /* XXX: if linkdev is SR-IOV VF, then set vf = VF index */
-        /* XXX: and set linkdev = PF device */
-        /* XXX: need to use get_physical_function_linux() or */
-        /* XXX: something like that to get PF */
-        /* XXX: device and figure out VF index */
-
-        rc = 1;
+        /* if linkdev is SR-IOV VF, then set vf = VF index */
+        /* and set physfndev = PF device */
 
+        rc = ifaceGetPFName(linkdev, physfndev);
+        if (!rc)
+            rc = ifaceGetVFIndex(*physfndev, linkdev, vf);
     } else {
 
         /* Not SR-IOV VF: physfndev is linkdev and VF index




More information about the libvir-list mailing list