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
6 http://www.apache.org/licenses/LICENSE-2.0
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
14 Convention for heading levels in Open vSwitch documentation:
16 ======= Heading 0 (reserved for the title in a document)
22 Avoid deeper levels because they do not render well.
24 =========================================
25 Open vSwitch on Linux, FreeBSD and NetBSD
26 =========================================
28 This document describes how to build and install Open vSwitch on a generic
29 Linux, FreeBSD, or NetBSD host. For specifics around installation on a specific
30 platform, refer to one of these installation guides:
32 - `Debian <INSTALL.Debian.rst>`__
33 - `Fedora <INSTALL.Fedora.md>`__
34 - `RHEL <INSTALL.RHEL.md>`__
35 - `XenServer <INSTALL.XenServer.rst>`__
36 - `NetBSD <INSTALL.NetBSD.md>`__
37 - `Windows <INSTALL.Windows.rst>`__
38 - `DPDK <INSTALL.DPDK.rst>`__
40 .. _general-build-reqs:
45 To compile the userspace programs in the Open vSwitch distribution, you will
46 need the following software:
50 - A C compiler, such as:
54 - Clang. Clang 3.4 and later provide useful static semantic analysis and
55 thread-safety checks. For Ubuntu, there are nightly built packages
56 available on clang's website.
58 - MSVC 2013. See the `Windows installation guide <INSTALL.Windows>`__
59 for additional Windows build instructions.
61 While OVS may be compatible with other compilers, optimal support for atomic
62 operations may be missing, making OVS very slow (see ``lib/ovs-atomic.h``).
64 - libssl, from OpenSSL, is optional but recommended if you plan to connect the
65 Open vSwitch to an OpenFlow controller. libssl is required to establish
66 confidentiality and authenticity in the connections from an Open vSwitch to
67 an OpenFlow controller. If libssl is installed, then Open vSwitch will
68 automatically build with support for it.
70 - libcap-ng, written by Steve Grubb, is optional but recommended. It is
71 required to run OVS daemons as a non-root user with dropped root privileges.
72 If libcap-ng is installed, then Open vSwitch will automatically build with
75 - Python 2.7. You must also have the Python ``six`` library.
77 On Linux, you may choose to compile the kernel module that comes with the Open
78 vSwitch distribution or to use the kernel module built into the Linux kernel
79 (version 3.3 or later). See the `FAQ <FAQ.rst>`__ question "What features
80 are not available in the Open vSwitch kernel datapath that ships as part of the
81 upstream Linux kernel?" for more information on this trade-off. You may also
82 use the userspace-only implementation, at some cost in features and performance
83 (see the `userspace installation guide <INSTALL.userspace.md>`__ for details).
85 To compile the kernel module on Linux, you must also install the
88 - A supported Linux kernel version. Refer to the `README <README.rst>`__
89 for a list of supported versions.
91 For optional support of ingress policing, you must enable kernel
92 configuration options ``NET_CLS_BASIC``, ``NET_SCH_INGRESS``, and
93 ``NET_ACT_POLICE``, either built-in or as modules. ``NET_CLS_POLICE`` is
94 obsolete and not needed.)
96 On kernels before 3.11, the ``ip_gre`` module, for GRE tunnels over IP
97 (``NET_IPGRE``), must not be loaded or compiled in.
99 To configure HTB or HFSC quality of service with Open vSwitch, you must
100 enable the respective configuration options.
102 To use Open vSwitch support for TAP devices, you must enable ``CONFIG_TUN``.
104 - To build a kernel module, you need the same version of GCC that was used to
107 - A kernel build directory corresponding to the Linux kernel image the module
108 is to run on. Under Debian and Ubuntu, for example, each linux-image package
109 containing a kernel binary has a corresponding linux-headers package with
110 the required build infrastructure.
112 If you are working from a Git tree or snapshot (instead of from a distribution
113 tarball), or if you modify the Open vSwitch build system or the database
114 schema, you will also need the following software:
116 - Autoconf version 2.63 or later.
118 - Automake version 1.10 or later.
120 - libtool version 2.4 or later. (Older versions might work too.)
122 To run the unit tests, you also need:
124 - Perl. Version 5.10.1 is known to work. Earlier versions should also
127 The datapath tests for userspace and Linux datapaths also rely upon:
129 - pyftpdlib. Version 1.2.0 is known to work. Earlier versions should
132 - GNU wget. Version 1.16 is known to work. Earlier versions should also
135 The ovs-vswitchd.conf.db(5) manpage will include an E-R diagram, in formats
136 other than plain text, only if you have the following:
138 - dot from graphviz (http://www.graphviz.org/).
140 - Perl. Version 5.10.1 is known to work. Earlier versions should also
143 If you are going to extensively modify Open vSwitch, consider installing the
144 following to obtain better warnings:
146 - "sparse" version 0.4.4 or later
147 (http://www.kernel.org/pub/software/devel/sparse/dist/).
151 - clang, version 3.4 or later
153 - flake8, version 2.X, along with the hacking flake8 plugin (for Python code).
154 The automatic flake8 check that runs against Python code has some warnings
155 enabled that come from the "hacking" flake8 plugin. If it's not installed,
156 the warnings just won't occur until it's run on a system with "hacking"
157 installed. Note that there are problems with flake8 3.0 and the "hacking"
158 plugin. To ensure you get flake8 2.X, you can use::
160 $ pip install 'flake8<3.0'
162 You may find the ovs-dev script found in ``utilities/ovs-dev.py`` useful.
164 .. _general-install-reqs:
166 Installation Requirements
167 -------------------------
169 The machine you build Open vSwitch on may not be the one you run it on. To
170 simply install and run Open vSwitch you require the following software:
172 - libc compatible with the libc used for build.
174 - libssl compatible with the libssl used for build, if OpenSSL was used
177 - On Linux, the same kernel version configured as part of the build.
179 - For optional support of ingress policing on Linux, the "tc" program
180 from iproute2 (part of all major distributions and available at
181 http://www.linux-foundation.org/en/Net:Iproute2).
183 - Python 2.7. You must also have the Python six library.
185 On Linux you should ensure that ``/dev/urandom`` exists. To support TAP
186 devices, you must also ensure that ``/dev/net/tun`` exists.
188 .. _general-bootstrapping:
193 This step is not needed if you have downloaded a released tarball. If
194 you pulled the sources directly from an Open vSwitch Git tree or got a
195 Git tree snapshot, then run boot.sh in the top source directory to build
196 the "configure" script::
200 .. _general-configuring:
205 Configure the package by running the configure script. You can usually
206 invoke configure without any arguments. For example::
210 By default all files are installed under ``/usr/local``. Open vSwitch also
211 expects to find its database in ``/usr/local/etc/openvswitch`` by default. If
212 you want to install all files into, e.g., ``/usr`` and ``/var`` instead of
213 ``/usr/local`` and ``/usr/local/var`` and expect to use ``/etc/openvswitch`` as
214 the default database directory, add options as shown here::
216 $ ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
220 Open vSwitch installed with packages like .rpm (e.g. via ``yum install`` or
221 ``rpm -ivh``) and .deb (e.g. via ``apt-get install`` or ``dpkg -i``) use the
222 above configure options.
224 By default, static libraries are built and linked against. If you want to use
225 shared libraries instead::
227 $ ./configure --enable-shared
229 To use a specific C compiler for compiling Open vSwitch user programs, also
230 specify it on the configure command line, like so::
232 $ ./configure CC=gcc-4.2
234 To use 'clang' compiler::
236 $ ./configure CC=clang
238 To supply special flags to the C compiler, specify them as ``CFLAGS`` on the
239 configure command line. If you want the default CFLAGS, which include ``-g`` to
240 build debug symbols and ``-O2`` to enable optimizations, you must include them
241 yourself. For example, to build with the default CFLAGS plus ``-mssse3``, you
242 might run configure as follows::
244 $ ./configure CFLAGS="-g -O2 -mssse3"
246 For efficient hash computation special flags can be passed to leverage built-in
247 intrinsics. For example on X86_64 with SSE4.2 instruction set support, CRC32
248 intrinsics can be used by passing ``-msse4.2``::
250 $ ./configure CFLAGS="-g -O2 -msse4.2"`
252 If you are on a different processor and don't know what flags to choose, it is
253 recommended to use ``-march=native`` settings::
255 $ ./configure CFLAGS="-g -O2 -march=native"
257 With this, GCC will detect the processor and automatically set appropriate
258 flags for it. This should not be used if you are compiling OVS outside the
262 CFLAGS are not applied when building the Linux kernel module. Custom CFLAGS
263 for the kernel module are supplied using the ``EXTRA_CFLAGS`` variable when
264 running make. For example::
266 $ make EXTRA_CFLAGS="-Wno-error=date-time"
268 To build the Linux kernel module, so that you can run the kernel-based switch,
269 pass the location of the kernel build directory on ``--with-linux``. For
270 example, to build for a running instance of Linux::
272 $ ./configure --with-linux=/lib/modules/$(uname -r)/build
275 If ``--with-linux`` requests building for an unsupported version of Linux,
276 then ``configure`` will fail with an error message. Refer to the `FAQ
277 <FAQ.rst>`__ for advice in that case.
279 If you wish to build the kernel module for an architecture other than the
280 architecture of the machine used for the build, you may specify the kernel
281 architecture string using the KARCH variable when invoking the configure
282 script. For example, to build for MIPS with Linux::
284 $ ./configure --with-linux=/path/to/linux KARCH=mips
286 If you plan to do much Open vSwitch development, you might want to add
287 ``--enable-Werror``, which adds the ``-Werror`` option to the compiler command
288 line, turning warnings into errors. That makes it impossible to miss warnings
289 generated by the build. For example::
291 $ ./configure --enable-Werror
293 To build with gcov code coverage support, add ``--enable-coverage``::
295 $ ./configure --enable-coverage
297 The configure script accepts a number of other options and honors additional
298 environment variables. For a full list, invoke configure with the ``--help``
303 You can also run configure from a separate build directory. This is helpful if
304 you want to build Open vSwitch in more than one way from a single source
305 directory, e.g. to try out both GCC and Clang builds, or to build kernel
306 modules for more than one Linux version. For example::
308 $ mkdir _gcc && (cd _gcc && ./configure CC=gcc)
309 $ mkdir _clang && (cd _clang && ./configure CC=clang)
311 Under certains loads the ovsdb-server and other components perform better when
312 using the jemalloc memory allocator, instead of the glibc memory allocator. If
313 you wish to link with jemalloc add it to LIBS::
315 $ ./configure LIBS=-ljemalloc
317 .. _general-building:
322 1. Run GNU make in the build directory, e.g.::
326 or if GNU make is installed as "gmake"::
330 If you used a separate build directory, run make or gmake from that
336 For improved warnings if you installed ``sparse`` (see "Prerequisites"), add
337 ``C=1`` to the command line.
340 Some versions of Clang and ccache are not completely compatible. If you
341 see unusual warnings when you use both together, consider disabling
344 2. Consider running the testsuite. Refer to **Testing** for instructions.
346 3. Run ``make install`` to install the executables and manpages into the
347 running system, by default under ``/usr/local``::
351 5. If you built kernel modules, you may install them, e.g.::
353 $ make modules_install
355 It is possible that you already had a Open vSwitch kernel module installed
356 on your machine that came from upstream Linux (in a different directory). To
357 make sure that you load the Open vSwitch kernel module you built from this
358 repository, you should create a ``depmod.d`` file that prefers your newly
359 installed kernel modules over the kernel modules from upstream Linux. The
360 following snippet of code achieves the same::
362 $ config_file="/etc/depmod.d/openvswitch.conf"
363 $ for module in datapath/linux/*.ko; do
364 modname="$(basename ${module})"
365 echo "override ${modname%.ko} * extra" >> "$config_file"
366 echo "override ${modname%.ko} * weak-updates" >> "$config_file"
370 Finally, load the kernel modules that you need. e.g.::
372 $ /sbin/modprobe openvswitch
374 To verify that the modules have been loaded, run ``/sbin/lsmod`` and check
375 that openvswitch is listed::
377 $ /sbin/lsmod | grep openvswitch
380 If the ``modprobe`` operation fails, look at the last few kernel log
381 messages (e.g. with ``dmesg | tail``). Generally, issues like this occur
382 when Open vSwitch is built for a kernel different from the one into which
383 you are trying to load it. Run ``modinfo`` on ``openvswitch.ko`` and on a
384 module built for the running kernel, e.g.::
386 $ /sbin/modinfo openvswitch.ko
387 $ /sbin/modinfo /lib/modules/$(uname -r)/kernel/net/bridge/bridge.ko
389 Compare the "vermagic" lines output by the two commands. If they differ,
390 then Open vSwitch was built for the wrong kernel.
392 If you decide to report a bug or ask a question related to module loading,
393 include the output from the ``dmesg`` and ``modinfo`` commands mentioned
396 .. _general-starting:
401 Before starting ovs-vswitchd itself, you need to start its configuration
402 database, ovsdb-server. Each machine on which Open vSwitch is installed should
403 run its own copy of ovsdb-server. Before ovsdb-server itself can be started,
404 configure a database that it can use::
406 $ mkdir -p /usr/local/etc/openvswitch
407 $ ovsdb-tool create /usr/local/etc/openvswitch/conf.db \
408 vswitchd/vswitch.ovsschema
410 Configure ovsdb-server to use database created above, to listen on a Unix
411 domain socket, to connect to any managers specified in the database itself, and
412 to use the SSL configuration in the database::
414 $ mkdir -p /usr/local/var/run/openvswitch
415 $ ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
416 --remote=db:Open_vSwitch,Open_vSwitch,manager_options \
417 --private-key=db:Open_vSwitch,SSL,private_key \
418 --certificate=db:Open_vSwitch,SSL,certificate \
419 --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
423 If you built Open vSwitch without SSL support, then omit ``--private-key``,
424 ``--certificate``, and ``--bootstrap-ca-cert``.)
426 Initialize the database using ovs-vsctl. This is only necessary the first time
427 after you create the database with ovsdb-tool, though running it at any time is
430 $ ovs-vsctl --no-wait init
432 Start the main Open vSwitch daemon, telling it to connect to the same Unix
435 $ ovs-vswitchd --pidfile --detach
440 At this point you can use ovs-vsctl to set up bridges and other Open vSwitch
441 features. For example, to create a bridge named ``br0`` and add ports ``eth0``
442 and ``vif1.0`` to it::
444 $ ovs-vsctl add-br br0
445 $ ovs-vsctl add-port br0 eth0
446 $ ovs-vsctl add-port br0 vif1.0
448 Refer to ovs-vsctl(8) for more details.
453 When you upgrade Open vSwitch from one version to another you should also
454 upgrade the database schema:
456 1. Stop the Open vSwitch daemons, e.g.::
458 $ kill `cd /usr/local/var/run/openvswitch && cat ovsdb-server.pid ovs-vswitchd.pid`
460 2. Install the new Open vSwitch release by using the same configure options as
461 was used for installing the previous version. If you do not use the same
462 configure options, you can end up with two different versions of Open
463 vSwitch executables installed in different locations.
465 3. Upgrade the database, in one of the following two ways:
467 - If there is no important data in your database, then you may delete the
468 database file and recreate it with ovsdb-tool, following the instructions
469 under "Building and Installing Open vSwitch for Linux, FreeBSD or NetBSD".
471 - If you want to preserve the contents of your database, back it up first,
472 then use ``ovsdb-tool convert`` to upgrade it, e.g.::
474 $ ovsdb-tool convert /usr/local/etc/openvswitch/conf.db \
475 vswitchd/vswitch.ovsschema
477 4. Start the Open vSwitch daemons as described under **Starting** above.
482 Upgrading Open vSwitch from one version to the next version with minimum
483 disruption of traffic going through the system that is using that Open vSwitch
484 needs some considerations:
486 1. If the upgrade only involves upgrading the userspace utilities and daemons
487 of Open vSwitch, make sure that the new userspace version is compatible with
488 the previously loaded kernel module.
490 2. An upgrade of userspace daemons means that they have to be restarted.
491 Restarting the daemons means that the OpenFlow flows in the ovs-vswitchd
492 daemon will be lost. One way to restore the flows is to let the controller
493 re-populate it. Another way is to save the previous flows using a utility
494 like ovs-ofctl and then re-add them after the restart. Restoring the old
495 flows is accurate only if the new Open vSwitch interfaces retain the old
498 3. When the new userspace daemons get restarted, they automatically flush the
499 old flows setup in the kernel. This can be expensive if there are hundreds
500 of new flows that are entering the kernel but userspace daemons are busy
501 setting up new userspace flows from either the controller or an utility like
502 ovs-ofctl. Open vSwitch database provides an option to solve this problem
503 through the ``other_config:flow-restore-wait`` column of the
504 ``Open_vSwitch`` table. Refer to the ovs-vswitchd.conf.db(5) manpage for
507 4. If the upgrade also involves upgrading the kernel module, the old kernel
508 module needs to be unloaded and the new kernel module should be loaded. This
509 means that the kernel network devices belonging to Open vSwitch is recreated
510 and the kernel flows are lost. The downtime of the traffic can be reduced if
511 the userspace daemons are restarted immediately and the userspace flows are
512 restored as soon as possible.
514 The ovs-ctl utility's ``restart`` function only restarts the userspace daemons,
515 makes sure that the 'ofport' values remain consistent across restarts, restores
516 userspace flows using the ovs-ofctl utility and also uses the
517 ``other_config:flow-restore-wait`` column to keep the traffic downtime to the
518 minimum. The ovs-ctl utility's ``force-reload-kmod`` function does all of the
519 above, but also replaces the old kernel module with the new one. Open vSwitch
520 startup scripts for Debian, XenServer and RHEL use ovs-ctl's functions and it
521 is recommended that these functions be used for other software platforms too.
528 This section describe Open vSwitch's built-in support for various test
529 suites. You must bootstrap, configure and build Open vSwitch (steps are
530 in "Building and Installing Open vSwitch for Linux, FreeBSD or NetBSD"
531 above) before you run the tests described here. You do not need to
532 install Open vSwitch or to build or load the kernel module to run these
533 test suites. You do not need supervisor privilege to run these test
539 Open vSwitch includes a suite of self-tests. Before you submit patches
540 upstream, we advise that you run the tests and ensure that they pass. If you
541 add new features to Open vSwitch, then adding tests for those features will
542 ensure your features don't break as developers modify other areas of Open
545 To run all the unit tests in Open vSwitch, one at a time, run::
549 This takes under 5 minutes on a modern desktop system.
551 To run all the unit tests in Open vSwitch in parallel, run::
553 $ make check TESTSUITEFLAGS=-j8
555 You can run up to eight threads. This takes under a minute on a modern 4-core
558 To see a list of all the available tests, run:
560 $ make check TESTSUITEFLAGS=--list
562 To run only a subset of tests, e.g. test 123 and tests 477 through 484, run::
564 $ make check TESTSUITEFLAGS='123 477-484'
566 Tests do not have inter-dependencies, so you may run any subset.
568 To run tests matching a keyword, e.g. ``ovsdb``, run::
570 $ make check TESTSUITEFLAGS='-k ovsdb'
572 To see a complete list of test options, run::
574 $ make check TESTSUITEFLAGS=--help
576 The results of a testing run are reported in ``tests/testsuite.log``. Report
577 report test failures as bugs and include the ``testsuite.log`` in your report.
580 Sometimes a few tests may fail on some runs but not others. This is usually a
581 bug in the testsuite, not a bug in Open vSwitch itself. If you find that a
582 test fails intermittently, please report it, since the developers may not
583 have noticed. You can make the testsuite automatically rerun tests that fail,
584 by adding ``RECHECK=yes`` to the ``make`` command line, e.g.::
586 $ make check TESTSUITEFLAGS=-j8 RECHECK=yes
591 If the build was configured with ``--enable-coverage`` and the ``lcov`` utility
592 is installed, you can run the testsuite and generate a code coverage report by
593 using the ``check-lcoc`` target::
597 All the same options are avaiable via TESTSUITEFLAGS. For example::
599 $ make check-lcov TESTSUITEFLAGS=-j8 -k ovn
604 If you have ``valgrind`` installed, you can run the testsuite under
605 valgrind by using the ``check-valgrind`` target::
607 $ make check-valgrind
609 When you do this, the "valgrind" results for test ``<N>`` are reported in files
610 named ``tests/testsuite.dir/<N>/valgrind.*``.
612 All the same options are available via TESTSUITEFLAGS.
615 You may find that the valgrind results are easier to interpret if you put
616 ``-q`` in ``~/.valgrindrc``, since that reduces the amount of output.
623 OFTest is an OpenFlow protocol testing suite. Open vSwitch includes a Makefile
624 target to run OFTest with Open vSwitch in "dummy mode". In this mode of
625 testing, no packets travel across physical or virtual networks. Instead, Unix
626 domain sockets stand in as simulated networks. This simulation is imperfect,
627 but it is much easier to set up, does not require extra physical or virtual
628 hardware, and does not require supervisor privileges.
630 To run OFTest with Open vSwitch, first read and follow the instructions under
631 **Testing** above. Second, obtain a copy of OFTest and install its
632 prerequisites. You need a copy of OFTest that includes commit 406614846c5 (make
633 ovs-dummy platform work again). This commit was merged into the OFTest
634 repository on Feb 1, 2013, so any copy of OFTest more recent than that should
635 work. Testing OVS in dummy mode does not require root privilege, so you may
636 ignore that requirement.
638 Optionally, add the top-level OFTest directory (containing the ``oft`` program)
639 to your ``$PATH``. This slightly simplifies running OFTest later.
641 To run OFTest in dummy mode, run the following command from your Open vSwitch
644 $ make check-oftest OFT=<oft-binary>
646 where ``<oft-binary>`` is the absolute path to the ``oft`` program in OFTest.
647 If you added "oft" to your $PATH, you may omit the OFT variable
650 By default, ``check-oftest`` passes ``oft`` just enough options to enable dummy
651 mode. You can use ``OFTFLAGS`` to pass additional options. For example, to run
652 just the ``basic.Echo`` test instead of all tests (the default) and enable
653 verbose logging, run::
655 $ make check-oftest OFT=<oft-binary> OFTFLAGS='--verbose -T basic.Echo'
657 If you use OFTest that does not include commit 4d1f3eb2c792 (oft: change
658 default port to 6653), merged into the OFTest repository in October 2013, then
659 you need to add an option to use the IETF-assigned controller port::
661 $ make check-oftest OFT=<oft-binary> OFTFLAGS='--port=6653'
663 Interpret OFTest results cautiously. Open vSwitch can fail a given test in
664 OFTest for many reasons, including bugs in Open vSwitch, bugs in OFTest, bugs
665 in the "dummy mode" integration, and differing interpretations of the OpenFlow
666 standard and other standards.
669 Open vSwitch has not been validated against OFTest. Report test failures that
670 you believe to represent bugs in Open vSwitch. Include the precise versions
671 of Open vSwitch and OFTest in your bug report, plus any other information
672 needed to reproduce the problem.
677 Ryu is an OpenFlow controller written in Python that includes an extensive
678 OpenFlow testsuite. Open vSwitch includes a Makefile target to run Ryu in
679 "dummy mode". See **OFTest** above for an explanation of dummy mode.
681 To run Ryu tests with Open vSwitch, first read and follow the instructions
682 under **Testing** above. Second, obtain a copy of Ryu, install its
683 prerequisites, and build it. You do not need to install Ryu (some of the tests
684 do not get installed, so it does not help).
686 To run Ryu tests, run the following command from your Open vSwitch build
689 $ make check-ryu RYUDIR=<ryu-source-dir>``
691 where ``<ryu-source-dir>`` is the absolute path to the root of the Ryu source
692 distribution. The default ``<ryu-source-dir>`` is ``$srcdir/../ryu``
693 where ``$srcdir`` is your Open vSwitch source directory. If this is correct,
697 Open vSwitch has not been validated against Ryu. Report test failures that
698 you believe to represent bugs in Open vSwitch. Include the precise versions
699 of Open vSwitch and Ryu in your bug report, plus any other information
700 needed to reproduce the problem.
705 Open vSwitch includes a suite of tests specifically for datapath functionality,
706 which can be run against the userspace or kernel datapaths. If you are
707 developing datapath features, it is recommended that you use these tests and
708 build upon them to verify your implementation.
710 The datapath tests make some assumptions about the environment. They must be
711 run under root privileges on a Linux system with support for network
712 namespaces. For ease of use, the OVS source tree includes a vagrant box to
713 invoke these tests. Running the tests inside Vagrant provides kernel isolation,
714 protecting your development host from kernel panics or configuration conflicts
715 in the testsuite. If you wish to run the tests without using the vagrant box,
716 there are further instructions below.
723 Requires Vagrant (version 1.7.0 or later) and a compatible hypervisor
726 You must **Bootstrap** and **Configure** the sources before you run the steps
729 A Vagrantfile is provided allowing to compile and provision the source tree as
730 found locally in a virtual machine using the following command::
734 This will bring up a Fedora 23 VM by default. If you wish to use a different
735 box or a vagrant backend not supported by the default box, the ``Vagrantfile``
736 can be modified to use a different box as base.
738 The VM can be reprovisioned at any time::
742 OVS out-of-tree compilation environment can be set up with::
745 $ vagrant provision --provision-with configure_ovs,build_ovs
747 This will set up an out-of-tree build environment inside the VM in
748 ``/root/build``. The source code can be found in ``/vagrant``.
750 To recompile and reinstall OVS in the VM using RPM::
753 $ vagrant provision --provision-with configure_ovs,install_rpm
755 Two provisioners are included to run system tests with the OVS kernel module or
756 with a userspace datapath. This tests are different from the self-tests
757 mentioned above. To run them::
760 $ vagrant provision --provision-with \
761 configure_ovs,test_ovs_kmod,test_ovs_system_userspace
763 The results of the testsuite reside in the VM root user's home directory::
773 The datapath testsuite as invoked by Vagrant above may also be run manually on
774 a Linux system with root privileges. These tests may take several minutes to
775 complete, and cannot be run in parallel.
780 To invoke the datapath testsuite with the userspace datapath, run::
782 $ make check-system-userspace
784 The results of the testsuite are in ``tests/system-userspace-traffic.dir``.
789 Make targets are also provided for testing the Linux kernel module. Note that
790 these tests operate by inserting modules into the running Linux kernel, so if
791 the tests are able to trigger a bug in the OVS kernel module or in the upstream
792 kernel then the kernel may panic.
794 To run the testsuite against the kernel module which is currently installed on
799 To install the kernel module from the current build directory and run the
800 testsuite against that kernel module::
804 The results of the testsuite are in ``tests/system-kmod-traffic.dir``.
806 Continuous Integration with Travis-CI
807 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
809 A .travis.yml file is provided to automatically build Open vSwitch with various
810 build configurations and run the testsuite using travis-ci. Builds will be
811 performed with gcc, sparse and clang with the -Werror compiler flag included,
812 therefore the build will fail if a new warning has been introduced.
814 The CI build is triggered via git push (regardless of the specific branch) or
815 pull request against any Open vSwitch GitHub repository that is linked to
818 Instructions to setup travis-ci for your GitHub repository:
820 1. Go to http://travis-ci.org/ and sign in using your GitHub ID.
821 2. Go to the "Repositories" tab and enable the ovs repository. You may disable
822 builds for pushes or pull requests.
823 3. In order to avoid forks sending build failures to the upstream mailing list,
824 the notification email recipient is encrypted. If you want to receive email
825 notification for build failures, replace the the encrypted string:
827 1. Install the travis-ci CLI (Requires ruby >=2.0): gem install travis
828 2. In your Open vSwitch repository: travis encrypt mylist@mydomain.org
829 3. Add/replace the notifications section in .travis.yml and fill in the
830 secure string as returned by travis encrypt::
838 You may remove/omit the notifications section to fall back to default
839 notification behaviour which is to send an email directly to the author and
840 committer of the failing commit. Note that the email is only sent if the
841 author/committer have commit rights for the particular GitHub repository.
843 4. Pushing a commit to the repository which breaks the build or the
844 testsuite will now trigger a email sent to mylist@mydomain.org
849 Static Analysis is a method of debugging Software by examining code rather than
850 actually executing it. This can be done through 'scan-build' commandline
851 utility which internally uses clang (or) gcc to compile the code and also
852 invokes a static analyzer to do the code analysis. At the end of the build, the
853 reports are aggregated in to a common folder and can later be analyzed using
856 Open vSwitch includes a Makefile target to trigger static code analysis::
859 $ ./configure CC=clang # clang
861 $ ./configure CC=gcc CFLAGS="-std=gnu99" # gcc
864 You should invoke scan-view to view analysis results. The last line of output
865 from ``clang-analyze`` will list the command (containing results directory)
866 that you should invoke to view the results on a browser.
871 Please report problems to bugs@openvswitch.org.