On 10/24/2014 12:39 AM, Michal Privoznik wrote:
On 16.10.2014 19:29, Robert Li (baoli) wrote:
> Hi,
>
> I’m an openstack developer trying to use
>
>
> Assignment from a pool of SRIOV VFs in a libvirt <network>
> definition
>
>
> from this link
http://wiki.libvirt.org/page/Networking
>
> My question is is it possible for nova (the openstack compute) to know
> which VF out of the pool will be allocated to a VM before it invokes
> libvirt to launch it?
In general no. Even though currently libvirt chooses the first free
VF, this is not a part of API, and thus it's not written into a stone.
I wouldn't rely on it.
... especially since a different thread/process could come along during
the period between examining the free list and doing that allocation,
and grab the VF that you thought you were going to get.
If you just need to do some pre-processing on the VF that will be used,
perhaps a libvirt hook script could give you what you need. For libvirt
of versions 1.2.2 and higher, the following command is executed whenever
a VF is allocated to a guest from a libvirt network:
/etc/libvirt/hooks/network network_name plugged begin -
The script is sent (via stdin) the full status XML of the network,
domain, and allocated interface in the following form:
<hookData>
<network>
...
</network>
<domain>
...
</domain>
<interface>
...
</interface>
</hookData>
Your script called /etc/libvirt/hooks/network should be able to learn
the specific device name being used from the final <interface> section
(note that the <domain> section also contains one or more <interface>
sections, so don't just search for the first occurrence; do a full XML
parse instead (or at least search for the *last* <interface>).
When the guest is finished with the VF, the same script will be called
again:
/etc/libvirt/hooks/network network_name unplugged begin -
This is all documented at
http://www.libvirt.org/hooks.html
But the fact, you need this kind of information makes me wonder why.
What's your use case?
Same here - is there some commonly needed setup that libvirt isn't
providing? Perhaps this functionality needs to be added to libvirt...
(or possibly the functionality is already present and just not
adequately documented)