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.md>`__
33 - `Fedora <INSTALL.Fedora.md>`__
34 - `RHEL <INSTALL.RHEL.md>`__
35 - `XenServer <INSTALL.XenServer.md>`__
36 - `NetBSD <INSTALL.NetBSD.md>`__
37 - `Windows <INSTALL.Windows.md>`__
38 - `DPDK <INSTALL.DPDK.md>`__
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.md>`__ 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
86 To compile the kernel module on Linux, you must also install the
89 - A supported Linux kernel version. Refer to the `README <README.md>`__
90 for a list of supported versions.
92 For optional support of ingress policing, you must enable kernel
93 configuration options ``NET_CLS_BASIC``, ``NET_SCH_INGRESS``, and
94 ``NET_ACT_POLICE``, either built-in or as modules. ``NET_CLS_POLICE`` is
95 obsolete and not needed.)
97 On kernels before 3.11, the ``ip_gre`` module, for GRE tunnels over IP
98 (``NET_IPGRE``), must not be loaded or compiled in.
100 To configure HTB or HFSC quality of service with Open vSwitch, you must
101 enable the respective configuration options.
103 To use Open vSwitch support for TAP devices, you must enable ``CONFIG_TUN``.
105 - To build a kernel module, you need the same version of GCC that was used to
108 - A kernel build directory corresponding to the Linux kernel image the module
109 is to run on. Under Debian and Ubuntu, for example, each linux-image package
110 containing a kernel binary has a corresponding linux-headers package with
111 the required build infrastructure.
113 If you are working from a Git tree or snapshot (instead of from a distribution
114 tarball), or if you modify the Open vSwitch build system or the database
115 schema, you will also need the following software:
117 - Autoconf version 2.63 or later.
119 - Automake version 1.10 or later.
121 - libtool version 2.4 or later. (Older versions might work too.)
123 To run the unit tests, you also need:
125 - Perl. Version 5.10.1 is known to work. Earlier versions should also
128 The datapath tests for userspace and Linux datapaths also rely upon:
130 - pyftpdlib. Version 1.2.0 is known to work. Earlier versions should
133 - GNU wget. Version 1.16 is known to work. Earlier versions should also
136 The ovs-vswitchd.conf.db(5) manpage will include an E-R diagram, in formats
137 other than plain text, only if you have the following:
139 - dot from graphviz (http://www.graphviz.org/).
141 - Perl. Version 5.10.1 is known to work. Earlier versions should also
144 If you are going to extensively modify Open vSwitch, consider installing the
145 following to obtain better warnings:
147 - "sparse" version 0.4.4 or later
148 (http://www.kernel.org/pub/software/devel/sparse/dist/).
152 - clang, version 3.4 or later
154 - flake8, version 2.X, along with the hacking flake8 plugin (for Python code).
155 The automatic flake8 check that runs against Python code has some warnings
156 enabled that come from the "hacking" flake8 plugin. If it's not installed,
157 the warnings just won't occur until it's run on a system with "hacking"
158 installed. Note that there are problems with flake8 3.0 and the "hacking"
159 plugin. To ensure you get flake8 2.X, you can use::
161 $ pip install 'flake8<3.0'
163 You may find the ovs-dev script found in ``utilities/ovs-dev.py`` useful.
165 .. _general-install-reqs:
167 Installation Requirements
168 -------------------------
170 The machine you build Open vSwitch on may not be the one you run it on. To
171 simply install and run Open vSwitch you require the following software:
173 - libc compatible with the libc used for build.
175 - libssl compatible with the libssl used for build, if OpenSSL was used
178 - On Linux, the same kernel version configured as part of the build.
180 - For optional support of ingress policing on Linux, the "tc" program
181 from iproute2 (part of all major distributions and available at
182 http://www.linux-foundation.org/en/Net:Iproute2).
184 - Python 2.7. You must also have the Python six library.
186 On Linux you should ensure that ``/dev/urandom`` exists. To support TAP
187 devices, you must also ensure that ``/dev/net/tun`` exists.
189 .. _general-bootstrapping:
194 This step is not needed if you have downloaded a released tarball. If
195 you pulled the sources directly from an Open vSwitch Git tree or got a
196 Git tree snapshot, then run boot.sh in the top source directory to build
197 the "configure" script::
201 .. _general-configuring:
206 Configure the package by running the configure script. You can usually
207 invoke configure without any arguments. For example::
211 By default all files are installed under ``/usr/local``. Open vSwitch also
212 expects to find its database in ``/usr/local/etc/openvswitch`` by default. If
213 you want to install all files into, e.g., ``/usr`` and ``/var`` instead of
214 ``/usr/local`` and ``/usr/local/var`` and expect to use ``/etc/openvswitch`` as
215 the default database directory, add options as shown here::
217 $ ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
221 Open vSwitch installed with packages like .rpm (e.g. via ``yum install`` or
222 ``rpm -ivh``) and .deb (e.g. via ``apt-get install`` or ``dpkg -i``) use the
223 above configure options.
225 By default, static libraries are built and linked against. If you want to use
226 shared libraries instead::
228 $ ./configure --enable-shared
230 To use a specific C compiler for compiling Open vSwitch user programs, also
231 specify it on the configure command line, like so::
233 $ ./configure CC=gcc-4.2
235 To use 'clang' compiler::
237 $ ./configure CC=clang
239 To supply special flags to the C compiler, specify them as ``CFLAGS`` on the
240 configure command line. If you want the default CFLAGS, which include ``-g`` to
241 build debug symbols and ``-O2`` to enable optimizations, you must include them
242 yourself. For example, to build with the default CFLAGS plus ``-mssse3``, you
243 might run configure as follows::
245 $ ./configure CFLAGS="-g -O2 -mssse3"
247 For efficient hash computation special flags can be passed to leverage built-in
248 intrinsics. For example on X86_64 with SSE4.2 instruction set support, CRC32
249 intrinsics can be used by passing ``-msse4.2``::
251 $ ./configure CFLAGS="-g -O2 -msse4.2"`
253 If you are on a different processor and don't know what flags to choose, it is
254 recommended to use ``-march=native`` settings::
256 $ ./configure CFLAGS="-g -O2 -march=native"
258 With this, GCC will detect the processor and automatically set appropriate
259 flags for it. This should not be used if you are compiling OVS outside the
263 CFLAGS are not applied when building the Linux kernel module. Custom CFLAGS
264 for the kernel module are supplied using the ``EXTRA_CFLAGS`` variable when
265 running make. For example::
267 $ make EXTRA_CFLAGS="-Wno-error=date-time"
269 To build the Linux kernel module, so that you can run the kernel-based switch,
270 pass the location of the kernel build directory on ``--with-linux``. For
271 example, to build for a running instance of Linux::
273 $ ./configure --with-linux=/lib/modules/$(uname -r)/build
276 If ``--with-linux`` requests building for an unsupported version of Linux,
277 then ``configure`` will fail with an error message. Refer to the `FAQ
278 <FAQ.md>`__ for advice in that case.
280 If you wish to build the kernel module for an architecture other than the
281 architecture of the machine used for the build, you may specify the kernel
282 architecture string using the KARCH variable when invoking the configure
283 script. For example, to build for MIPS with Linux::
285 $ ./configure --with-linux=/path/to/linux KARCH=mips
287 If you plan to do much Open vSwitch development, you might want to add
288 ``--enable-Werror``, which adds the ``-Werror`` option to the compiler command
289 line, turning warnings into errors. That makes it impossible to miss warnings
290 generated by the build. For example::
292 $ ./configure --enable-Werror
294 To build with gcov code coverage support, add ``--enable-coverage``::
296 $ ./configure --enable-coverage
298 The configure script accepts a number of other options and honors additional
299 environment variables. For a full list, invoke configure with the ``--help``
304 You can also run configure from a separate build directory. This is helpful if
305 you want to build Open vSwitch in more than one way from a single source
306 directory, e.g. to try out both GCC and Clang builds, or to build kernel
307 modules for more than one Linux version. For example::
309 $ mkdir _gcc && (cd _gcc && ./configure CC=gcc)
310 $ mkdir _clang && (cd _clang && ./configure CC=clang)
312 Under certains loads the ovsdb-server and other components perform better when
313 using the jemalloc memory allocator, instead of the glibc memory allocator. If
314 you wish to link with jemalloc add it to LIBS::
316 $ ./configure LIBS=-ljemalloc
318 .. _general-building:
323 1. Run GNU make in the build directory, e.g.::
327 or if GNU make is installed as "gmake"::
331 If you used a separate build directory, run make or gmake from that
337 For improved warnings if you installed ``sparse`` (see "Prerequisites"), add
338 ``C=1`` to the command line.
341 Some versions of Clang and ccache are not completely compatible. If you
342 see unusual warnings when you use both together, consider disabling
345 2. Consider running the testsuite. Refer to **Testing** for instructions.
347 3. Run ``make install`` to install the executables and manpages into the
348 running system, by default under ``/usr/local``::
352 5. If you built kernel modules, you may install them, e.g.::
354 $ make modules_install
356 It is possible that you already had a Open vSwitch kernel module installed
357 on your machine that came from upstream Linux (in a different directory). To
358 make sure that you load the Open vSwitch kernel module you built from this
359 repository, you should create a ``depmod.d`` file that prefers your newly
360 installed kernel modules over the kernel modules from upstream Linux. The
361 following snippet of code achieves the same::
363 $ config_file="/etc/depmod.d/openvswitch.conf"
364 $ for module in datapath/linux/*.ko; do
365 modname="$(basename ${module})"
366 echo "override ${modname%.ko} * extra" >> "$config_file"
367 echo "override ${modname%.ko} * weak-updates" >> "$config_file"
371 Finally, load the kernel modules that you need. e.g.::
373 $ /sbin/modprobe openvswitch
375 To verify that the modules have been loaded, run ``/sbin/lsmod`` and check
376 that openvswitch is listed::
378 $ /sbin/lsmod | grep openvswitch
381 If the ``modprobe`` operation fails, look at the last few kernel log
382 messages (e.g. with ``dmesg | tail``). Generally, issues like this occur
383 when Open vSwitch is built for a kernel different from the one into which
384 you are trying to load it. Run ``modinfo`` on ``openvswitch.ko`` and on a
385 module built for the running kernel, e.g.::
387 $ /sbin/modinfo openvswitch.ko
388 $ /sbin/modinfo /lib/modules/$(uname -r)/kernel/net/bridge/bridge.ko
390 Compare the "vermagic" lines output by the two commands. If they differ,
391 then Open vSwitch was built for the wrong kernel.
393 If you decide to report a bug or ask a question related to module loading,
394 include the output from the ``dmesg`` and ``modinfo`` commands mentioned
397 .. _general-starting:
402 Before starting ovs-vswitchd itself, you need to start its configuration
403 database, ovsdb-server. Each machine on which Open vSwitch is installed should
404 run its own copy of ovsdb-server. Before ovsdb-server itself can be started,
405 configure a database that it can use::
407 $ mkdir -p /usr/local/etc/openvswitch
408 $ ovsdb-tool create /usr/local/etc/openvswitch/conf.db \
409 vswitchd/vswitch.ovsschema
411 Configure ovsdb-server to use database created above, to listen on a Unix
412 domain socket, to connect to any managers specified in the database itself, and
413 to use the SSL configuration in the database::
415 $ mkdir -p /usr/local/var/run/openvswitch
416 $ ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
417 --remote=db:Open_vSwitch,Open_vSwitch,manager_options \
418 --private-key=db:Open_vSwitch,SSL,private_key \
419 --certificate=db:Open_vSwitch,SSL,certificate \
420 --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
424 If you built Open vSwitch without SSL support, then omit ``--private-key``,
425 ``--certificate``, and ``--bootstrap-ca-cert``.)
427 Initialize the database using ovs-vsctl. This is only necessary the first time
428 after you create the database with ovsdb-tool, though running it at any time is
431 $ ovs-vsctl --no-wait init
433 Start the main Open vSwitch daemon, telling it to connect to the same Unix
436 $ ovs-vswitchd --pidfile --detach
441 At this point you can use ovs-vsctl to set up bridges and other Open vSwitch
442 features. For example, to create a bridge named ``br0`` and add ports ``eth0``
443 and ``vif1.0`` to it::
445 $ ovs-vsctl add-br br0
446 $ ovs-vsctl add-port br0 eth0
447 $ ovs-vsctl add-port br0 vif1.0
449 Refer to ovs-vsctl(8) for more details.
454 When you upgrade Open vSwitch from one version to another you should also
455 upgrade the database schema:
457 1. Stop the Open vSwitch daemons, e.g.::
459 $ kill `cd /usr/local/var/run/openvswitch && cat ovsdb-server.pid ovs-vswitchd.pid`
461 2. Install the new Open vSwitch release by using the same configure options as
462 was used for installing the previous version. If you do not use the same
463 configure options, you can end up with two different versions of Open
464 vSwitch executables installed in different locations.
466 3. Upgrade the database, in one of the following two ways:
468 - If there is no important data in your database, then you may delete the
469 database file and recreate it with ovsdb-tool, following the instructions
470 under "Building and Installing Open vSwitch for Linux, FreeBSD or NetBSD".
472 - If you want to preserve the contents of your database, back it up first,
473 then use ``ovsdb-tool convert`` to upgrade it, e.g.::
475 $ ovsdb-tool convert /usr/local/etc/openvswitch/conf.db \
476 vswitchd/vswitch.ovsschema
478 4. Start the Open vSwitch daemons as described under **Starting** above.
483 Upgrading Open vSwitch from one version to the next version with minimum
484 disruption of traffic going through the system that is using that Open vSwitch
485 needs some considerations:
487 1. If the upgrade only involves upgrading the userspace utilities and daemons
488 of Open vSwitch, make sure that the new userspace version is compatible with
489 the previously loaded kernel module.
491 2. An upgrade of userspace daemons means that they have to be restarted.
492 Restarting the daemons means that the OpenFlow flows in the ovs-vswitchd
493 daemon will be lost. One way to restore the flows is to let the controller
494 re-populate it. Another way is to save the previous flows using a utility
495 like ovs-ofctl and then re-add them after the restart. Restoring the old
496 flows is accurate only if the new Open vSwitch interfaces retain the old
499 3. When the new userspace daemons get restarted, they automatically flush the
500 old flows setup in the kernel. This can be expensive if there are hundreds
501 of new flows that are entering the kernel but userspace daemons are busy
502 setting up new userspace flows from either the controller or an utility like
503 ovs-ofctl. Open vSwitch database provides an option to solve this problem
504 through the ``other_config:flow-restore-wait`` column of the
505 ``Open_vSwitch`` table. Refer to the ovs-vswitchd.conf.db(5) manpage for
508 4. If the upgrade also involves upgrading the kernel module, the old kernel
509 module needs to be unloaded and the new kernel module should be loaded. This
510 means that the kernel network devices belonging to Open vSwitch is recreated
511 and the kernel flows are lost. The downtime of the traffic can be reduced if
512 the userspace daemons are restarted immediately and the userspace flows are
513 restored as soon as possible.
515 The ovs-ctl utility's ``restart`` function only restarts the userspace daemons,
516 makes sure that the 'ofport' values remain consistent across restarts, restores
517 userspace flows using the ovs-ofctl utility and also uses the
518 ``other_config:flow-restore-wait`` column to keep the traffic downtime to the
519 minimum. The ovs-ctl utility's ``force-reload-kmod`` function does all of the
520 above, but also replaces the old kernel module with the new one. Open vSwitch
521 startup scripts for Debian, XenServer and RHEL use ovs-ctl's functions and it
522 is recommended that these functions be used for other software platforms too.
529 This section describe Open vSwitch's built-in support for various test
530 suites. You must bootstrap, configure and build Open vSwitch (steps are
531 in "Building and Installing Open vSwitch for Linux, FreeBSD or NetBSD"
532 above) before you run the tests described here. You do not need to
533 install Open vSwitch or to build or load the kernel module to run these
534 test suites. You do not need supervisor privilege to run these test
540 Open vSwitch includes a suite of self-tests. Before you submit patches
541 upstream, we advise that you run the tests and ensure that they pass. If you
542 add new features to Open vSwitch, then adding tests for those features will
543 ensure your features don't break as developers modify other areas of Open
546 To run all the unit tests in Open vSwitch, one at a time, run::
550 This takes under 5 minutes on a modern desktop system.
552 To run all the unit tests in Open vSwitch in parallel, run::
554 $ make check TESTSUITEFLAGS=-j8
556 You can run up to eight threads. This takes under a minute on a modern 4-core
559 To see a list of all the available tests, run:
561 $ make check TESTSUITEFLAGS=--list
563 To run only a subset of tests, e.g. test 123 and tests 477 through 484, run::
565 $ make check TESTSUITEFLAGS='123 477-484'
567 Tests do not have inter-dependencies, so you may run any subset.
569 To run tests matching a keyword, e.g. ``ovsdb``, run::
571 $ make check TESTSUITEFLAGS='-k ovsdb'
573 To see a complete list of test options, run::
575 $ make check TESTSUITEFLAGS=--help
577 The results of a testing run are reported in ``tests/testsuite.log``. Report
578 report test failures as bugs and include the ``testsuite.log`` in your report.
581 Sometimes a few tests may fail on some runs but not others. This is usually a
582 bug in the testsuite, not a bug in Open vSwitch itself. If you find that a
583 test fails intermittently, please report it, since the developers may not
584 have noticed. You can make the testsuite automatically rerun tests that fail,
585 by adding ``RECHECK=yes`` to the ``make`` command line, e.g.::
587 $ make check TESTSUITEFLAGS=-j8 RECHECK=yes
592 If the build was configured with ``--enable-coverage`` and the ``lcov`` utility
593 is installed, you can run the testsuite and generate a code coverage report by
594 using the ``check-lcoc`` target::
598 All the same options are avaiable via TESTSUITEFLAGS. For example::
600 $ make check-lcov TESTSUITEFLAGS=-j8 -k ovn
605 If you have ``valgrind`` installed, you can run the testsuite under
606 valgrind by using the ``check-valgrind`` target::
608 $ make check-valgrind
610 When you do this, the "valgrind" results for test ``<N>`` are reported in files
611 named ``tests/testsuite.dir/<N>/valgrind.*``.
613 All the same options are available via TESTSUITEFLAGS.
616 You may find that the valgrind results are easier to interpret if you put
617 ``-q`` in ``~/.valgrindrc``, since that reduces the amount of output.
624 OFTest is an OpenFlow protocol testing suite. Open vSwitch includes a Makefile
625 target to run OFTest with Open vSwitch in "dummy mode". In this mode of
626 testing, no packets travel across physical or virtual networks. Instead, Unix
627 domain sockets stand in as simulated networks. This simulation is imperfect,
628 but it is much easier to set up, does not require extra physical or virtual
629 hardware, and does not require supervisor privileges.
631 To run OFTest with Open vSwitch, first read and follow the instructions under
632 **Testing** above. Second, obtain a copy of OFTest and install its
633 prerequisites. You need a copy of OFTest that includes commit 406614846c5 (make
634 ovs-dummy platform work again). This commit was merged into the OFTest
635 repository on Feb 1, 2013, so any copy of OFTest more recent than that should
636 work. Testing OVS in dummy mode does not require root privilege, so you may
637 ignore that requirement.
639 Optionally, add the top-level OFTest directory (containing the ``oft`` program)
640 to your ``$PATH``. This slightly simplifies running OFTest later.
642 To run OFTest in dummy mode, run the following command from your Open vSwitch
645 $ make check-oftest OFT=<oft-binary>
647 where ``<oft-binary>`` is the absolute path to the ``oft`` program in OFTest.
648 If you added "oft" to your $PATH, you may omit the OFT variable
651 By default, ``check-oftest`` passes ``oft`` just enough options to enable dummy
652 mode. You can use ``OFTFLAGS`` to pass additional options. For example, to run
653 just the ``basic.Echo`` test instead of all tests (the default) and enable
654 verbose logging, run::
656 $ make check-oftest OFT=<oft-binary> OFTFLAGS='--verbose -T basic.Echo'
658 If you use OFTest that does not include commit 4d1f3eb2c792 (oft: change
659 default port to 6653), merged into the OFTest repository in October 2013, then
660 you need to add an option to use the IETF-assigned controller port::
662 $ make check-oftest OFT=<oft-binary> OFTFLAGS='--port=6653'
664 Interpret OFTest results cautiously. Open vSwitch can fail a given test in
665 OFTest for many reasons, including bugs in Open vSwitch, bugs in OFTest, bugs
666 in the "dummy mode" integration, and differing interpretations of the OpenFlow
667 standard and other standards.
670 Open vSwitch has not been validated against OFTest. Report test failures that
671 you believe to represent bugs in Open vSwitch. Include the precise versions
672 of Open vSwitch and OFTest in your bug report, plus any other information
673 needed to reproduce the problem.
678 Ryu is an OpenFlow controller written in Python that includes an extensive
679 OpenFlow testsuite. Open vSwitch includes a Makefile target to run Ryu in
680 "dummy mode". See **OFTest** above for an explanation of dummy mode.
682 To run Ryu tests with Open vSwitch, first read and follow the instructions
683 under **Testing** above. Second, obtain a copy of Ryu, install its
684 prerequisites, and build it. You do not need to install Ryu (some of the tests
685 do not get installed, so it does not help).
687 To run Ryu tests, run the following command from your Open vSwitch build
690 $ make check-ryu RYUDIR=<ryu-source-dir>``
692 where ``<ryu-source-dir>`` is the absolute path to the root of the Ryu source
693 distribution. The default ``<ryu-source-dir>`` is ``$srcdir/../ryu``
694 where ``$srcdir`` is your Open vSwitch source directory. If this is correct,
698 Open vSwitch has not been validated against Ryu. Report test failures that
699 you believe to represent bugs in Open vSwitch. Include the precise versions
700 of Open vSwitch and Ryu in your bug report, plus any other information
701 needed to reproduce the problem.
706 Open vSwitch includes a suite of tests specifically for datapath functionality,
707 which can be run against the userspace or kernel datapaths. If you are
708 developing datapath features, it is recommended that you use these tests and
709 build upon them to verify your implementation.
711 The datapath tests make some assumptions about the environment. They must be
712 run under root privileges on a Linux system with support for network
713 namespaces. For ease of use, the OVS source tree includes a vagrant box to
714 invoke these tests. Running the tests inside Vagrant provides kernel isolation,
715 protecting your development host from kernel panics or configuration conflicts
716 in the testsuite. If you wish to run the tests without using the vagrant box,
717 there are further instructions below.
724 Requires Vagrant (version 1.7.0 or later) and a compatible hypervisor
727 You must **Bootstrap** and **Configure** the sources before you run the steps
730 A Vagrantfile is provided allowing to compile and provision the source tree as
731 found locally in a virtual machine using the following command::
735 This will bring up a Fedora 23 VM by default. If you wish to use a different
736 box or a vagrant backend not supported by the default box, the ``Vagrantfile``
737 can be modified to use a different box as base.
739 The VM can be reprovisioned at any time::
743 OVS out-of-tree compilation environment can be set up with::
746 $ vagrant provision --provision-with configure_ovs,build_ovs
748 This will set up an out-of-tree build environment inside the VM in
749 ``/root/build``. The source code can be found in ``/vagrant``.
751 To recompile and reinstall OVS in the VM using RPM::
754 $ vagrant provision --provision-with configure_ovs,install_rpm
756 Two provisioners are included to run system tests with the OVS kernel module or
757 with a userspace datapath. This tests are different from the self-tests
758 mentioned above. To run them::
761 $ vagrant provision --provision-with \
762 configure_ovs,test_ovs_kmod,test_ovs_system_userspace
764 The results of the testsuite reside in the VM root user's home directory::
774 The datapath testsuite as invoked by Vagrant above may also be run manually on
775 a Linux system with root privileges. These tests may take several minutes to
776 complete, and cannot be run in parallel.
781 To invoke the datapath testsuite with the userspace datapath, run::
783 $ make check-system-userspace
785 The results of the testsuite are in ``tests/system-userspace-traffic.dir``.
790 Make targets are also provided for testing the Linux kernel module. Note that
791 these tests operate by inserting modules into the running Linux kernel, so if
792 the tests are able to trigger a bug in the OVS kernel module or in the upstream
793 kernel then the kernel may panic.
795 To run the testsuite against the kernel module which is currently installed on
800 To install the kernel module from the current build directory and run the
801 testsuite against that kernel module::
805 The results of the testsuite are in ``tests/system-kmod-traffic.dir``.
807 Continuous Integration with Travis-CI
808 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
810 A .travis.yml file is provided to automatically build Open vSwitch with various
811 build configurations and run the testsuite using travis-ci. Builds will be
812 performed with gcc, sparse and clang with the -Werror compiler flag included,
813 therefore the build will fail if a new warning has been introduced.
815 The CI build is triggered via git push (regardless of the specific branch) or
816 pull request against any Open vSwitch GitHub repository that is linked to
819 Instructions to setup travis-ci for your GitHub repository:
821 1. Go to http://travis-ci.org/ and sign in using your GitHub ID.
822 2. Go to the "Repositories" tab and enable the ovs repository. You may disable
823 builds for pushes or pull requests.
824 3. In order to avoid forks sending build failures to the upstream mailing list,
825 the notification email recipient is encrypted. If you want to receive email
826 notification for build failures, replace the the encrypted string:
828 1. Install the travis-ci CLI (Requires ruby >=2.0): gem install travis
829 2. In your Open vSwitch repository: travis encrypt mylist@mydomain.org
830 3. Add/replace the notifications section in .travis.yml and fill in the
831 secure string as returned by travis encrypt::
839 You may remove/omit the notifications section to fall back to default
840 notification behaviour which is to send an email directly to the author and
841 committer of the failing commit. Note that the email is only sent if the
842 author/committer have commit rights for the particular GitHub repository.
844 4. Pushing a commit to the repository which breaks the build or the
845 testsuite will now trigger a email sent to mylist@mydomain.org
850 Static Analysis is a method of debugging Software by examining code rather than
851 actually executing it. This can be done through 'scan-build' commandline
852 utility which internally uses clang (or) gcc to compile the code and also
853 invokes a static analyzer to do the code analysis. At the end of the build, the
854 reports are aggregated in to a common folder and can later be analyzed using
857 Open vSwitch includes a Makefile target to trigger static code analysis::
860 $ ./configure CC=clang # clang
862 $ ./configure CC=gcc CFLAGS="-std=gnu99" # gcc
865 You should invoke scan-view to view analysis results. The last line of output
866 from ``clang-analyze`` will list the command (containing results directory)
867 that you should invoke to view the results on a browser.
872 Please report problems to bugs@openvswitch.org.