<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, 15 Nov 2018 at 12:23, Michal Privoznik <<a href="mailto:mprivozn@redhat.com" target="_blank">mprivozn@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 11/10/2018 01:56 PM, Radoslaw Biernacki wrote:<br>
> libvirt wrongly assumes that VF netdev has to have the<br>
> netdev assigned to PF. There is no such requirement in SRIOV standard.<br>
> This patch change the virNetDevSwitchdevFeature() function to deal<br>
> with SRIOV devices which does not have netdev on PF. Also removes<br>
> one comment about PF netdev assumption.<br>
> <br>
> One example of such devices is ThunderX VNIC.<br>
> By applying this change, VF device is used for virNetlinkCommand() as<br>
> it is the only netdev assigned to VNIC.<br>
> <br>
> Signed-off-by: Radoslaw Biernacki <<a href="mailto:radoslaw.biernacki@linaro.org" target="_blank">radoslaw.biernacki@linaro.org</a>><br>
> ---<br>
>  src/util/virnetdev.c | 10 +++++-----<br>
>  1 file changed, 5 insertions(+), 5 deletions(-)<br>
> <br>
> diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c<br>
> index 5867977df4..e55c538a29 100644<br>
> --- a/src/util/virnetdev.c<br>
> +++ b/src/util/virnetdev.c<br>
> @@ -1359,9 +1359,6 @@ virNetDevGetPhysicalFunction(const char *ifname, char **pfname)<br>
>      }<br>
>  <br>
>      if (!*pfname) {<br>
> -        /* this shouldn't be possible. A VF can't exist unless its<br>
> -         * PF device is bound to a network driver<br>
> -         */<br>
>          virReportError(VIR_ERR_INTERNAL_ERROR,<br>
>                         _("The PF device for VF %s has no network device name"),<br>
>                         ifname);<br>
> @@ -3182,8 +3179,11 @@ virNetDevSwitchdevFeature(const char *ifname,<br>
>      if ((is_vf = virNetDevIsVirtualFunction(ifname)) < 0)<br>
>          return ret;<br>
>  <br>
> -    if (is_vf == 1 && virNetDevGetPhysicalFunction(ifname, &pfname) < 0)<br>
> -        goto cleanup;<br>
> +    if (is_vf == 1) {<br>
> +        /* ignore error if PF does noto have netdev assigned<br>
> +         * in that case pfname == NULL */<br>
> +        ignore_value(virNetDevGetPhysicalFunction(ifname, &pfname));<br>
<br>
Problem is that virNetDevGetPhysicalFunction() reports error on failure.<br>
So either you need to take that out and put it into the other place that<br>
calls the function (virNetDevReadNetConfig) or call virResetLastError().<br></blockquote><div><br></div><div>Moved error reporting out of  virNetDevGetPhysicalFunction().</div><div>Fortunately with 2/4 patch, only virNetDevGetVirtualFunctionInfo() calls it.</div><div>Fixed in v2.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> +    }<br>
>  <br>
>      pci_device_ptr = pfname ? virNetDevGetPCIDevice(pfname) :<br>
>                                virNetDevGetPCIDevice(ifname);<br>
> <br>
<br>
Michal<br>
</blockquote></div></div></div></div></div>