[libvirt] how to know if PCI device has SR-IOV PF capability

Laine Stump laine at laine.org
Mon Nov 23 16:26:11 UTC 2015


On 11/23/2015 10:40 AM, Daniel P. Berrange wrote:
> On Mon, Nov 23, 2015 at 10:34:43AM -0500, Laine Stump wrote:
>
>> If we're going to switch to emiting virt_functions whenever a device has the
>> potential to provide VFs, we may as well make it worthwhile and also emit
>> the maximum possible VFs for the device, maybe simply:
>>
>>      <capability type='virt_functions' maxCount='7'>
>>
>> (the current count is implicit in the number of entries in the list that
>> follows. I don't have an opinion on whether it is better to also include
>> explicitly with, e.g. "count='7'", or just leave it implicit).
> Is there any way for us to actually discover the max count ? If so, then
> it seems nice to include it.

Yes. I don't know if it existed back when that code was originally 
added, but at least RHEL6.7 (the oldest OS I have running on a machine 
with an SRIOV-capable card) and later have two files in the device's 
sysfs, sriov_numvfs and sriov_totalvfs. The former is the number that 
are currently active, and the latter is the maximum possible for this PF.

(On a related topic - you can change the number of currently active VFs 
by writing "0" to sriov_numvfs then writing the desired number to it; 
this does temporarily delete any VFs that are already active though, so 
it can only be done if none are in use. I've planned to hook libvirt 
networks up to this so that VFs can be enabled completely within libvirt 
(since the driver commandline method isn't consistent between different 
vendors, and I believe is now considered to be deprecated). Since 
Openstack doesn't use libvirt networks but may want similar 
functionality, I'm wondering where would be a good place to do that. We 
could provide something via the node-device API, but that couldn't be 
automatically done by libvirtd at startup; alternately Openstack could 
create a network but not use it, but that just seems conceptually 
confusing even though it would work.)





More information about the libvir-list mailing list