Comment 1 for bug 1742778

Revision history for this message
Ryan Harper (raharper) wrote : Re: replace usermode network with bridge due to unreliability of user-mode networking.

It turns out that we were constructing multiple qemu "vlans" which aren't actual 802.1q vlans but rather something akin to network hubs w.r.t to which devices see which packets.

A -netdev user,id=net00 and -device virtio-net-pci,netdev=net00 pairs a slirp/usernetwork backend with a virtio-net-pci device ,each one of those pairs runs it's own copy of slirp independent of each other. From qemu monitor the network setup looked like this:

info network
virtio-net-pci.0: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:00
 \ net00: index=0,type=user,net=10.0.2.0,restrict=off
virtio-net-pci.1: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:02
 \ net01: index=0,type=user,net=10.0.2.0,restrict=off
virtio-net-pci.2: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:04
 \ net02: index=0,type=user,net=10.0.2.0,restrict=off
virtio-net-pci.3: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:06
 \ net03: index=0,type=user,net=10.0.2.0,restrict=off
virtio-net-pci.4: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:08
 \ net04: index=0,type=user,net=10.0.2.0,restrict=off
virtio-net-pci.5: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:0a
 \ net05: index=0,type=user,net=10.0.2.0,restrict=off

This allowed the multi nic setup to DHCP on each nic and obtain the same IP address since the default user/slirp network config is the same (10.0.2.0/24, dhcpstart=10.0.2.15).

If we use -net user -net nic (legacy and depricated options) we can obtain a configuration with one slirp/user network services for a hub of devices but that means we lose some configuration ability in xkvm around use of -netdev and -device. Here is how we got the hub mode working though:

    -netdev hubport,id=hubport0,hubid=0 \
    -netdev hubport,id=hubport1,hubid=0 \
    -device virtio-net-pci,netdev=hubport0 \
    -device virtio-net-pci,netdev=hubport1 \

Produces a qemu network like this:

(qemu) info network
hub 0
 \ hub0port2: user.0: index=0,type=user,net=10.0.3.0,restrict=off
 \ hubport1: virtio-net-pci.1: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:57
 \ hubport0: virtio-net-pci.0: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:56