[libvirt-users] virConnectListAllNodeDevices requires number of devices to be known

Laine Stump laine at laine.org
Thu Mar 26 22:38:29 UTC 2015


On 03/26/2015 04:05 PM, Neel Basu wrote:
> Hi,
> virConnectListAllNodeDevices() takes a virNodeDevicePtr **devices. So
> I need to create an array of virNodeDevicePtr. For that I need to know
> size / Number of devices. What is the function for that ?

No, that is incorrect.

http://www.libvirt.org/html/libvirt-libvirt-nodedev.html#virConnectListAllNodeDevices

virConnectListAllNodeDevices() 1) allocates the memory for you (you must
later free it with iterated calls to virNodeDeviceFree()), and 2) the
return value of the API is the number of node devices that were found
(i.e. how many elements are in the array), or -1 if there was an error.




More information about the libvirt-users mailing list