Robert Li (baoli)
2014-Oct-16 17:29 UTC
[libvirt-users] question about libvirt network Xml
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? Thanks In advance, Robert
Michal Privoznik
2014-Oct-24 04:39 UTC
Re: [libvirt-users] question about libvirt network Xml
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. But the fact, you need this kind of information makes me wonder why. What's your use case? Michal
Robert Li (baoli)
2014-Oct-24 14:16 UTC
Re: [libvirt-users] question about libvirt network Xml
Hi Michal, Thanks for the response. With openstack, neutron plugins need to know the device identification (in this case, the device¹s vendor id , product id, and slot information) in order to program the device, or probably the upstream switch in the case of 802.1qbr. I know that libvirt programs the sr-iov nic adaptor under the cover, but it doesn¹t seem to be able to cover all. So in the case of network XML, nova/neutron won¹t be able to do anything with the device since its id can¹t be obtained from libvirt. Robert On 10/24/14, 12:39 AM, "Michal Privoznik" <mprivozn@redhat.com> 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. But the fact, you need this kind of information >makes me wonder why. What's your use case? > >Michal
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)