[libvirt] Set MAC address for host virtual interface?

Daniel P. Berrange berrange at redhat.com
Thu Jan 14 12:10:51 UTC 2010


On Wed, Jan 13, 2010 at 08:25:47PM -0600, Neil Aggarwal wrote:
> Hello:
> 
> Is there a way to set the MAC address for the virtual
> interface on the host?
> 
> I have this in my guests's XML file:
>    <interface type='bridge'>
>      <mac address='54:52:00:7d:f8:fc'/>
>      <source bridge='br0'/>
>      <target dev='tkl-joomla'/>
>    </interface>
> 
> the mac address line controls the guest interface
> but the host interface seems to get a random MAC
> address.

At some time in the past we did set the MAC address on the host interface
too, but it caused networking problems in some configurations so we stopped
doing that.

> This is causing a problem for me since I use Cacti
> to monitor the bandwidth usage of the guest machines.
> Every time I stop and start a guest, Cacti creates a
> new interface and I have to reset the graphs to use
> the new interfaces.

I guess you have Cacti configured to pull stats directly from the TAP
devices on the host ?    Cacti has the ability to run scripts to pull
in statistics, so my recommendation would be to add a shell script which
calls the 'domifstat' command in virsh 

   virsh domifstat DOMNAME TAPDEVNAME

Or alternatively a python script which uses the libvirt python API to
get the ifstats from libvirt's API for that. That way you would not be
susceptible to changes in the TAP device setup on the host

There have already been plugins contributed to the Munin, Nagious and
CollectD projects todo exactly this, so it is natural that the same
be done for Cacti

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list