]>
Commit | Line | Data |
---|---|---|
7668f7cc SF |
1 | .. |
2 | Licensed under the Apache License, Version 2.0 (the "License"); you may | |
3 | not use this file except in compliance with the License. You may obtain | |
4 | a copy of the License at | |
5 | ||
6 | http://www.apache.org/licenses/LICENSE-2.0 | |
7 | ||
8 | Unless required by applicable law or agreed to in writing, software | |
9 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
10 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
11 | License for the specific language governing permissions and limitations | |
12 | under the License. | |
13 | ||
14 | Convention for heading levels in Open vSwitch documentation: | |
15 | ||
16 | ======= Heading 0 (reserved for the title in a document) | |
17 | ------- Heading 1 | |
18 | ~~~~~~~ Heading 2 | |
19 | +++++++ Heading 3 | |
20 | ''''''' Heading 4 | |
21 | ||
22 | Avoid deeper levels because they do not render well. | |
23 | ||
24 | ================================ | |
25 | How to Use Open vSwitch with KVM | |
26 | ================================ | |
27 | ||
28 | This document describes how to use Open vSwitch with the Kernel-based Virtual | |
29 | Machine (KVM). | |
30 | ||
31 | .. note:: | |
32 | ||
33 | This document assumes that you have read and followed the `installation guide | |
34 | <INSTALL.rst>`__ to get Open vSwitch setup on your Linux system. | |
35 | ||
36 | Setup | |
37 | ----- | |
38 | ||
39 | KVM uses tunctl to handle various bridging modes, which you can install with | |
dc76953f | 40 | the Debian/Ubuntu package ``uml-utilities``:: |
7668f7cc SF |
41 | |
42 | $ apt-get install uml-utilities | |
43 | ||
44 | Next, you will need to modify or create custom versions of the ``qemu-ifup`` | |
45 | and ``qemu-ifdown`` scripts. In this guide, we'll create custom versions that | |
46 | make use of example Open vSwitch bridges that we'll describe in this guide. | |
47 | ||
dc76953f | 48 | Create the following two files and store them in known locations. For example:: |
7668f7cc SF |
49 | |
50 | echo << EOF > /etc/ovs-ifup | |
51 | #!/bin/sh | |
52 | ||
53 | switch='br0' | |
54 | /sbin/ifconfig $1 0.0.0.0 up | |
55 | ovs-vsctl add-port ${switch} $1 | |
56 | EOF | |
57 | ||
58 | :: | |
59 | ||
60 | echo << EOF > /etc/ovs-ifdown | |
61 | #!/bin/sh | |
62 | ||
63 | switch='br0' | |
64 | /sbin/ifconfig $1 0.0.0.0 down | |
65 | ovs-vsctl del-port ${switch} $1 | |
66 | ||
67 | The basic usage of Open vSwitch is described at the end of the `installation | |
68 | guide <INSTALL.rst>`__. If you haven't already, create a bridge named ``br0`` | |
dc76953f | 69 | with the following command:: |
7668f7cc SF |
70 | |
71 | $ ovs-vsctl add-br br0 | |
72 | ||
73 | Then, add a port to the bridge for the NIC that you want your guests to | |
dc76953f | 74 | communicate over (e.g. ``eth0``):: |
7668f7cc SF |
75 | |
76 | $ ovs-vsctl add-port br0 eth0 | |
77 | ||
78 | Refer to ovs-vsctl(8) for more details. | |
79 | ||
dc76953f | 80 | Next, we'll start a guest that will use our ifup and ifdown scripts:: |
7668f7cc SF |
81 | |
82 | $ kvm -m 512 -net nic,macaddr=00:11:22:EE:EE:EE -net \ | |
83 | tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -drive \ | |
84 | file=/path/to/disk-image,boot=on | |
85 | ||
86 | This will start the guest and associate a tap device with it. The ``ovs-ifup`` | |
87 | script will add a port on the br0 bridge so that the guest will be able to | |
88 | communicate over that bridge. | |
89 | ||
90 | To get some more information and for debugging you can use Open vSwitch | |
dc76953f | 91 | utilities such as ovs-dpctl and ovs-ofctl, For example:: |
7668f7cc SF |
92 | |
93 | $ ovs-dpctl show | |
94 | $ ovs-ofctl show br0 | |
95 | ||
96 | You should see tap devices for each KVM guest added as ports to the bridge | |
97 | (e.g. tap0) | |
98 | ||
99 | Refer to ovs-dpctl(8) and ovs-ofctl(8) for more details. | |
100 | ||
101 | Bug Reporting | |
102 | ------------- | |
103 | ||
104 | Please report problems to bugs@openvswitch.org. |