[Libvir] Proposal: More script hooks for <interface type='ethernet'>

I have a few issues with <interface type='ethernet'>: - The requirement that either (1) the tap device already exists and has a constant name, or (2) the tap device can be created by the current user without privilege escalation doesn't work for places where the user wants to - dynamically generate tap devices - ...but is running kvm without privileges to do so. (this is particularly likely now that write privileges to /dev/net/tap are not enough, and the user needs CAP_NET_ADMIN to create a tap device). Allowing a target script to be specified (which is responsible for gaining any privileges necessary) which runs *before* the tap device is opened and would resolve this. - A qemu-ifup script can be specified, but not a qemu-ifdown replacement. Before looking to use libvirt, I had kvm's invocation wrapped by a script which did appropriate privilege escalation (ifname=$(sudo tunctl -b -u $USER), with sudo configured with the NOPASSWORD flag for this request -- though plenty of other approaches are certainly possible). It would be ideal if more hooks were available... for instance: <interface type='ethernet'> <!-- script gives device name on stdout --> <target script='/usr/local/bin/make-me-a-tap-device'/> <!-- preexisting argument and syntax for up scripts --> <script path='/etc/qemu-ifup-mynet'/> <!-- option to specify a down script, passed to qemu via 'downscript=' parameter--> <script-down path='/etc/qemu-ifdown-mynet'/> </interface> Working around this means that I would need to preallocate the tap devices and assign them to specific VMs (boo! hiss!) or that (if I wrapped libvirt's invocation to have the tap device created just ahead of time and its name substituted into interface/@dev) 3rd-party libvirt-based management tools couldn't be used (which would defeat the point of switching to libvirt from my homegrown script collection in the first place). So -- does the proposed syntax extension look reasonable?

On Sat, Feb 23, 2008 at 09:38:02PM -0600, Charles Duffy wrote:
I have a few issues with <interface type='ethernet'>: - The requirement that either (1) the tap device already exists and has a constant name, or (2) the tap device can be created by the current user without privilege escalation doesn't work for places where the user wants to - dynamically generate tap devices - ...but is running kvm without privileges to do so. (this is particularly likely now that write privileges to /dev/net/tap are not enough, and the user needs CAP_NET_ADMIN to create a tap device).
[snip]
So -- does the proposed syntax extension look reasonable?
Being able to specify an qemu-ifdown script is reasonable, since we already support an qemu-ifup script, but I don't want to just add that without a clearer understanding of exactly what type of network config you are trying to achieve. So rather than describing a desired implementation can you describe the deployment scenario / level of network connectivity you're trying to provide. Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

Daniel P. Berrange wrote:
Being able to specify an qemu-ifdown script is reasonable, since we already support an qemu-ifup script, but I don't want to just add that without a clearer understanding of exactly what type of network config you are trying to achieve. So rather than describing a desired implementation can you describe the deployment scenario / level of network connectivity you're trying to provide.
I want similar behavior to <interface type='ethernet'/> with no tap device precreated, in a scenario where CAP_NET_ADMIN (not just write access to /dev/net/tun) is necessary to create new tap devices and kvm isn't running as root. Is that an adequate description, or do I need to expand? I'm using my ifup script to select a bridge to connect to (and actually create that connection), and the ifdown script to clean up unused tap devices; these scripts use sudo where necessary. The problem, though, is that these scripts can't create the tap device themselves, so they can't use sudo for that. So -- just a bridge (or, rather, a selection of one of a few bridges), but with the tap devices dynamically created in a situation where privilege escalation is necessary for that device creation.
participants (3)
-
Charles Duffy
-
Charles Duffy
-
Daniel P. Berrange