[libvirt] vnet<X>'s & interfaceStats().. KVM device numbering confusion?

Hi libirt-list, I am attempting to migrate from Xen->KVM and am having a little trouble understanding the new vnet<X> interface numbering scheme and how to use it to collect statistics of the interface using the interfaceStats() function. In Xen, the ID for a given domain was know, and a corresponding vif<ID>.0 interface was brought up so it was easy to grab the stats (amongst other things). Under my new KVM config I've realised that vnet<X> is brought up in a 'first free' fashion as opposed to a counter in the Xen case. This leaves me scratching my head a little bit, say I have a domain which has ended up with ID = 8, but may for instance have network 'vnet1' associated with it. I'm not sure how I can determine any association between the domain & which interface belongs to it! (e.g. a call to domain.interfaceStats() requires the correct network interface as a parameter). Surely I must be missing something here? Anyone have any advice/workaround for this situation? Ideally I would like to either be able to hardcode vnet-labels in the XML description (tried but it's ignored), or otherwise keep vnet numbering in sync with domain ID. Thanks in advance, Ravi

On Sat, Sep 12, 2009 at 02:57:28AM -0700, r-c@rocketmail.com wrote:
Under my new KVM config I've realised that vnet<X> is brought up in a 'first free' fashion as opposed to a counter in the Xen case. This leaves me scratching my head a little bit, say I have a domain which has ended up with ID = 8, but may for instance have network 'vnet1' associated with it. I'm not sure how I can determine any association between the domain & which interface belongs to it! (e.g. a call to domain.interfaceStats() requires the correct network interface as a parameter).
Surely I must be missing something here? Anyone have any advice/workaround for this situation? Ideally I would like to either be able to hardcode vnet-labels in the XML description (tried but it's ignored), or otherwise keep vnet numbering in sync with domain ID.
Ask libvirt for the XML config while the domain is running, you should see the interface there I think, try "virsh dumpxml 8" Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Under my new KVM config I've realised that vnet<X> is brought up in a 'first free' fashion as opposed to a counter in the Xen case. This leaves me scratching my head a little bit, say I have a domain which has ended up with ID = 8, but may for instance have network 'vnet1' associated with it. I'm not sure how I can determine any association between the domain & which interface belongs to it! (e.g. a call to domain.interfaceStats() requires the correct network interface as a parameter).
Surely I must be missing something here? Anyone have any advice/workaround for this situation? Ideally I would like to either be able to hardcode vnet-labels in the XML description (tried but it's ignored), or otherwise keep vnet numbering in sync with domain ID.
Ask libvirt for the XML config while the domain is running, you should see the interface there I think, try "virsh dumpxml 8"
Hi Daniel, thanks for your fast reply. Yes you're right I can do that and parse the XML (possibly not so elegant but I've tested it and it works! :-) But I have another question for you.. I would now like to apply iptables rules similar to Xen antispoofing (i.e. lock an IP to a vnet<X> interface). Can you recommend the best place to integrate this functionality? Are there some script hooks? I.e. if I try to add <interface>..<ip />..<script path='/some/script'/> </interface> to my domain definition would it pass the IP address & interface to the script (as what seems to happen with the Xen driver?) or am I approaching this the wrong way again? Thanks in advance, Ravi
participants (2)
-
Daniel Veillard
-
r-c@rocketmail.com