Skip to content

Commit

Permalink
Build OVN using external OVS directory
Browse files Browse the repository at this point in the history
With this patch we have to configure OVN to refer to external OVS source/build
directory instead of the ovs subtree.

The new configuration options added are:
 * --with-ovs-source=/path/to/ovs/source/dir
 * --with-ovs-build=/path/to/ovs/build/dir

Before configuring OVN, user should configure and compile OVS. If the user has
configured OVS on a different directory than the source dir, then 'with-ovs-build'
should be specified.

If ovs-build dir is not defined, then ovs-source is used.

An upcoming patch will delete the ovs subtree.

Example usage:
  $ # Clone OVS repo
  $cd /home/foo/ovs
  $./boot.sh
  $mkdir _gcc
  $cd _gcc && ../configure && cd ..
  $make -C _gcc

  $ # Clone OVN repo
  $cd /home/foo/ovn
  $./boot.sh
  $./configure --with-ovs-source=/home/foo/ovs/ --with-ovs-build=/home/foo/ovs/_gcc
  $make

Acked-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
  • Loading branch information
numansiddique committed Aug 5, 2019
1 parent 04e10d1 commit 93b157f
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 132 deletions.
31 changes: 27 additions & 4 deletions .travis/linux-build.sh
Expand Up @@ -10,7 +10,18 @@ TARGET="x86_64-native-linuxapp-gcc"

function configure_ovs()
{
git clone https://github.com/openvswitch/ovs.git ovs_src
pushd ovs_src
./boot.sh && ./configure $* || { cat config.log; exit 1; }
make -j4
popd
}

function configure_ovn()
{
configure_ovs
./boot.sh && ./configure --with-ovs-source=$PWD/ovs_src $* || \
{ cat config.log; exit 1; }
}

OPTS="$EXTRA_OPTS $*"
Expand All @@ -28,16 +39,28 @@ fi
if [ "$TESTSUITE" ]; then
# 'distcheck' will reconfigure with required options.
# Now we only need to prepare the Makefile without sparse-wrapped CC.
configure_ovs
configure_ovn

export DISTCHECK_CONFIGURE_FLAGS="$OPTS"
export DISTCHECK_CONFIGURE_FLAGS="$OPTS --with-ovs-source=$PWD/ovs_src"
if ! make distcheck -j4 TESTSUITEFLAGS="-j4 -k ovn" RECHECK=yes; then
# testsuite.log is necessary for debugging.
cat */_build/tests/testsuite.log
echo "******** NUMS : echoing 168 result **********"
pwd
ls -l
cat _build/tests/testsuite.dir/168/testsuite.log
echo "******* NUMS : echoing 169 result ***********"
cat tests/testsuite.dir/169/testsuite.log
echo "******* NUMS 3333 : echoing 170 result **********"
cat tests/testsuite.dir/170/testsuite.log
echo "*** NUMS 444 : echoing 171 result *********"
cat tests/testsuite.dir/171/testsuite.log
echo "**** NUMS 5555 : echoing 178 result *********"
cat tests/testsuite.dir/178/testsuite.log
#cat */_build/tests/testsuite.log
exit 1
fi
else
configure_ovs $OPTS
configure_ovn $OPTS
make selinux-policy

make -j4
Expand Down
32 changes: 26 additions & 6 deletions Documentation/intro/install/general.rst
Expand Up @@ -42,9 +42,8 @@ out. This is the right branch for general development.

As of now there are no official OVN releases.

Although building OVN, also builds OVS, it is recommended to clone
and build OVS from its own repo. Please see the Open vSwitch
documentation to build and install OVS.
Before building OVN you should configure and build OVS.
Please see the Open vSwitch documentation to build and install OVS.

.. _general-build-reqs:

Expand Down Expand Up @@ -143,16 +142,24 @@ the "configure" script::

$ ./boot.sh

Before configuring OVN, clone, configure and build Open vSwitch.

.. _general-configuring:

Configuring
-----------

Configure the package by running the configure script. You can usually
invoke configure without any arguments. For example::
Configure the package by running the configure script. You need to
invoke configure with atleast the argument --with-ovs-source.
For example::

$ ./configure --with-ovs-source=/path/to/ovs/source

$ ./configure
If you have built Open vSwitch in a separate directory, then you
need to provide that path in the option - --with-ovs-build.

As of now, OVN uses all the run time directory of Open vSwitch. This
will be changed to ``ovn`` specific directories.
By default all files are installed under ``/usr/local``. OVN and Open vSwitch
also expects to find its database in ``/usr/local/etc/openvswitch`` by default.
If you want to install all files into, e.g., ``/usr`` and ``/var`` instead of
Expand Down Expand Up @@ -272,6 +279,19 @@ you wish to link with jemalloc add it to LIBS::

$ ./configure LIBS=-ljemalloc

Example usage::
$ # Clone OVS repo
$cd /home/foo/ovs
$./boot.sh
$mkdir _gcc
$cd _gcc && ../configure && cd ..
$make -C _gcc

$ # Clone OVN repo
$cd /home/foo/ovn
$./boot.sh
$./configure --with-ovs-source=/home/foo/ovs/ --with-ovs-build=/home/foo/ovs/_gcc

.. _general-building:

Building
Expand Down
24 changes: 10 additions & 14 deletions Makefile.am
Expand Up @@ -7,7 +7,7 @@

AUTOMAKE_OPTIONS = foreign subdir-objects
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = ovs
#SUBDIRS = ovs

OVS_SRCDIR=@ovs_srcdir@
OVS_BUILDDIR=@ovs_builddir@
Expand All @@ -22,9 +22,9 @@ AM_LDFLAGS += $(OVS_LDFLAGS)
AM_CPPFLAGS += -I $(top_srcdir)/include

if WIN32
AM_CPPFLAGS += -I $(top_srcdir)/ovs/include
AM_CPPFLAGS += -I $(top_srcdir)/ovs/lib
AM_CPPFLAGS += -I $(top_srcdir)/ovs
AM_CPPFLAGS += -I $(OVS_SRCDIR)/include
AM_CPPFLAGS += -I $(OVS_SRCDIR)/lib
AM_CPPFLAGS += -I $(OVS_SRCDIR)
AM_CPPFLAGS += -I $(top_srcdir)/lib
AM_CPPFLAGS += $(PTHREAD_INCLUDES)
AM_CPPFLAGS += $(MSVC_CFLAGS)
Expand All @@ -33,6 +33,10 @@ AM_LDFLAGS += $(MSVC64_LDFLAGS)
PLATFORM = $(MSVC_PLATFORM)
endif

AM_CPPFLAGS += -I $(top_srcdir)/include
AM_CPPFLAGS += -I $(top_srcdir)/ovn
AM_CPPFLAGS += -I $(top_builddir)/include

AM_CPPFLAGS += -I $(OVS_SRCDIR)/include
AM_CPPFLAGS += -I $(OVS_BUILDDIR)/include
AM_CPPFLAGS += -I $(OVS_SRCDIR)/lib
Expand Down Expand Up @@ -113,8 +117,7 @@ EXTRA_DIST = \
ovn-nb.ovsschema \
ovn-nb.xml \
ovn-sb.ovsschema \
ovn-sb.xml \
ovs/
ovn-sb.xml
bin_PROGRAMS =
sbin_PROGRAMS =
bin_SCRIPTS =
Expand Down Expand Up @@ -220,13 +223,6 @@ CLEAN_LOCAL += clean-pycov
ALL_LOCAL += dist-hook-git
dist-hook-git: distfiles
@if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then \
(cd ovs && $(MAKE) distfiles); \
(cat distfiles; sed 's|^|ovs/|' ovs/distfiles) | \
LC_ALL=C sort -u > ovs-distfiles; \
(cd ovs/datapath && $(MAKE) distfiles); \
(cat distfiles; sed 's|^|ovs/datapath/|' ovs/datapath/distfiles) | \
LC_ALL=C sort -u > datapath-distfiles; \
LC_ALL=C sort -u ovs-distfiles datapath-distfiles > all-distfiles; \
(cd $(srcdir) && git ls-files) | grep -v '\.gitignore$$' | \
grep -v '\.gitattributes$$' | \
LC_ALL=C sort -u > all-gitfiles; \
Expand All @@ -242,7 +238,7 @@ dist-hook-git: distfiles
exit 1; \
fi \
fi
CLEANFILES += ovs-distfiles datapath-distfiles all-distfiles all-gitfiles missing-distfiles
CLEANFILES += all-distfiles all-gitfiles missing-distfiles
# The following is based on commands for the Automake "distdir" target.
distfiles: Makefile
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
Expand Down
35 changes: 35 additions & 0 deletions acinclude.m4
Expand Up @@ -1206,3 +1206,38 @@ AC_DEFUN([OVS_CHECK_LINUX_HOST],
[ovs_cv_linux=true],
[ovs_cv_linux=false])])
AM_CONDITIONAL([LINUX], [$ovs_cv_linux])])

dnl OVN_CHECK_OVS
dnl
dnl Check for OVS sources
AC_DEFUN([OVN_CHECK_OVS], [
AC_ARG_WITH([ovs-source],
[AC_HELP_STRING([--ovs-source=/path/to/ovs/src/dir],
[Specify the OVS src directory])])
AC_ARG_WITH([ovs-build],
[AC_HELP_STRING([--ovs-build=/path/to/ovs/build/dir],
[Specify the OVS build directory])])
AC_MSG_CHECKING([for OVS source directory])
if test X"$with_ovs_source" != X; then
OVSDIR=$with_ovs_source
else
AC_ERROR([OVS source dir path needs to be specified])
fi
OVSDIR=`eval echo "$OVSDIR"`
AC_MSG_RESULT([$OVSDIR])
AC_SUBST(OVSDIR)
AC_MSG_CHECKING([for OVS build directory])
if test X"$with_ovs_build" != X; then
OVSBUILDDIR=$with_ovs_build
else
# If separate build dir is not specified, use src dir.
OVSBUILDDIR=$OVSDIR
fi
OVSBUILDDIR=`eval echo "$OVSBUILDDIR"`
AC_MSG_RESULT([$OVSBUILDDIR])
AC_SUBST(OVSBUILDDIR)
])
29 changes: 15 additions & 14 deletions configure.ac
Expand Up @@ -20,7 +20,7 @@ AC_CONFIG_HEADERS([config.h])
AC_CONFIG_TESTDIR([tests])
AM_INIT_AUTOMAKE([tar-pax])

AC_CONFIG_SUBDIRS([ovs])
#AC_CONFIG_SUBDIRS([ovs])

AC_PROG_CC_C99
AM_PROG_CC_C_O
Expand Down Expand Up @@ -64,23 +64,17 @@ m4_pattern_forbid([LT_INIT]) dnl Make autoconf fail if libtool is missing.
# the new version. This is the case when symbols have been modified or
# deleted. Bump current, set revision and age to 0.

m4_define([libopenvswitch_lt_current], [0])
m4_define([libopenvswitch_lt_revision], [0])
m4_define([libopenvswitch_lt_age], [0])
m4_define([libovn_lt_current], [0])
m4_define([libovn_lt_revision], [0])
m4_define([libovn_lt_age], [0])

LT_CURRENT=libopenvswitch_lt_current
LT_CURRENT=libovn_lt_current
AC_SUBST([LT_CURRENT])
LT_REVISION=libopenvswitch_lt_revision
LT_REVISION=libovn_lt_revision
AC_SUBST([LT_REVISION])
LT_AGE=libopenvswitch_lt_age
LT_AGE=libovn_lt_age
AC_SUBST([LT_AGE])

AC_SUBST([ovs_srcdir], ['${top_srcdir}/ovs'])
AC_SUBST([ovs_builddir], ['${top_builddir}/ovs'])
AC_SUBST([ovs_libdir], ['${top_builddir}/ovs/lib'])
AC_SUBST([ovsdb_libdir], ['${top_builddir}/ovs/ovsdb'])
AC_SUBST([ovs_mandir], ['${top_srcdir}/ovs/'])

AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([clock_gettime], [rt])
AC_SEARCH_LIBS([timer_create], [rt])
Expand Down Expand Up @@ -187,12 +181,19 @@ OVS_CHECK_LINUX
OVS_CHECK_LINUX_TC
OVS_CHECK_DPDK
OVS_CHECK_PRAGMA_MESSAGE
OVN_CHECK_OVS
AC_SUBST([OVS_CFLAGS])
AC_SUBST([OVS_LDFLAGS])

AC_SUBST([ovs_srcdir], ['${OVSDIR}'])
AC_SUBST([ovs_builddir], ['${OVSBUILDDIR}'])
AC_SUBST([ovs_libdir], ['${OVSBUILDDIR}/lib'])
AC_SUBST([ovsdb_libdir], ['${OVSBUILDDIR}/ovsdb'])
AC_SUBST([ovs_mandir], ['${OVSDIR}'])

AC_CONFIG_FILES(Makefile)
AC_CONFIG_FILES(tests/atlocal)
AC_CONFIG_FILES(ovs/include/openvswitch/version.h)
AC_CONFIG_FILES(include/ovn/version.h)

dnl This makes sure that include/openflow gets created in the build directory.
AC_CONFIG_COMMANDS([include/openflow/openflow.h.stamp])
Expand Down
2 changes: 1 addition & 1 deletion controller-vtep/automake.mk
Expand Up @@ -8,7 +8,7 @@ controller_vtep_ovn_controller_vtep_SOURCES = \
controller-vtep/ovn-controller-vtep.h \
controller-vtep/vtep.c \
controller-vtep/vtep.h
controller_vtep_ovn_controller_vtep_LDADD = lib/libovn.la $(OVS_LIBDIR)/libopenvswitch.la ovs/vtep/libvtep.la
controller_vtep_ovn_controller_vtep_LDADD = lib/libovn.la $(OVS_LIBDIR)/libopenvswitch.la $(OVSBUILDDIR)/vtep/libvtep.la
man_MANS += controller-vtep/ovn-controller-vtep.8
EXTRA_DIST += controller-vtep/ovn-controller-vtep.8.xml
CLEANFILES += controller-vtep/ovn-controller-vtep.8
28 changes: 28 additions & 0 deletions include/ovn/version.h.in
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2014 Nicira, Inc.
* Copyright (c) 2014 Cisco Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef OVN_VERSION_H
#define OVN_VERSION_H 1

#define OVN_PACKAGE_STRING "@PACKAGE_STRING@"
#define OVN_PACKAGE_VERSION "@PACKAGE_VERSION@"

#define OVN_LIB_VERSION @LT_CURRENT@
#define OVN_LIB_REVISION @LT_REVISION@
#define OVN_LIB_AGE @LT_AGE@

#endif /* ovn/version.h */
7 changes: 1 addition & 6 deletions lib/ovsdb_automake.mk
@@ -1,10 +1,6 @@
# ovsdb-idlc
noinst_SCRIPTS += ovs/ovsdb/ovsdb-idlc
EXTRA_DIST += ovs/ovsdb/ovsdb-idlc.in
MAN_ROOTS += ovs/ovsdb/ovsdb-idlc.1
CLEANFILES += ovs/ovsdb/ovsdb-idlc
SUFFIXES += .ovsidl .ovsschema
OVSDB_IDLC = $(run_python) $(srcdir)/ovs/ovsdb/ovsdb-idlc.in
OVSDB_IDLC = $(run_python) ${OVSDIR}/ovsdb/ovsdb-idlc.in
.ovsidl.c:
$(AM_V_GEN)$(OVSDB_IDLC) c-idl-source $< > $@.tmp && mv $@.tmp $@
.ovsidl.h:
Expand All @@ -21,5 +17,4 @@ CLEANFILES += $(OVSIDL_BUILT)
# However, current versions of Automake seem to output all variable
# assignments before any targets, so it doesn't seem to be a problem,
# at least for now.
$(OVSIDL_BUILT): ovs/ovsdb/ovsdb-idlc.in

6 changes: 3 additions & 3 deletions tests/automake.mk
Expand Up @@ -51,10 +51,10 @@ SYSTEM_KMOD_TESTSUITE = $(srcdir)/tests/system-kmod-testsuite
SYSTEM_USERSPACE_TESTSUITE = $(srcdir)/tests/system-userspace-testsuite
DISTCLEANFILES += tests/atconfig tests/atlocal

AUTOTEST_PATH = ovs/utilities:ovs/vswitchd:ovs/ovsdb:ovs/vtep:tests:$(PTHREAD_WIN32_DIR_DLL):$(SSL_DIR):controller-vtep:northd:utilities:controller
AUTOTEST_PATH = $(ovs_builddir)/utilities:$(ovs_builddir)/vswitchd:$(ovs_builddir)/ovsdb:$(ovs_builddir)/vtep:tests:$(PTHREAD_WIN32_DIR_DLL):$(SSL_DIR):controller-vtep:northd:utilities:controller

check-local:
set $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH); \
set $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) ovs_srcdir=$(ovs_srcdir); \
"$$@" $(TESTSUITEFLAGS) || (test X'$(RECHECK)' = Xyes && "$$@" --recheck)

# Python Coverage support.
Expand Down Expand Up @@ -230,7 +230,7 @@ tests/testpki-req2.pem: tests/pki/stamp
tests/testpki-privkey2.pem: tests/pki/stamp
$(AM_V_GEN)cp tests/pki/test2-privkey.pem $@

OVS_PKI = $(SHELL) $(srcdir)/ovs/utilities/ovs-pki.in --dir=tests/pki --log=tests/ovs-pki.log
OVS_PKI = $(SHELL) $(ovs_srcdir)/utilities/ovs-pki.in --dir=tests/pki --log=tests/ovs-pki.log
tests/pki/stamp:
$(AM_V_at)rm -f tests/pki/stamp
$(AM_V_at)rm -rf tests/pki
Expand Down
4 changes: 2 additions & 2 deletions tests/ofproto-macros.at
Expand Up @@ -91,7 +91,7 @@ sim_add () {

# Create database and start ovsdb-server.
: > "$d"/.conf.db.~lock~
as $1 ovsdb-tool create "$d"/conf.db "$abs_top_srcdir"/ovs/vswitchd/vswitch.ovsschema || return 1
as $1 ovsdb-tool create "$d"/conf.db "$ovs_srcdir"/vswitchd/vswitch.ovsschema || return 1
as $1 start_daemon ovsdb-server --remote=punix:"$d"/db.sock || return 1

# Initialize database.
Expand Down Expand Up @@ -322,7 +322,7 @@ m4_define([TESTABLE_LOG], [-vPATTERN:ANY:'%c|%p|%m'])
m4_define([_OVS_VSWITCHD_START],
[dnl Create database.
touch .conf.db.~lock~
AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/ovs/vswitchd/vswitch.ovsschema])
AT_CHECK([ovsdb-tool create conf.db $ovs_srcdir/vswitchd/vswitch.ovsschema])

dnl Start ovsdb-server.
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
Expand Down
4 changes: 2 additions & 2 deletions tests/ovn-controller-vtep.at
Expand Up @@ -18,11 +18,11 @@ m4_define([OVN_CONTROLLER_VTEP_START],
AT_SKIP_IF([test $HAVE_PYTHON = no])

dnl Create databases (ovn-nb, ovn-sb, vtep).
AT_CHECK([ovsdb-tool create vswitchd.db $abs_top_srcdir/ovs/vswitchd/vswitch.ovsschema])
AT_CHECK([ovsdb-tool create vswitchd.db $ovs_srcdir/vswitchd/vswitch.ovsschema])
for daemon in ovn-nb ovn-sb; do
AT_CHECK([ovsdb-tool create $daemon.db $abs_top_srcdir/${daemon}.ovsschema])
done
AT_CHECK([ovsdb-tool create vtep.db $abs_top_srcdir/ovs/vtep/vtep.ovsschema])
AT_CHECK([ovsdb-tool create vtep.db $ovs_srcdir/vtep/vtep.ovsschema])

dnl Start ovsdb-server.
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock vswitchd.db vtep.db], [0], [], [stderr])
Expand Down

0 comments on commit 93b157f

Please sign in to comment.