blob: 4410d27e4cd6dabc80a168e35f004ed3550c606b [file] [log] [blame]
Patrick Williamsd849ec72016-08-17 14:59:38 -05001Simple setup for connecting openvswitch to qemu/kvm
2===================================================
3This example brings up openvswitch using a private network.
4
5Preliminary notes
6=================
71. Make sure to build kernel support for openvswitch as a module. The
8openvswitch init scripts expect to load a module and upon success
9continue to setup the switch. If openvswitch is compiled
10statically, the init scripts not load the ovs-vswitchd daemon
11and none of the configured bridges will show up in the interfaces
12table (ifconfig). You can get around this limiation by running the
13following by hand:
14 # ovs-vswitchd --pidfile --detach
15
162. Verify that ovs-vswitchd is running before proceeding:
17 # /etc/init.d/openvswitch-switch status
18 ovsdb-server is running with pid 1867
19 ovs-vswitchd is running with pid 1877
20
213. A kernel and rootfs is required for qemu bring up.
22
23Qemu Setup
24==========
25The host requires a /etc/qemu-ifup script to setup the bridging and tap
26devices. Qemu will invoke this qemu-ifup script at startup. Here is
27an example script:
28$ cat /etc/qemu-fup
29 #!/bin/sh
30 # the tap is dynamically assigned and passed into this script
31 # as a parameter
32 TAP=$1
33
34 # Note: if booting over NFS, once the $ETH0 device is added to the bridge,
35 # your host will be unusable. In that case, setup networking
36 # init scripts appropriately and change the following to work
37 # with it.
38 ETH0="eth1"
39 NETMASK=255.255.255.0
40 IP=192.168.1.1
41 GATEWAY=
42 SWITCH=ovsbr0
43 if [ -n "$TAP" ];then
44 ifconfig $TAP up
45 ifconfig $SWITCH down &>/dev/null
46 ovs-vsctl del-br $SWITCH
47 ovs-vsctl add-br $SWITCH
48 ifconfig $ETH0 0.0.0.0
49 ifconfig $SWITCH $IP up netmask $NETMASK
50 #-- external access not required for this test.
51 #route add default gw $GATEWAY
52 ovs-vsctl add-port $SWITCH $ETH0
53 ovs-vsctl add-port $SWITCH $TAP
54 exit 0
55 else
56 echo "$0: No tap device"
57 exit 1
58 fi
59
60Start Qemu
61==========
62This example will bring up qemu with a tap network interface.
63Note: this command must be run as root due to the networking setup.
64
65 $ qemu-system-x86_64 -nographic -k en-us -m 1024 \
66 -net nic,macaddr=1a:46:0b:ca:bc:7a,model=virtio \
67 -net tap -enable-kvm\
68 -kernel /opt/dpdk-guest-kernel \
69 -append 'root=/dev/vda ro console=ttyS0' \
70 -drive file=/opt/intel-xeon-core-ovp-kvm-preempt-rt-dist.ext3,cache=none,if=virtio
71
72Once the guest OS is up and running, configure the quest network interface:
73 $ ifconfig eth0 192.168.1.10
74
75Ping the bridge:
76 $ ping 192.168.1.1
77
78From the host, view the bridged network:
79$ ovs-vsctl show
80c1212b96-ef49-4a8e-b598-09b05b854dd0
81 Bridge "ovsbr0"
82 Port "tap0"
83 Interface "tap0"
84 Port "eth1"
85 Interface "eth1"
86 Port "ovsbr0"
87 Interface "ovsbr0"
88 type: internal
89
90At this point, openvswitch is up and running. If you want external
91network access, you need to set a GATEWAY in the qemu-ifup script and
92make sure the external device is part of the bridge.
93
94Note:
95Proper setup will require a /etc/qemu-ifdown script to tear down the
96bridge and interfaces. (not provided here).