[PATCHv3 1/2] build: define WITH_INTERFACE for the driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Based exclusively on work by Eric Blake in a patch posted with the same
subject. However some modifications related to comments and my plans to
add another backend.

Added WITH_INTERFACE as the only automake variable deciding whether to
build the driver and using WITH_NETCF to identify that we're wanting to
use the netcf library as the backend.

* configure.ac: Added with_interface
* src/interface/netcf_driver.c: Renamed..
* src/interface/interface_backend_netcf.c: ..to this to match storage.
* src/interface/netcf_driver.h: Renamed..
* src/interface/interface_driver.h: ..to this.
* daemon/Makefile.am: Respect WITH_INTERFACE and WITH_NETCF.
* libvirt.spec.in: Add RPM support for --with-interface
---

Change from v2:
* rebase against master
* v2 conditionally ACK'd by Laine if Eric ACK'd it

Change from v1:
* rebased against master
* Fixed copyright header
* Added libvirt.spec.in modification
* Changed virsh -V output


 configure.ac                                       |   33 ++++++++++++++++++-
 daemon/Makefile.am                                 |    2 +-
 daemon/libvirtd.c                                  |    8 ++--
 libvirt.spec.in                                    |   13 ++++---
 src/Makefile.am                                    |   24 +++++++++++---
 .../{netcf_driver.c => interface_backend_netcf.c}  |    2 +-
 .../{netcf_driver.h => interface_driver.h}         |    0
 tests/virdrivermoduletest.c                        |    2 +-
 tools/virsh.c                                      |    5 ++-
 9 files changed, 67 insertions(+), 22 deletions(-)
 rename src/interface/{netcf_driver.c => interface_backend_netcf.c} (99%)
 rename src/interface/{netcf_driver.h => interface_driver.h} (100%)

diff --git a/configure.ac b/configure.ac
index 2090e5f..1a44d21 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1948,7 +1948,6 @@ AM_CONDITIONAL([WITH_NETCF], [test "$with_netcf" = "yes"])
 AC_SUBST([NETCF_CFLAGS])
 AC_SUBST([NETCF_LIBS])
 
-
 AC_ARG_WITH([secrets],
   AC_HELP_STRING([--with-secrets], [with local secrets management driver @<:@default=yes@:>@]),[],[with_secrets=yes])
 
@@ -2787,6 +2786,36 @@ if test "$with_nwfilter" = "yes" ; then
 fi
 AM_CONDITIONAL([WITH_NWFILTER], [test "$with_nwfilter" = "yes"])
 
+dnl check if the interface driver should be compiled
+AC_ARG_WITH([interface],
+  AC_HELP_STRING([--with-interface],
+    [with host interface driver @<:@default=check@:>@]), [],
+    [with_interface=check])
+
+dnl Don't compile the interface driver without libvirtd
+if test "$with_libvirtd" = "no" ; then
+  with_interface=no
+fi
+
+dnl The interface driver depends on the netcf library
+if test "$with_interface:$with_netcf" = "check:yes" ; then
+  with_interface=yes
+fi
+
+if test "$with_interface:$with_netcf" = "check:no" ; then
+  with_interface=no
+fi
+
+if test "$with_interface:$with_netcf" = "yes:no" ; then
+  AC_MSG_ERROR([Requested the Interface driver without netcf support])
+fi
+
+if test "$with_interface" = "yes" ; then
+  AC_DEFINE_UNQUOTED([WITH_INTERFACE], [1],
+    [whether the interface driver is enabled])
+fi
+AM_CONDITIONAL([WITH_INTERFACE], [test "$with_interface" = "yes"])
+
 dnl libblkid is used by several storage drivers; therefore we probe
 dnl for it unconditionally.
 AC_ARG_WITH([libblkid],
@@ -3016,7 +3045,7 @@ AC_MSG_NOTICE([     Test: $with_test])
 AC_MSG_NOTICE([   Remote: $with_remote])
 AC_MSG_NOTICE([  Network: $with_network])
 AC_MSG_NOTICE([ Libvirtd: $with_libvirtd])
-AC_MSG_NOTICE([    netcf: $with_netcf])
+AC_MSG_NOTICE([Interface: $with_interface])
 AC_MSG_NOTICE([  macvtap: $with_macvtap])
 AC_MSG_NOTICE([ virtport: $with_virtualport])
 AC_MSG_NOTICE([])
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index b45349c..3405c67 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -151,7 +151,7 @@ if WITH_NETWORK
     libvirtd_LDADD += ../src/libvirt_driver_network.la
 endif
 
-if WITH_NETCF
+if WITH_INTERFACE
     libvirtd_LDADD += ../src/libvirt_driver_interface.la
 endif
 
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 6973df6..1156bd6 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -78,8 +78,8 @@
 # ifdef WITH_NETWORK
 #  include "network/bridge_driver.h"
 # endif
-# ifdef WITH_NETCF
-#  include "interface/netcf_driver.h"
+# ifdef WITH_INTERFACE
+#  include "interface/interface_driver.h"
 # endif
 # ifdef WITH_STORAGE
 #  include "storage/storage_driver.h"
@@ -382,7 +382,7 @@ static void daemonInitialize(void)
 # ifdef WITH_NWFILTER
     virDriverLoadModule("nwfilter");
 # endif
-# ifdef WITH_NETCF
+# ifdef WITH_INTERFACE
     virDriverLoadModule("interface");
 # endif
 # ifdef WITH_XEN
@@ -404,7 +404,7 @@ static void daemonInitialize(void)
 # ifdef WITH_NETWORK
     networkRegister();
 # endif
-# ifdef WITH_NETCF
+# ifdef WITH_INTERFACE
     interfaceRegister();
 # endif
 # ifdef WITH_STORAGE
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 8c4c08d..853cef7 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -92,6 +92,7 @@
 # A few optional bits off by default, we enable later
 %define with_polkit        0%{!?_without_polkit:0}
 %define with_capng         0%{!?_without_capng:0}
+%define with_interface     0%{!?_without_interface:0}
 %define with_netcf         0%{!?_without_netcf:0}
 %define with_udev          0%{!?_without_udev:0}
 %define with_hal           0%{!?_without_hal:0}
@@ -200,6 +201,12 @@
 %define with_netcf     0%{!?_without_netcf:%{server_drivers}}
 %endif
 
+# interface is the driver that wraps netcf or udev interface management
+# backends in Fedora 18 / RHEL-7 or newer
+%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7
+%define with_interface     0%{!?_without_interface:%{server_drivers}}
+%endif
+
 # udev is used to manage host devices in Fedora 12 / RHEL-6 or newer
 %if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
 %define with_udev     0%{!?_without_udev:%{server_drivers}}
@@ -281,12 +288,6 @@
 %define with_nodedev 0
 %endif
 
-%if %{with_netcf}
-%define with_interface 1
-%else
-%define with_interface 0
-%endif
-
 %if %{with_storage_fs} || %{with_storage_mpath} || %{with_storage_iscsi} || %{with_storage_lvm} || %{with_storage_disk}
 %define with_storage 1
 %else
diff --git a/src/Makefile.am b/src/Makefile.am
index 9f27fcf..4ae741b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -552,8 +552,17 @@ PARALLELS_DRIVER_SOURCES =					\
 NETWORK_DRIVER_SOURCES =					\
 		network/bridge_driver.h network/bridge_driver.c
 
-INTERFACE_DRIVER_SOURCES =					\
-		interface/netcf_driver.h interface/netcf_driver.c
+INTERFACE_DRIVER_SOURCES =
+
+if WITH_INTERFACE
+INTERFACE_DRIVER_SOURCES +=					\
+		interface/interface_driver.h
+endif
+
+if WITH_NETCF
+INTERFACE_DRIVER_SOURCES +=					\
+		interface/interface_backend_netcf.c
+endif
 
 SECRET_DRIVER_SOURCES =						\
 		secret/secret_driver.h secret/secret_driver.c
@@ -1021,7 +1030,7 @@ endif
 EXTRA_DIST += network/default.xml
 
 
-if WITH_NETCF
+if WITH_INTERFACE
 if WITH_DRIVER_MODULES
 mod_LTLIBRARIES += libvirt_driver_interface.la
 else
@@ -1029,10 +1038,13 @@ noinst_LTLIBRARIES += libvirt_driver_interface.la
 # Stateful, so linked to daemon instead
 #libvirt_la_BUILT_LIBADD += libvirt_driver_interface.la
 endif
-libvirt_driver_interface_la_CFLAGS = $(NETCF_CFLAGS) \
-		-I$(top_srcdir)/src/conf $(AM_CFLAGS)
+libvirt_driver_interface_la_CFLAGS = -I$(top_srcdir)/src/conf $(AM_CFLAGS)
 libvirt_driver_interface_la_LDFLAGS = $(AM_LDFLAGS)
-libvirt_driver_interface_la_LIBADD = $(NETCF_LIBS)
+libvirt_driver_interface_la_LIBADD =
+if WITH_NETCF
+libvirt_driver_interface_la_CFLAGS += $(NETCF_CFLAGS)
+libvirt_driver_interface_la_LIBADD += $(NETCF_LIBS)
+endif
 if WITH_DRIVER_MODULES
 libvirt_driver_interface_la_LIBADD += ../gnulib/lib/libgnu.la
 libvirt_driver_interface_la_LDFLAGS += -module -avoid-version
diff --git a/src/interface/netcf_driver.c b/src/interface/interface_backend_netcf.c
similarity index 99%
rename from src/interface/netcf_driver.c
rename to src/interface/interface_backend_netcf.c
index 6e429db..3b4ee11 100644
--- a/src/interface/netcf_driver.c
+++ b/src/interface/interface_backend_netcf.c
@@ -27,7 +27,7 @@
 
 #include "virterror_internal.h"
 #include "datatypes.h"
-#include "netcf_driver.h"
+#include "interface_driver.h"
 #include "interface_conf.h"
 #include "memory.h"
 #include "logging.h"
diff --git a/src/interface/netcf_driver.h b/src/interface/interface_driver.h
similarity index 100%
rename from src/interface/netcf_driver.h
rename to src/interface/interface_driver.h
diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c
index 4d6e91e..8762de4 100644
--- a/tests/virdrivermoduletest.c
+++ b/tests/virdrivermoduletest.c
@@ -79,7 +79,7 @@ mymain(void)
 #ifdef WITH_NWFILTER
     TEST("nwfilter", NULL);
 #endif
-#ifdef WITH_NETCF
+#ifdef WITH_INTERFACE
     TEST("interface", NULL);
 #endif
 #ifdef WITH_QEMU
diff --git a/tools/virsh.c b/tools/virsh.c
index d0b302a..6a7b89d 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2707,8 +2707,11 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
 #ifdef WITH_BRIDGE
     vshPrint(ctl, " Bridging");
 #endif
-#ifdef WITH_NETCF
+#if defined(WITH_INTERFACE)
     vshPrint(ctl, " Interface");
+#if defined(WITH_NETCF)
+    vshPrint(ctl, " netcf");
+#endif
 #endif
 #ifdef WITH_NWFILTER
     vshPrint(ctl, " Nwfilter");
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]