[libvirt] Providing custom arguments/environment to network scripts

Tore Anderson tore.anderson at redpill-linpro.com
Wed May 23 13:49:00 UTC 2012


I'm trying to build a setup where the VMs only have point-to-point
Ethernet connections to the hypervisor, which will then act as a layer-3
router. When the VM starts, the hypervisor needs to UP the assigned tap
interface and configure an IP/mask on it (that will be the VMs default
gateway). So I'm currently looking at a config looking like this:

<interface type='ethernet'>
  <script path='/sbin/vm-ifup'/>
</interface>

The problem I'm facing is that there appears to be no way supply
information to the script by way of command-line arguments or custom
environment variables. So something like:

<script path='/sbin/vm-ifup 2001:db8::/64'/>

...fails because it tries to execute the whole string, space included,
as the script file.

The only information I have available in the script is the assigned tap
device in the hypervisor (which is automatically passed in as the first
argument to the script). As the device name is automatically assigned on
VM start, it is useless as a lookup key of sorts for finding more
information. One workaround would be to have one network script per VM
that hard-codes all the necessary information, but if you have a large
number of hypervisors with an even larger number of VMs, this quickly
becomes impractical.

So my question is, is there some other way to pass configuration
information to the network script or to accomplish what I'm trying to do?

Best regards,
-- 
Tore Anderson
Redpill Linpro AS - http://www.redpill-linpro.com




More information about the libvir-list mailing list