[libvirt] [PATCH] nodedev: update netdev feature bits before each dumpxml

Ján Tomko jtomko at redhat.com
Wed Jun 17 08:35:25 UTC 2015


On Tue, Jun 16, 2015 at 12:03:55PM -0400, Laine Stump wrote:
> As with several other attributes of devices (link status, sriov VF
> list, IOMMU group list), the detdev feature bits aren't automatically

s/det/net/

> updated in the nodedev driver's cache when they change. In order to
> get a properly up-to-date list when getting the XML of a device, we
> must reget them in update-caps prior to each dumpxml.
> 
> Reported-By: Moshe Levi <moshele at mellanox.com>
> ---
> 
> I dislike needing to put in the virBitmapFree and set the pointer to
> NULL before re-getting the features, but leaving it out would lead to
> a leak of the old bitmap, and I'm not sure I want
> virNetDevGetFeatures() to assume a valid pointer when it starts (it
> currently assumes the pointer contents is junk, and overwrites it with
> a newly allocated *virBitmap).
> 

Setting it to NULL is not strictly required, since the GetFeatures()
call will always overwrite it.

Maybe the code would be nicer if virBitmapFree also cleared the pointer
and virNetDevGetFeatures returned the bitmap instead of an int?

> 
>  src/node_device/node_device_driver.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
> index 768db7f..31741b9 100644
> --- a/src/node_device/node_device_driver.c
> +++ b/src/node_device/node_device_driver.c
> @@ -58,6 +58,10 @@ static int update_caps(virNodeDeviceObjPtr dev)
>          case VIR_NODE_DEV_CAP_NET:
>              if (virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.lnk) < 0)
>                  return -1;
> +            virBitmapFree(cap->data.net.features);
> +            cap->data.net.features = NULL;
> +            if (virNetDevGetFeatures(cap->data.net.ifname, &cap->data.net.features) < 0)
> +                return -1;
>              break;
>          case VIR_NODE_DEV_CAP_PCI_DEV:
>             if (nodeDeviceSysfsGetPCIRelatedDevCaps(dev->def->sysfs_path,

ACK with the typo fixed.

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150617/6845bb28/attachment-0001.sig>


More information about the libvir-list mailing list