Re: [libvirt] [PATCH v3 1/2] util: Add helper APIs to get/verify VF Representor name

2018-07-25 Thread Rana, JaiSingh
Thanks again John for giving detailed review and feedback for v3 patchset.
I have tried incorporating the suggestions in v4.

v4: https://www.redhat.com/archives/libvir-list/2018-June/msg01807.html


-Jai


From: John Ferlan 
Sent: 13 April 2018 00:38
To: Jai Singh Rana; libvir-list@redhat.com
Cc: Rana, JaiSingh
Subject: Re: [libvirt] [PATCH v3 1/2] util: Add helper APIs to get/verify VF 
Representor name



On 04/04/2018 12:29 PM, Jai Singh Rana wrote:
> Switchdev VF representor interface name on host is queried based on
> Bus:Device:Function information of pci SR-IOV device in Domain's
> 'hostdev' structure and subsequently verifying the required net sysfs
> directory and file entries of VF representor according to switchdev
> model.

You are missing the S-o-b:

The someone new policy is that:

Contributors to libvirt projects must assert that they are in compliance
with the Developer Certificate of Origin 1.1. This is achieved by adding
a "Signed-off-by" line containing the contributor's name and e-mail to
every commit message. The presence of this line attests that the
contributor has read the above lined DCO and agrees with its statements.

https://developercertificate.org/

> ---
> v3 includes changes based on v2's[1] feedback and suggestions. Fixes
> warnings reported by syntax-check.
> [1] https://www.redhat.com/archives/libvir-list/2018-February/msg00562.html
>
>  po/POTFILES.in  |   1 +
>  src/libvirt_private.syms|   7 +
>  src/util/Makefile.inc.am|   2 +
>  src/util/virhostdev.c   |   2 +-
>  src/util/virhostdev.h   |   8 +
>  src/util/virnetdevhostdev.c | 374 
> 
>  src/util/virnetdevhostdev.h |  35 +
>  7 files changed, 428 insertions(+), 1 deletion(-)
>  create mode 100644 src/util/virnetdevhostdev.c
>  create mode 100644 src/util/virnetdevhostdev.h
>

You probably don't have cppi installed, but if you did it would have
pointed out a few more syntax-check issues...

> diff --git a/po/POTFILES.in b/po/POTFILES.in
> index d84859a4e..8cd6b86e8 100644
> --- a/po/POTFILES.in
> +++ b/po/POTFILES.in
> @@ -234,6 +234,7 @@ src/util/virmdev.c
>  src/util/virnetdev.c
>  src/util/virnetdevbandwidth.c
>  src/util/virnetdevbridge.c
> +src/util/virnetdevhostdev.c
>  src/util/virnetdevip.c
>  src/util/virnetdevmacvlan.c
>  src/util/virnetdevmidonet.c
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index f6897915c..fad235206 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1923,6 +1923,7 @@ virHostCPUStatsAssign;
>  virHostdevFindUSBDevice;
>  virHostdevIsSCSIDevice;
>  virHostdevManagerGetDefault;
> +virHostdevNetDevice;
>  virHostdevPCINodeDeviceDetach;
>  virHostdevPCINodeDeviceReAttach;
>  virHostdevPCINodeDeviceReset;
> @@ -2306,6 +2307,12 @@ virNetDevBridgeSetSTPDelay;
>  virNetDevBridgeSetVlanFiltering;
>
>
> +# util/virnetdevhostdev.h
> +virNetdevHostdevCheckVFRIfName;
> +virNetdevHostdevGetVFRIfName;
> +virNetdevHostdevVFRIfStats;
> +
> +
>  # util/virnetdevip.h
>  virNetDevIPAddrAdd;
>  virNetDevIPAddrDel;
> diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
> index a3c3b711f..31fe11c68 100644
> --- a/src/util/Makefile.inc.am
> +++ b/src/util/Makefile.inc.am
> @@ -104,6 +104,8 @@ UTIL_SOURCES = \
>util/virnetdevbandwidth.h \
>util/virnetdevbridge.c \
>util/virnetdevbridge.h \
> + util/virnetdevhostdev.c \
> + util/virnetdevhostdev.h \
>util/virnetdevip.c \
>util/virnetdevip.h \
>util/virnetdevmacvlan.c \
> diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
> index a12224c58..4f7b46a04 100644
> --- a/src/util/virhostdev.c
> +++ b/src/util/virhostdev.c
> @@ -306,7 +306,7 @@ virHostdevIsVirtualFunction(virDomainHostdevDefPtr 
> hostdev)
>  }
>
>
> -static int
> +int
>  virHostdevNetDevice(virDomainHostdevDefPtr hostdev,
>  int pfNetDevIdx,
>  char **linkdev,
> diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h
> index 54e1c66be..735220add 100644
> --- a/src/util/virhostdev.h
> +++ b/src/util/virhostdev.h
> @@ -60,6 +60,14 @@ struct _virHostdevManager {
>  };
>
>  virHostdevManagerPtr virHostdevManagerGetDefault(void);
> +
> +int
> +virHostdevNetDevice(virDomainHostdevDefPtr hostdev,
> +int pfNetDevIdx,
> +char **linkdev,
> +int *vf)
> +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
> +
>  int
>  virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
>  const char *drv_name,
> diff --git 

Re: [libvirt] [PATCH v3 1/2] util: Add helper APIs to get/verify VF Representor name

2018-04-12 Thread John Ferlan


On 04/04/2018 12:29 PM, Jai Singh Rana wrote:
> Switchdev VF representor interface name on host is queried based on
> Bus:Device:Function information of pci SR-IOV device in Domain's
> 'hostdev' structure and subsequently verifying the required net sysfs
> directory and file entries of VF representor according to switchdev
> model.

You are missing the S-o-b:

The someone new policy is that:

Contributors to libvirt projects must assert that they are in compliance
with the Developer Certificate of Origin 1.1. This is achieved by adding
a "Signed-off-by" line containing the contributor's name and e-mail to
every commit message. The presence of this line attests that the
contributor has read the above lined DCO and agrees with its statements.

https://developercertificate.org/

> ---
> v3 includes changes based on v2's[1] feedback and suggestions. Fixes
> warnings reported by syntax-check.
> [1] https://www.redhat.com/archives/libvir-list/2018-February/msg00562.html
> 
>  po/POTFILES.in  |   1 +
>  src/libvirt_private.syms|   7 +
>  src/util/Makefile.inc.am|   2 +
>  src/util/virhostdev.c   |   2 +-
>  src/util/virhostdev.h   |   8 +
>  src/util/virnetdevhostdev.c | 374 
> 
>  src/util/virnetdevhostdev.h |  35 +
>  7 files changed, 428 insertions(+), 1 deletion(-)
>  create mode 100644 src/util/virnetdevhostdev.c
>  create mode 100644 src/util/virnetdevhostdev.h
> 

You probably don't have cppi installed, but if you did it would have
pointed out a few more syntax-check issues...

> diff --git a/po/POTFILES.in b/po/POTFILES.in
> index d84859a4e..8cd6b86e8 100644
> --- a/po/POTFILES.in
> +++ b/po/POTFILES.in
> @@ -234,6 +234,7 @@ src/util/virmdev.c
>  src/util/virnetdev.c
>  src/util/virnetdevbandwidth.c
>  src/util/virnetdevbridge.c
> +src/util/virnetdevhostdev.c
>  src/util/virnetdevip.c
>  src/util/virnetdevmacvlan.c
>  src/util/virnetdevmidonet.c
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index f6897915c..fad235206 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1923,6 +1923,7 @@ virHostCPUStatsAssign;
>  virHostdevFindUSBDevice;
>  virHostdevIsSCSIDevice;
>  virHostdevManagerGetDefault;
> +virHostdevNetDevice;
>  virHostdevPCINodeDeviceDetach;
>  virHostdevPCINodeDeviceReAttach;
>  virHostdevPCINodeDeviceReset;
> @@ -2306,6 +2307,12 @@ virNetDevBridgeSetSTPDelay;
>  virNetDevBridgeSetVlanFiltering;
>  
>  
> +# util/virnetdevhostdev.h
> +virNetdevHostdevCheckVFRIfName;
> +virNetdevHostdevGetVFRIfName;
> +virNetdevHostdevVFRIfStats;
> +
> +
>  # util/virnetdevip.h
>  virNetDevIPAddrAdd;
>  virNetDevIPAddrDel;
> diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
> index a3c3b711f..31fe11c68 100644
> --- a/src/util/Makefile.inc.am
> +++ b/src/util/Makefile.inc.am
> @@ -104,6 +104,8 @@ UTIL_SOURCES = \
>   util/virnetdevbandwidth.h \
>   util/virnetdevbridge.c \
>   util/virnetdevbridge.h \
> + util/virnetdevhostdev.c \
> + util/virnetdevhostdev.h \
>   util/virnetdevip.c \
>   util/virnetdevip.h \
>   util/virnetdevmacvlan.c \
> diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
> index a12224c58..4f7b46a04 100644
> --- a/src/util/virhostdev.c
> +++ b/src/util/virhostdev.c
> @@ -306,7 +306,7 @@ virHostdevIsVirtualFunction(virDomainHostdevDefPtr 
> hostdev)
>  }
>  
>  
> -static int
> +int
>  virHostdevNetDevice(virDomainHostdevDefPtr hostdev,
>  int pfNetDevIdx,
>  char **linkdev,
> diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h
> index 54e1c66be..735220add 100644
> --- a/src/util/virhostdev.h
> +++ b/src/util/virhostdev.h
> @@ -60,6 +60,14 @@ struct _virHostdevManager {
>  };
>  
>  virHostdevManagerPtr virHostdevManagerGetDefault(void);
> +
> +int
> +virHostdevNetDevice(virDomainHostdevDefPtr hostdev,
> +int pfNetDevIdx,
> +char **linkdev,
> +int *vf)
> +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
> +
>  int
>  virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
>  const char *drv_name,
> diff --git a/src/util/virnetdevhostdev.c b/src/util/virnetdevhostdev.c
> new file mode 100644
> index 0..19f95bfdd
> --- /dev/null
> +++ b/src/util/virnetdevhostdev.c
> @@ -0,0 +1,374 @@
> +/*
> + * virnetdevhostdev.c: utilities to get/verify Switchdev VF Representor
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General 

[libvirt] [PATCH v3 1/2] util: Add helper APIs to get/verify VF Representor name

2018-04-04 Thread Jai Singh Rana
Switchdev VF representor interface name on host is queried based on
Bus:Device:Function information of pci SR-IOV device in Domain's
'hostdev' structure and subsequently verifying the required net sysfs
directory and file entries of VF representor according to switchdev
model.
---
v3 includes changes based on v2's[1] feedback and suggestions. Fixes
warnings reported by syntax-check.
[1] https://www.redhat.com/archives/libvir-list/2018-February/msg00562.html

 po/POTFILES.in  |   1 +
 src/libvirt_private.syms|   7 +
 src/util/Makefile.inc.am|   2 +
 src/util/virhostdev.c   |   2 +-
 src/util/virhostdev.h   |   8 +
 src/util/virnetdevhostdev.c | 374 
 src/util/virnetdevhostdev.h |  35 +
 7 files changed, 428 insertions(+), 1 deletion(-)
 create mode 100644 src/util/virnetdevhostdev.c
 create mode 100644 src/util/virnetdevhostdev.h

diff --git a/po/POTFILES.in b/po/POTFILES.in
index d84859a4e..8cd6b86e8 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -234,6 +234,7 @@ src/util/virmdev.c
 src/util/virnetdev.c
 src/util/virnetdevbandwidth.c
 src/util/virnetdevbridge.c
+src/util/virnetdevhostdev.c
 src/util/virnetdevip.c
 src/util/virnetdevmacvlan.c
 src/util/virnetdevmidonet.c
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f6897915c..fad235206 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1923,6 +1923,7 @@ virHostCPUStatsAssign;
 virHostdevFindUSBDevice;
 virHostdevIsSCSIDevice;
 virHostdevManagerGetDefault;
+virHostdevNetDevice;
 virHostdevPCINodeDeviceDetach;
 virHostdevPCINodeDeviceReAttach;
 virHostdevPCINodeDeviceReset;
@@ -2306,6 +2307,12 @@ virNetDevBridgeSetSTPDelay;
 virNetDevBridgeSetVlanFiltering;
 
 
+# util/virnetdevhostdev.h
+virNetdevHostdevCheckVFRIfName;
+virNetdevHostdevGetVFRIfName;
+virNetdevHostdevVFRIfStats;
+
+
 # util/virnetdevip.h
 virNetDevIPAddrAdd;
 virNetDevIPAddrDel;
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index a3c3b711f..31fe11c68 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -104,6 +104,8 @@ UTIL_SOURCES = \
util/virnetdevbandwidth.h \
util/virnetdevbridge.c \
util/virnetdevbridge.h \
+   util/virnetdevhostdev.c \
+   util/virnetdevhostdev.h \
util/virnetdevip.c \
util/virnetdevip.h \
util/virnetdevmacvlan.c \
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index a12224c58..4f7b46a04 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -306,7 +306,7 @@ virHostdevIsVirtualFunction(virDomainHostdevDefPtr hostdev)
 }
 
 
-static int
+int
 virHostdevNetDevice(virDomainHostdevDefPtr hostdev,
 int pfNetDevIdx,
 char **linkdev,
diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h
index 54e1c66be..735220add 100644
--- a/src/util/virhostdev.h
+++ b/src/util/virhostdev.h
@@ -60,6 +60,14 @@ struct _virHostdevManager {
 };
 
 virHostdevManagerPtr virHostdevManagerGetDefault(void);
+
+int
+virHostdevNetDevice(virDomainHostdevDefPtr hostdev,
+int pfNetDevIdx,
+char **linkdev,
+int *vf)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
+
 int
 virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
 const char *drv_name,
diff --git a/src/util/virnetdevhostdev.c b/src/util/virnetdevhostdev.c
new file mode 100644
index 0..19f95bfdd
--- /dev/null
+++ b/src/util/virnetdevhostdev.c
@@ -0,0 +1,374 @@
+/*
+ * virnetdevhostdev.c: utilities to get/verify Switchdev VF Representor
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * .
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "virhostdev.h"
+#include "virnetdev.h"
+#include "virnetdevhostdev.h"
+#include "viralloc.h"
+#include "virstring.h"
+#include "virfile.h"
+#include "virerror.h"
+#include "virlog.h"
+#include "c-ctype.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+VIR_LOG_INIT("util.netdevhostdev");
+
+#ifndef IFNAMSIZ
+#define IFNAMSIZ 16
+#endif
+
+#define IFSWITCHIDSIZ 20
+
+#ifdef __linux__
+/**
+ * virNetdevHostdevNetSysfsPath
+ *
+ * @pf_name: netdev name of the physical function (PF)
+ * @vf: virtual function (VF) number for the device of interest
+ * @vf_ifname: name of the VF