Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #222494 > unrolled thread

Passing multiple ethernet adapters to QEMU guest

Started byAndrew Wood <andrewjameswood@ymail.com>
First post2020-05-14 16:20 +0200
Last post2020-05-14 22:30 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.debian.user

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Passing multiple ethernet adapters to QEMU guest Andrew Wood <andrewjameswood@ymail.com> - 2020-05-14 16:20 +0200
    Re: Passing multiple ethernet adapters to QEMU guest Reco <recoverym4n@enotuniq.net> - 2020-05-14 17:00 +0200
      Re: Passing multiple ethernet adapters to QEMU guest Andrew Wood <andrewjameswood@ymail.com> - 2020-05-14 22:10 +0200
        Re: Passing multiple ethernet adapters to QEMU guest Reco <recoverym4n@enotuniq.net> - 2020-05-14 22:30 +0200

#222494 — Passing multiple ethernet adapters to QEMU guest

FromAndrew Wood <andrewjameswood@ymail.com>
Date2020-05-14 16:20 +0200
SubjectPassing multiple ethernet adapters to QEMU guest
Message-ID<A6mSl-5nd-3@gated-at.bofh.it>
How do I pass more than one ethernet adapter to a QEMU guest.

Doing it like this seems to attach them both on virtual bridge br1

kvm ....  -net nic,macaddr=52:54:00:00:01:08,model=rtl8139 -net 
tap,ifname=br1p5 \
-net nic,macaddr=52:54:00:00:02:08,model=rtl8139 -net tap,ifname=br3p8

Thanks

Andrew

[toc] | [next] | [standalone]


#222495

FromReco <recoverym4n@enotuniq.net>
Date2020-05-14 17:00 +0200
Message-ID<A6nv4-5zG-15@gated-at.bofh.it>
In reply to#222494
	Hi.

On Thu, May 14, 2020 at 03:13:50PM +0100, Andrew Wood wrote:
> How do I pass more than one ethernet adapter to a QEMU guest.
> 
> Doing it like this seems to attach them both on virtual bridge br1
> 
> kvm ....  -net nic,macaddr=52:54:00:00:01:08,model=rtl8139 -net tap,ifname=br1p5 \
> -net nic,macaddr=52:54:00:00:02:08,model=rtl8139 -net tap,ifname=br3p8

Qemu uses /etc/qemu-ifup by default which deliberately puts tap
interface to the bridge which corresponds to the default route.

To override this you have to:

1) Write your own replacement for /etc/qemu-ifup, two in this case.
2) Pass it to qemu with the "script" option:

kvm ....  -net nic,macaddr=52:54:00:00:01:08,model=rtl8139 \
	-net tap,ifname=br1p5,script=/etc/my-qemu-bridge1 \
-net nic,macaddr=52:54:00:00:02:08,model=rtl8139 \
	-net tap,ifname=br3p8,scrupt=/etc/my-qemu-bridge2

Reco

[toc] | [prev] | [next] | [standalone]


#222510

FromAndrew Wood <andrewjameswood@ymail.com>
Date2020-05-14 22:10 +0200
Message-ID<A6sl3-GL-7@gated-at.bofh.it>
In reply to#222495
On 14/05/2020 15:50, Reco wrote:
> 	
> Qemu uses /etc/qemu-ifup by default which deliberately puts tap
> interface to the bridge which corresponds to the default route.
>
>
Im sorry I dont understand where the default route comes into it as none 
of the interfaces, virtual, bridge or the corresponding real hardware 
interface have any layer 3 addressing assigned, they are purely working 
at L2.

Ive got many VMs working with 1 virtual interface. Some on br1 some on 
br2 some on br3, its only when I try to put a VM on more than one I get 
a problem

The bridges are setup like this

#br1 on enp8s0f1 which has no IP address assigned
/sbin/brctl addbr br1
/sbin/brctl addif br1 enp8s0f1

/usr/bin/tunctl -u root -t br1p0
/sbin/brctl addif br1 br1p0

/usr/bin/tunctl -u root -t br1p1
/sbin/brctl addif br1 br1p1
.
.
.

/sbin/ip link set enp8s0f1 up
/sbin/ip link set br1 up

#br2 on ens7f0 which has no IP address assigned
/sbin/brctl addbr br2
/sbin/brctl addif br2 ens7f0

/usr/bin/tunctl -u root -t br2p0
/sbin/brctl addif br2 br2p0

/usr/bin/tunctl -u root -t br2p1
/sbin/brctl addif br2 br2p1
.
.
.

/sbin/ip link set ens7f0 up
/sbin/ip link set br2 up

[toc] | [prev] | [next] | [standalone]


#222513

FromReco <recoverym4n@enotuniq.net>
Date2020-05-14 22:30 +0200
Message-ID<A6sEq-MR-13@gated-at.bofh.it>
In reply to#222510
On Thu, May 14, 2020 at 09:03:50PM +0100, Andrew Wood wrote:
> On 14/05/2020 15:50, Reco wrote:
> > 	
> > Qemu uses /etc/qemu-ifup by default which deliberately puts tap
> > interface to the bridge which corresponds to the default route.
> > 
> Im sorry I dont understand where the default route comes into it as
> none of the interfaces, virtual, bridge or the corresponding real
> hardware interface have any layer 3 addressing assigned, they are
> purely working at L2.

Quoting /etc/qemu-ifup,

# only add the interface to default-route bridge if we
# have such interface (with default route) and if that
# interface is actually a bridge.
# It is possible to have several default routes too
for br in $switch; do  
    if [ -d /sys/class/net/$br/bridge/. ]; then
        if [ -n "$ip" ]; then
          ip link set "$1" master "$br"
        else
          brctl addif $br "$1"
        fi
        exit    # exit with status of the previous command
    fi
done

Where $ip is defined as "$(which ip)", and $switch correspond to the
interface with the default route set.

Reco

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web