Hello, everyone. I am using QEMU VM to test OVS-DPDK with virtio-networking. However, I also want a network device to connect to the Internet. So I try to use the bridge helper provided by QEMU. The QEMU version is:
I follow the instruction in [the video][https://www.youtube.com/watch?v=Q1PebvpQUvI] to create a bridge, and VM.
(1) Create a bridge
```
$ sudo ip link add br0 type bridge
```
(2) Bind a physical NIC to the bridge
```
$ sudo ip addr flush dev eno2
$ sudo ip link set eno2 master br0
$ brctl show
bridge name bridge id STP enabled interfaces
br0 8000.1866daf9a071 no eno2
```
(3) Set up `br0`
According to [the blog][https://unix.stackexchange.com/questions/248504/bridged-interfaces-do-not-have-internet-access], I think I need to set the IP address of the bridge `br0`. I left `eno2` unconfigured.
```
$ sudo ifconfig br0 10.0.0.21/8
$ ifconfig
br0 Link encap:Ethernet HWaddr 18:66:da:f9:a0:71
inet addr:10.0.0.21 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::1a66:daff:fef9:a071/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13028 errors:0 dropped:0 overruns:0 frame:0
TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:694896 (694.8 KB) TX bytes:2832 (2.8 KB)
eno1 Link encap:Ethernet HWaddr 18:66:da:f9:a0:70
inet addr:10.0.0.20 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::1a66:daff:fef9:a070/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:229486 errors:0 dropped:0 overruns:0 frame:0
TX packets:13100 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:17595899 (17.5 MB) TX bytes:1923061 (1.9 MB)
Interrupt:89
eno2 Link encap:Ethernet HWaddr 18:66:da:f9:a0:71
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:5016 errors:0 dropped:0 overruns:0 frame:0
TX packets:64 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:349069 (349.0 KB) TX bytes:5332 (5.3 KB)
Interrupt:90
```
**Note:** I have two physical NICs. One is `eno1`, for host network. The other is `eno2`, just for VM, which is not configured in `/etc/network/interfaces`.
(4) Create VM with bridge helper
Create VM
```
sudo qemu-system-x86_64 -enable-kvm -m 1024 -smp 2 -nographic \
-chardev socket,id=char0,path=/usr/local/var/run/openvswitch/vhost-user2 \
-netdev type=vhost-user,id=mynet1,chardev=char0,vhostforce \
-device virtio-net-pci,netdev=mynet1,mac=52:54:00:02:d9:02 \
-object memory-backend-file,id=mem,size=1024M,mem-path=/dev/hugepages,share=on \
-numa node,memdev=mem -mem-prealloc \
-net nic -net bridge,br=br0 \
$IMAGE_DIR/debian_squeeze_amd64_standard.qcow2
```
Here I use the image from [Debian][https://people.debian.org/~aurel32/qemu/amd64/]. I set up a `vhost-user` port, which is generated by OVS-DPDK. I guess this does not have an effect on the bridge.
The most important part is: `-net nic -net bridge,br=br0`.
(5) Enter the VM
After creating the VM, I found the bridge helper automatically created a tap interface in host:
```
bridge name bridge id STP enabled interfaces
br0 8000.1866daf9a071 no eno2
tap0
```
In VM, I found that the bridge port (`eth0`) and the vhost-user port (`eth2`):
```
eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56
inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:287 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:17220 (16.8 KiB) TX bytes:2520 (2.4 KiB)
eth2 Link encap:Ethernet HWaddr 52:54:00:02:d9:02
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 B) TX bytes:560 (560.0 B)
```
Then, the VM has no connection to neither the Internet or the host.
Thank you for sharing the idea.