Qemu: Assigning two tap devices to one virtual machine

Jedrzej Kalinowski kalinoj1 at iem.pw.edu.pl
Mon Jun 1 18:21:20 UTC 2009


Juergen Lock pisze:
> In article <20090523223024.GA93488 at volt.iem.pw.edu.pl> you write:
>> Hello all,
>>
>> I'm running qemu 0.10.5 on CURRENT machine and experienced an
>> interesting problem.
>>
>> I try to run a single qemu machine with two network interfaces (tap's)
>> connected to the same bridge - I need this for playing with m0n0wall for
>> example.
>>
>> The qemu launch looks similiar to this:
>>
>> qemu -net nic -net tap -net nic -net tap -cdrom cdrom.iso -curses
>>
>> What happens is that when qemu starts up - my machine locks (sometimes I
>> manage to kill qemu and recover it, sometimes not). I see that it's a
>> problem with network bridge - looks like the infitine loop of arp
>> requests that get replicated infinitely (it also kills/floods my real network
>> that is connected through the bridge to the tap devices).
>>
>> My question is - have any of You tried to use multiple tap devices within
>> one qemu machine? Can you replicate this problem in your environments?
>>
>> One note: there is no problem if I run two qemus and each of them has a
>> tap device connected to bridge0. They coexist and I have no network
>> issues in both guests. I can post qemu-if{up,down} scripts if needed.
> 
> Ok just in case this hasn't been resolved yet...
> 
>  Try something like
> 	qemu -net nic -net tap -net nic,vlan=1,macaddr=52:54:00:12:34:57 -net tap,vlan=1 -cdrom cdrom.iso -curses
> 
> and if you want you can also add `,model=e1000' to the -net nic parameters,
> that one (em(4) on FreeBSD) should perform a little better than the default
> ne2kpci (ed(4) on FreeBSD.)
> 
>  Explanation: vlan= is used to associate -net nic with -net tap/user/pcap
> connections (default is vlan=0), and macaddr= you need because qemu uses
> one single default macaddress (52:54:00:12:34:56 atm) for all -net nic
> and you can't have two nics with identical macs on the same network.
> 

Yes, I tried it and I can confirm that it works well - assigning
different vlans to different nics saves the day here.

Also, good news is that qemu already doesn't create same MAC-addresses
for nics blindly. I run it like this:

qemu -net nic,model=e1000,vlan=0 -net user,vlan=0 -net
nic,model=e1000,vlan=1 -net user,vlan=1


And get:

(qemu) info network

  VLAN 0 devices:

    user.0:

    e1000.0: model=e1000,macaddr=52:54:00:12:34:56

  VLAN 1 devices:

    user.1:

    e1000.1: model=e1000,macaddr=52:54:00:12:34:57




>  Good luck, :)
> 	Juergen
> 

Thank you for your help, Juergen (and thanks for maintainig the port the
way it is always up to date with the latest release!)
Jędrzej Kalinowski


More information about the freebsd-emulation mailing list