Neel Basu
2015-Mar-26 20:05 UTC
[libvirt-users] virConnectListAllNodeDevices requires number of devices to be known
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 ? Thank You.
Laine Stump
2015-Mar-26 22:38 UTC
Re: [libvirt-users] virConnectListAllNodeDevices requires number of devices to be known
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.