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

Re: [libvirt] PATCH: 2/4: Restructure sources files in Makefile.am



Over time we've added lots of general purpose source code files, as wel
as making more of the existing ones conditionally compiled. We've done
this by adding lots of #ifdef WITH_XXXX  macros across the various
source files.  This is becoming rather a minefield with soo many conditionals
sprinkled throughout the code.

With all the recent re-factoring we now have very good separation between
generic code, and driver specific code - each typically being in separate
files. Thus it is now practical to remove the vast majority of the macros
and just do the conditional compilation via the Makefile.am. 

The patch is not entirely clear - the resulting Makefile.am is much easier
to review. It is structured in two section, first we declare variables
for groups of source code files - eg generic helper files, generic domain
XML files, generic network XML files, and then per-driver files.



  # These files are not related to driver APIs. Simply generic
  # helper APIs for various purposes
  GENERIC_LIB_SOURCES =                                         \
                bridge.c bridge.h                               \
                buf.c buf.h                                     \
                conf.c conf.h                                   \
                event.c event.h                                 \
                iptables.c iptables.h                           \
                memory.c memory.h                               \
                qparams.c qparams.h                             \
                stats_linux.c stats_linux.h                     \
                uuid.c uuid.h                                   \
                util.c util.h                                   \
                virterror.c                                     \
                xml.c xml.h

  # Domain driver generic impl APIs
  DOMAIN_CONF_SOURCES =                                         \
                capabilities.c capabilities.h                   \
                domain_conf.c domain_conf.h                     \
                nodeinfo.h nodeinfo.c

  # Network driver generic impl APIs
  NETWORK_CONF_SOURCES =                                        \
                network_conf.c network_conf.h

  # Storage driver generic impl APIs
  STORAGE_CONF_SOURCES =                                        \
                storage_conf.h storage_conf.c


  # The remote RPC driver, covering domains, storage, networks, etc
  REMOTE_DRIVER_SOURCES =                                       \
                gnutls_1_0_compat.h                             \
                remote_internal.c remote_internal.h             \
                ../qemud/remote_protocol.c                      \
                ../qemud/remote_protocol.h                      \
                socketcompat.h

  # Mock driver, covering domains, storage, networks, etc
  TEST_DRIVER_SOURCES =                                         \
                test.c test.h

  # Now the Hypervisor specific drivers
  XEN_DRIVER_SOURCES =                                          \
                proxy_internal.c proxy_internal.h               \
                sexpr.c sexpr.h                                 \
                xen_internal.c xen_internal.h                   \
                xen_unified.c xen_unified.h                     \
                xend_internal.c xend_internal.h                 \
                xm_internal.c xm_internal.h                     \
                xs_internal.c xs_internal.h


In the second section we then build up the libvirt_la_SOURCES variable,
conditionally adding the driver specific sources according to what the
user asked 'configure' to build

  libvirt_la_SOURCES =                                          \
                driver.h                                        \
                hash.c hash.h                                   \
                internal.h                                      \
                libvirt.c                                       \
                $(GENERIC_LIB_SOURCES)                          \
                $(DOMAIN_CONF_SOURCES)                          \
                $(NETWORK_CONF_SOURCES)                         \
                $(STORAGE_CONF_SOURCES)

  # Drivers usable outside daemon context
  if WITH_TEST
  libvirt_la_SOURCES += $(TEST_DRIVER_SOURCES)
  endif

  if WITH_REMOTE
  libvirt_la_SOURCES += $(REMOTE_DRIVER_SOURCES)
  endif

  if WITH_XEN
  libvirt_la_SOURCES += $(XEN_DRIVER_SOURCES)
  endif


I've cut this down - the real makefile covers all drivers.

Finally we also add all the sources to EXTRA_DIST, so that if someone
does 'make dist', they include all the source files regardless of what
has been configured to build.


In removing the unneeded WITH_XXX macros from header/sources I noticed that
a bunch of our header files have

  #ifdef __cplusplus
  extern "C" {
  #endif

With is irrelevant since we're not using C++ anywhere - indeed some of the
files even had the corresponding '}'  missing, so clearly this is never
actually used during compilation. Removing this fixes bogus indentation
in some of the header files

I've tested this all by running configure --without-XXX for each hypervisor
driver in turn, and it seemed to work in all cases. The only thing I didn't
test is MinGW. I think I really need to add a MinGW based build to the 
nightly build system, so we can sanity check that nightly

 configure.in          |   15 ++-
 qemud/Makefile.am     |   46 ++++++----
 src/Makefile.am       |  212 ++++++++++++++++++++++++++++++++++++--------------
 src/bridge.c          |    4 
 src/bridge.h          |    4 
 src/conf.h            |    7 -
 src/console.h         |   10 --
 src/driver.h          |    7 -
 src/hash.h            |    7 -
 src/internal.h        |    7 -
 src/libvirt.c         |   21 +++-
 src/lxc_conf.c        |    3 
 src/lxc_conf.h        |    3 
 src/lxc_container.c   |    3 
 src/lxc_container.h   |    4 
 src/lxc_driver.c      |    4 
 src/lxc_driver.h      |    4 
 src/nodeinfo.h        |   10 --
 src/openvz_conf.c     |    3 
 src/openvz_driver.c   |    3 
 src/proxy_internal.c  |    4 
 src/proxy_internal.h  |    7 -
 src/qemu_conf.c       |    4 
 src/qemu_conf.h       |    4 
 src/qemu_driver.c     |    3 
 src/qemu_driver.h     |    4 
 src/remote_internal.h |    8 -
 src/test.c            |    6 -
 src/test.h            |    7 -
 src/veth.c            |    4 
 src/xen_internal.c    |    3 
 src/xen_internal.h    |    8 -
 src/xen_unified.c     |    3 
 src/xen_unified.h     |    9 --
 src/xend_internal.c   |    2 
 src/xend_internal.h   |    4 
 src/xm_internal.c     |    2 
 src/xs_internal.c     |    3 
 src/xs_internal.h     |    7 -
 tests/testutils.h     |   44 ++++------
 40 files changed, 237 insertions(+), 276 deletions(-)

Daniel

diff -r b6d8ebb28723 configure.in
--- a/configure.in	Tue Aug 12 22:21:25 2008 +0100
+++ b/configure.in	Tue Aug 12 22:21:47 2008 +0100
@@ -241,27 +241,35 @@
 LIBVIRT_FEATURES=
 WITH_XEN=0
 
-if test "$with_openvz" = "yes" ; then
+if test "$with_openvz" = "yes"; then
     LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_OPENVZ"
 fi
+AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"])
+
 if test "$with_lxc" = "yes" ; then
     LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_LXC"
 fi
+AM_CONDITIONAL([WITH_LXC], [test "$with_lxc" = "yes"])
+
 if test "$with_qemu" = "yes" ; then
     LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_QEMU"
 fi
+AM_CONDITIONAL([WITH_QEMU], [test "$with_qemu" = "yes"])
 
 if test "$with_test" = "yes" ; then
     LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_TEST"
 fi
+AM_CONDITIONAL([WITH_TEST], [test "$with_test" = "yes"])
 
 if test "$with_remote" = "yes" ; then
     LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_REMOTE"
 fi
+AM_CONDITIONAL([WITH_REMOTE], [test "$with_remote" = "yes"])
 
 if test "$with_libvirtd" = "yes" ; then
     LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_LIBVIRTD"
 fi
+AM_CONDITIONAL([WITH_LIBVIRTD], [test "$with_libvirtd" = "yes"])
 
 if test "$with_xen" = "yes" ; then
     dnl search for the Xen store library
@@ -294,11 +302,12 @@
 #include <xen/xen.h>
 ])
 fi
+AM_CONDITIONAL([WITH_XEN], [test "$WITH_XEN" = "1"])
 
 dnl
-dnl check for kernel headers required by qemud/bridge.c
+dnl check for kernel headers required by src/bridge.c
 dnl
-if test "$with_qemu" = "yes" ; then
+if test "$with_qemu" = "yes" -o "$with_lxc" = "yes" ; then
   AC_CHECK_HEADERS([linux/param.h linux/sockios.h linux/if_bridge.h linux/if_tun.h],,
                    AC_MSG_ERROR([You must install kernel-headers in order to compile libvirt]))
 fi
diff -r b6d8ebb28723 qemud/Makefile.am
--- a/qemud/Makefile.am	Tue Aug 12 22:21:25 2008 +0100
+++ b/qemud/Makefile.am	Tue Aug 12 22:21:47 2008 +0100
@@ -2,19 +2,30 @@
 
 INCLUDES = $(LIBVIRT_FEATURES)
 
-# Distribute the generated files so that rpcgen isn't required on the
-# target machine (although almost any Unix machine will have it).
-EXTRA_DIST = libvirtd.init.in libvirtd.sysconf default-network.xml \
-	remote_protocol.x \
-	remote_protocol.c remote_protocol.h \
-	remote_generate_stubs.pl rpcgen_fix.pl \
-	remote_dispatch_prototypes.h \
-	remote_dispatch_localvars.h \
-	remote_dispatch_proc_switch.h \
-	mdns.c mdns.h \
-        libvirtd.sasl \
-        libvirtd.conf \
-        libvirtd.policy
+DAEMON_SOURCES =					\
+		event.c event.h				\
+		qemud.c qemud.h				\
+		remote.c				\
+		remote_dispatch_prototypes.h		\
+		remote_dispatch_localvars.h		\
+		remote_dispatch_proc_switch.h		\
+		remote_protocol.h remote_protocol.c	\
+		$(srcdir)/../src/util-lib.c
+
+AVAHI_SOURCES =						\
+		mdns.c mdns.h
+
+EXTRA_DIST =						\
+	default-network.xml				\
+	remote_generate_stubs.pl rpcgen_fix.pl		\
+	remote_protocol.x				\
+	libvirtd.conf					\
+	libvirtd.init.in				\
+	libvirtd.policy					\
+	libvirtd.sasl					\
+	libvirtd.sysconf				\
+	$(AVAHI_SOURCES)				\
+	$(DAEMON_SOURCES)
 
 if RPCGEN
 SUFFIXES = .x
@@ -45,12 +56,7 @@
 confdir = $(sysconfdir)/libvirt/
 conf_DATA = libvirtd.conf
 
-libvirtd_SOURCES = \
-		qemud.c qemud.h \
-		remote_protocol.h remote_protocol.c \
-		remote.c \
-		$(srcdir)/../src/util-lib.c \
-		event.c event.h
+libvirtd_SOURCES = $(DAEMON_SOURCES)
 
 #-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L
 libvirtd_CFLAGS = \
@@ -79,7 +85,7 @@
 endif
 
 if HAVE_AVAHI
-libvirtd_SOURCES += mdns.c mdns.h
+libvirtd_SOURCES += $(AVAHI_SOURCES)
 libvirtd_CFLAGS += $(AVAHI_CFLAGS)
 libvirtd_LDADD += $(AVAHI_LIBS)
 endif
diff -r b6d8ebb28723 src/Makefile.am
--- a/src/Makefile.am	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/Makefile.am	Tue Aug 12 22:21:47 2008 +0100
@@ -30,80 +30,176 @@
 
 lib_LTLIBRARIES = libvirt.la
 
-CLIENT_SOURCES =						\
-		libvirt.c internal.h				\
+# These files are not related to driver APIs. Simply generic
+# helper APIs for various purposes
+GENERIC_LIB_SOURCES =						\
+		bridge.c bridge.h				\
+		buf.c buf.h					\
+		conf.c conf.h					\
+		event.c event.h					\
+		iptables.c iptables.h				\
+		memory.c memory.h				\
+		qparams.c qparams.h				\
+		stats_linux.c stats_linux.h			\
+		uuid.c uuid.h					\
+		util.c util.h					\
+		virterror.c					\
+		xml.c xml.h
+
+# Domain driver generic impl APIs
+DOMAIN_CONF_SOURCES =						\
+		capabilities.c capabilities.h			\
+		domain_conf.c domain_conf.h			\
+		nodeinfo.h nodeinfo.c
+
+# Network driver generic impl APIs
+NETWORK_CONF_SOURCES =						\
+		network_conf.c network_conf.h
+
+# Storage driver generic impl APIs
+STORAGE_CONF_SOURCES =						\
+		storage_conf.h storage_conf.c
+
+
+# The remote RPC driver, covering domains, storage, networks, etc
+REMOTE_DRIVER_SOURCES =						\
 		gnutls_1_0_compat.h				\
-		socketcompat.h					\
-                memory.c memory.h				\
-		hash.c hash.h					\
-		test.c test.h                                   \
-                buf.c buf.h					\
-		qparams.c qparams.h				\
-                domain_conf.c domain_conf.h                     \
-                capabilities.c capabilities.h			\
-		xml.c xml.h					\
-		event.c event.h					\
+		remote_internal.c remote_internal.h		\
+		../qemud/remote_protocol.c			\
+		../qemud/remote_protocol.h			\
+		socketcompat.h
+
+# Mock driver, covering domains, storage, networks, etc
+TEST_DRIVER_SOURCES =						\
+		test.c test.h
+
+
+
+# Now the Hypervisor specific drivers
+XEN_DRIVER_SOURCES =						\
+		proxy_internal.c proxy_internal.h		\
+		sexpr.c sexpr.h					\
+		xen_internal.c xen_internal.h			\
 		xen_unified.c xen_unified.h			\
-		xen_internal.c xen_internal.h			\
-		xs_internal.c xs_internal.h			\
 		xend_internal.c xend_internal.h			\
-		stats_linux.c stats_linux.h			\
-		sexpr.c sexpr.h					\
-		virterror.c					\
-		driver.h					\
-		proxy_internal.c proxy_internal.h		\
-		conf.c conf.h                                   \
-		network_conf.c network_conf.h                   \
-		xm_internal.c xm_internal.h                     \
-		remote_internal.c remote_internal.h		\
-		bridge.c bridge.h				\
-		iptables.c iptables.h				\
-		uuid.c uuid.h					\
-		qemu_driver.c qemu_driver.h			\
-		qemu_conf.c qemu_conf.h				\
-		openvz_conf.c openvz_conf.h			\
-		openvz_driver.c openvz_driver.h			\
-		lxc_driver.c lxc_driver.h			\
-		lxc_controller.c lxc_controller.h		\
+		xm_internal.c xm_internal.h			\
+		xs_internal.c xs_internal.h
+
+LXC_DRIVER_SOURCES =						\
 		lxc_conf.c lxc_conf.h				\
 		lxc_container.c lxc_container.h			\
-		veth.c veth.h			\
-                nodeinfo.h nodeinfo.c                           \
-		util.c util.h
+		lxc_controller.c lxc_controller.h		\
+		lxc_driver.c lxc_driver.h			\
+		veth.c veth.h
 
-SERVER_SOURCES =						\
-		../qemud/remote_protocol.c ../qemud/remote_protocol.h
+OPENVZ_DRIVER_SOURCES =						\
+		openvz_conf.c openvz_conf.h			\
+		openvz_driver.c openvz_driver.h
 
-if WITH_LIBVIRTD
+# XXX network driver should be split out of this
+QEMU_DRIVER_SOURCES =						\
+		qemu_conf.c qemu_conf.h				\
+		qemu_driver.c qemu_driver.h
 
-CLIENT_SOURCES += 						\
-		storage_conf.h storage_conf.c			\
+
+# And finally storage backend specific impls
+STORAGE_DRIVER_SOURCES =					\
 		storage_driver.h storage_driver.c		\
-		storage_backend.h storage_backend.c		\
+		storage_backend.h storage_backend.c
+
+STORAGE_DRIVER_FS_SOURCES =					\
 		storage_backend_fs.h storage_backend_fs.c
 
+STORAGE_DRIVER_LVM_SOURCES =					\
+		storage_backend_logical.h 			\
+		storage_backend_logical.c
+
+STORAGE_DRIVER_ISCSI_SOURCES =					\
+		storage_backend_iscsi.h storage_backend_iscsi.c
+
+STORAGE_DRIVER_DISK_SOURCES =					\
+		storage_backend_disk.h storage_backend_disk.c
+
+STORAGE_HELPER_DISK_SOURCES =					\
+		parthelper.c
+
+
+
+#########################
+#
+# Build up list of libvirt.la source files based on configure conditions
+#
+# First deal with sources usable in non-daemon context
+
+libvirt_la_SOURCES =						\
+		driver.h					\
+		hash.c hash.h					\
+		internal.h					\
+		libvirt.c					\
+		$(GENERIC_LIB_SOURCES)				\
+		$(DOMAIN_CONF_SOURCES)				\
+		$(NETWORK_CONF_SOURCES)				\
+		$(STORAGE_CONF_SOURCES)
+
+# Drivers usable outside daemon context
+if WITH_TEST
+libvirt_la_SOURCES += $(TEST_DRIVER_SOURCES)
+endif
+
+if WITH_REMOTE
+libvirt_la_SOURCES += $(REMOTE_DRIVER_SOURCES)
+endif
+
+if WITH_XEN
+libvirt_la_SOURCES += $(XEN_DRIVER_SOURCES)
+endif
+
+
+# Drivers usable inside daemon context
+if WITH_LIBVIRTD
+libvirt_la_SOURCES += $(STORAGE_DRIVER_SOURCES)
+libvirt_la_SOURCES += $(STORAGE_DRIVER_FS_SOURCES)
+
+if WITH_QEMU
+libvirt_la_SOURCES += $(QEMU_DRIVER_SOURCES)
+endif
+
+if WITH_LXC
+libvirt_la_SOURCES += $(LXC_DRIVER_SOURCES)
+endif
+
+if WITH_OPENVZ
+libvirt_la_SOURCES += $(OPENVZ_DRIVER_SOURCES)
+endif
+
 if WITH_STORAGE_LVM
-CLIENT_SOURCES += storage_backend_logical.h storage_backend_logical.c
-else
-EXTRA_DIST += storage_backend_logical.h storage_backend_logical.c
+libvirt_la_SOURCES += $(STORAGE_DRIVER_LVM_SOURCES)
 endif
 
 if WITH_STORAGE_ISCSI
-CLIENT_SOURCES +=  storage_backend_iscsi.h storage_backend_iscsi.c
-else
-EXTRA_DIST +=  storage_backend_iscsi.h storage_backend_iscsi.c
+libvirt_la_SOURCES += $(STORAGE_DRIVER_ISCSI_SOURCES)
 endif
 
 if WITH_STORAGE_DISK
-CLIENT_SOURCES += storage_backend_disk.h storage_backend_disk.c
-else
-EXTRA_DIST += storage_backend_disk.h storage_backend_disk.c
+libvirt_la_SOURCES += $(STORAGE_DRIVER_DISK_SOURCES)
+endif
 endif
 
-endif
+# Add all conditional sources just in case...
+EXTRA_DIST +=							\
+		$(TEST_DRIVER_SOURCES)				\
+		$(REMOTE_DRIVER_SOURCES)			\
+		$(XEN_DRIVER_SOURCES)				\
+		$(QEMU_DRIVER_SOURCES)				\
+		$(LXC_DRIVER_SOURCES)				\
+		$(OPENVZ_DRIVER_SOURCES)			\
+		$(STORAGE_DRIVER_SOURCES)			\
+		$(STORAGE_DRIVER_FS_SOURCES)			\
+		$(STORAGE_DRIVER_LVM_SOURCES)			\
+		$(STORAGE_DRIVER_ISCSI_SOURCES)			\
+		$(STORAGE_DRIVER_DISK_SOURCES)
 
 
-libvirt_la_SOURCES = $(CLIENT_SOURCES) $(SERVER_SOURCES)
 libvirt_la_LIBADD = $(LIBXML_LIBS) $(GNUTLS_LIBS) $(SASL_LIBS) $(SELINUX_LIBS) \
                     $(NUMACTL_LIBS) \
 		    @CYGWIN_EXTRA_LIBADD@ ../gnulib/lib/libgnu.la
@@ -134,7 +230,11 @@
 
 bin_PROGRAMS = virsh
 
-virsh_SOURCES = virsh.c console.c console.h util-lib.c util-lib.h
+virsh_SOURCES =							\
+		console.c console.h				\
+		util-lib.c util-lib.h				\
+		virsh.c
+
 virsh_LDFLAGS = $(WARN_CFLAGS) $(COVERAGE_LDFLAGS)
 virsh_DEPENDENCIES = $(DEPS)
 virsh_LDADD = $(LDADDS) $(VIRSH_LIBS)
@@ -176,14 +276,14 @@
 if WITH_LIBVIRTD
 libexec_PROGRAMS = libvirt_parthelper
 
-libvirt_parthelper_SOURCES = parthelper.c
+libvirt_parthelper_SOURCES = $(STORAGE_HELPER_DISK_SOURCES)
 libvirt_parthelper_LDFLAGS = $(WARN_CFLAGS) $(COVERAGE_LDCFLAGS)
 libvirt_parthelper_LDADD = $(LIBPARTED_LIBS)
 libvirt_parthelper_CFLAGS =  $(LIBPARTED_CFLAGS)
 endif
-else
-EXTRA_DIST += parthelper.c
 endif
+EXTRA_DIST += $(STORAGE_HELPER_DISK_SOURCES)
+
 
 # Create the /var/cache/libvirt directory when installing.
 install-exec-local:
diff -r b6d8ebb28723 src/bridge.c
--- a/src/bridge.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/bridge.c	Tue Aug 12 22:21:47 2008 +0100
@@ -21,7 +21,7 @@
 
 #include <config.h>
 
-#ifdef WITH_QEMU
+#if defined(WITH_QEMU) || defined(WITH_LXC)
 
 #include "bridge.h"
 
@@ -721,4 +721,4 @@
     return retval;
 }
 
-#endif /* WITH_QEMU */
+#endif /* WITH_QEMU || WITH_LXC */
diff -r b6d8ebb28723 src/bridge.h
--- a/src/bridge.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/bridge.h	Tue Aug 12 22:21:47 2008 +0100
@@ -24,7 +24,7 @@
 
 #include <config.h>
 
-#ifdef WITH_QEMU
+#if defined(WITH_QEMU) || defined(WITH_LXC)
 
 #include <net/if.h>
 #include <netinet/in.h>
@@ -98,6 +98,6 @@
                                  const char *bridge,
                                  int *enable);
 
-#endif /* WITH_QEMU */
+#endif /* WITH_QEMU || WITH_LXC */
 
 #endif /* __QEMUD_BRIDGE_H__ */
diff -r b6d8ebb28723 src/conf.h
--- a/src/conf.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/conf.h	Tue Aug 12 22:21:47 2008 +0100
@@ -10,10 +10,6 @@
 
 #ifndef __VIR_CONF_H__
 #define __VIR_CONF_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 /**
  * virConfType:
@@ -93,7 +89,4 @@
 #define virConfWriteFile(f,c) __virConfWriteFile((f),(c))
 #define virConfWriteMem(m,l,c) __virConfWriteMem((m),(l),(c))
 
-#ifdef __cplusplus
-}
-#endif
 #endif /* __VIR_CONF_H__ */
diff -r b6d8ebb28723 src/console.h
--- a/src/console.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/console.h	Tue Aug 12 22:21:47 2008 +0100
@@ -25,15 +25,7 @@
 
 #ifndef __MINGW32__
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-    int vshRunConsole(const char *tty);
-
-#ifdef __cplusplus
-}
-#endif
+int vshRunConsole(const char *tty);
 
 #endif /* !__MINGW32__ */
 
diff -r b6d8ebb28723 src/driver.h
--- a/src/driver.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/driver.h	Tue Aug 12 22:21:47 2008 +0100
@@ -12,10 +12,6 @@
 #include <libxml/uri.h>
 
 #include <signal.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 /*
  * List of registered drivers numbers
@@ -611,7 +607,4 @@
 int virRegisterStateDriver(virStateDriverPtr);
 #endif
 
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
 #endif /* __VIR_DRIVER_H__ */
diff -r b6d8ebb28723 src/hash.h
--- a/src/hash.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/hash.h	Tue Aug 12 22:21:47 2008 +0100
@@ -11,10 +11,6 @@
 
 #ifndef __VIR_HASH_H__
 #define __VIR_HASH_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 /*
  * The hash table.
@@ -90,7 +86,4 @@
 int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, virHashDeallocator f, const void *data);
 void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *data);
 
-#ifdef __cplusplus
-}
-#endif
 #endif                          /* ! __VIR_HASH_H__ */
diff -r b6d8ebb28723 src/internal.h
--- a/src/internal.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/internal.h	Tue Aug 12 22:21:47 2008 +0100
@@ -37,10 +37,6 @@
 #include "libvirt/libvirt.h"
 #include "libvirt/virterror.h"
 #include "driver.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 /* On architectures which lack these limits, define them (ie. Cygwin).
  * Note that the libvirt code should be robust enough to handle the
@@ -366,7 +362,4 @@
 int __virDomainMigratePerform (virDomainPtr domain, const char *cookie, int cookielen, const char *uri, unsigned long flags, const char *dname, unsigned long bandwidth);
 virDomainPtr __virDomainMigrateFinish (virConnectPtr dconn, const char *dname, const char *cookie, int cookielen, const char *uri, unsigned long flags);
 
-#ifdef __cplusplus
-}
-#endif                          /* __cplusplus */
 #endif                          /* __VIR_INTERNAL_H__ */
diff -r b6d8ebb28723 src/libvirt.c
--- a/src/libvirt.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/libvirt.c	Tue Aug 12 22:21:47 2008 +0100
@@ -36,17 +36,26 @@
 
 #include "uuid.h"
 #include "util.h"
+
+#ifdef WITH_TEST
 #include "test.h"
+#endif
+#ifdef WITH_XEN
 #include "xen_unified.h"
+#endif
+#ifdef WITH_REMOTE
 #include "remote_internal.h"
+#endif
+#ifdef WITH_QEMU
 #include "qemu_driver.h"
-#include "storage_driver.h"
+#endif
 #ifdef WITH_OPENVZ
 #include "openvz_driver.h"
 #endif
 #ifdef WITH_LXC
 #include "lxc_driver.h"
 #endif
+#include "storage_driver.h"
 
 /*
  * TODO:
@@ -273,23 +282,23 @@
 #ifdef WITH_TEST
     if (testRegister() == -1) return -1;
 #endif
+#ifdef WITH_XEN
+    if (xenUnifiedRegister () == -1) return -1;
+#endif
+#ifdef WITH_LIBVIRTD
 #ifdef WITH_QEMU
     if (qemudRegister() == -1) return -1;
 #endif
-#ifdef WITH_XEN
-    if (xenUnifiedRegister () == -1) return -1;
-#endif
 #ifdef WITH_OPENVZ
     if (openvzRegister() == -1) return -1;
 #endif
 #ifdef WITH_LXC
     if (lxcRegister() == -1) return -1;
 #endif
-#ifdef WITH_LIBVIRTD
     if (storageRegister() == -1) return -1;
-#endif
 #ifdef WITH_REMOTE
     if (remoteRegister () == -1) return -1;
+#endif
 #endif
 
     return(0);
diff -r b6d8ebb28723 src/lxc_conf.c
--- a/src/lxc_conf.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/lxc_conf.c	Tue Aug 12 22:21:47 2008 +0100
@@ -24,8 +24,6 @@
 
 /* includes */
 #include <config.h>
-
-#ifdef WITH_LXC
 
 #include <sys/utsname.h>
 
@@ -111,4 +109,3 @@
 }
 
 
-#endif /* WITH_LXC */
diff -r b6d8ebb28723 src/lxc_conf.h
--- a/src/lxc_conf.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/lxc_conf.h	Tue Aug 12 22:21:47 2008 +0100
@@ -26,8 +26,6 @@
 
 #include <config.h>
 
-#ifdef WITH_LXC
-
 #include "internal.h"
 #include "domain_conf.h"
 #include "capabilities.h"
@@ -52,6 +50,5 @@
               int code, const char *fmt, ...)
     ATTRIBUTE_FORMAT(printf,4,5);
 
-#endif /* WITH_LXC */
 #endif /* LXC_CONF_H */
 
diff -r b6d8ebb28723 src/lxc_container.c
--- a/src/lxc_container.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/lxc_container.c	Tue Aug 12 22:21:47 2008 +0100
@@ -22,8 +22,6 @@
  */
 
 #include <config.h>
-
-#ifdef WITH_LXC
 
 #include <fcntl.h>
 #include <limits.h>
@@ -406,4 +404,3 @@
     return 0;
 }
 
-#endif /* WITH_LXC */
diff -r b6d8ebb28723 src/lxc_container.h
--- a/src/lxc_container.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/lxc_container.h	Tue Aug 12 22:21:47 2008 +0100
@@ -26,8 +26,6 @@
 
 #include "lxc_conf.h"
 
-#ifdef WITH_LXC
-
 enum {
     LXC_CONTAINER_FEATURE_NET = (1 << 0),
 };
@@ -42,6 +40,4 @@
 
 int lxcContainerAvailable(int features);
 
-#endif /* LXC_DRIVER_H */
-
 #endif /* LXC_CONTAINER_H */
diff -r b6d8ebb28723 src/lxc_driver.c
--- a/src/lxc_driver.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/lxc_driver.c	Tue Aug 12 22:21:47 2008 +0100
@@ -22,8 +22,6 @@
  */
 
 #include <config.h>
-
-#ifdef WITH_LXC
 
 #include <fcntl.h>
 #include <sched.h>
@@ -1112,5 +1110,3 @@
     virRegisterStateDriver(&lxcStateDriver);
     return 0;
 }
-
-#endif /* WITH_LXC */
diff -r b6d8ebb28723 src/lxc_driver.h
--- a/src/lxc_driver.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/lxc_driver.h	Tue Aug 12 22:21:47 2008 +0100
@@ -26,11 +26,7 @@
 
 #include <config.h>
 
-#ifdef WITH_LXC
-
 /* Function declarations */
 int lxcRegister(void);
 
-#endif /* WITH_LXC */
-
 #endif /* LXC_DRIVER_H */
diff -r b6d8ebb28723 src/nodeinfo.h
--- a/src/nodeinfo.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/nodeinfo.h	Tue Aug 12 22:21:47 2008 +0100
@@ -26,14 +26,6 @@
 
 #include "libvirt/libvirt.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-  int virNodeInfoPopulate(virConnectPtr conn, virNodeInfoPtr nodeinfo);
-
-#ifdef __cplusplus
-}
-#endif
+int virNodeInfoPopulate(virConnectPtr conn, virNodeInfoPtr nodeinfo);
 
 #endif /* __VIR_NODEINFO_H__*/
diff -r b6d8ebb28723 src/openvz_conf.c
--- a/src/openvz_conf.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/openvz_conf.c	Tue Aug 12 22:21:47 2008 +0100
@@ -24,8 +24,6 @@
  * Anoop Joe Cyriac <anoop binarykarma com>
  *
  */
-
-#ifdef WITH_OPENVZ
 
 #include <config.h>
 
@@ -814,4 +812,3 @@
     return 0;
 }
 
-#endif
diff -r b6d8ebb28723 src/openvz_driver.c
--- a/src/openvz_driver.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/openvz_driver.c	Tue Aug 12 22:21:47 2008 +0100
@@ -24,8 +24,6 @@
  * Anoop Joe Cyriac <anoop binarykarma com>
  *
  */
-
-#ifdef WITH_OPENVZ
 
 #include <config.h>
 
@@ -948,4 +946,3 @@
     return 0;
 }
 
-#endif /* WITH_OPENVZ */
diff -r b6d8ebb28723 src/proxy_internal.c
--- a/src/proxy_internal.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/proxy_internal.c	Tue Aug 12 22:21:47 2008 +0100
@@ -7,8 +7,6 @@
  *
  * Daniel Veillard <veillard redhat com>
  */
-
-#ifdef WITH_XEN
 
 #include <config.h>
 
@@ -1082,4 +1080,4 @@
     return(ostype);
 }
 
-#endif /* WITH_XEN */
+
diff -r b6d8ebb28723 src/proxy_internal.h
--- a/src/proxy_internal.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/proxy_internal.h	Tue Aug 12 22:21:47 2008 +0100
@@ -13,10 +13,6 @@
 #define __LIBVIR_PROXY_H__
 
 #include "libvirt/libvirt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 #define PROXY_SOCKET_PATH "/tmp/livirt_proxy_conn"
 #define PROXY_PROTO_VERSION 1
@@ -98,7 +94,4 @@
 
 extern char *       xenProxyDomainDumpXML(virDomainPtr domain,
                                           int flags);
-#ifdef __cplusplus
-}
-#endif                          /* __cplusplus */
 #endif /* __LIBVIR_PROXY_H__ */
diff -r b6d8ebb28723 src/qemu_conf.c
--- a/src/qemu_conf.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/qemu_conf.c	Tue Aug 12 22:21:47 2008 +0100
@@ -22,8 +22,6 @@
  */
 
 #include <config.h>
-
-#ifdef WITH_QEMU
 
 #include <dirent.h>
 #include <string.h>
@@ -1221,5 +1219,3 @@
 #undef ADD_ARG_SPACE
 }
 
-
-#endif /* WITH_QEMU */
diff -r b6d8ebb28723 src/qemu_conf.h
--- a/src/qemu_conf.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/qemu_conf.h	Tue Aug 12 22:21:47 2008 +0100
@@ -25,8 +25,6 @@
 #define __QEMUD_CONF_H
 
 #include <config.h>
-
-#ifdef WITH_QEMU
 
 #include "internal.h"
 #include "iptables.h"
@@ -102,6 +100,4 @@
 
 const char *qemudVirtTypeToString       (int type);
 
-#endif /* WITH_QEMU */
-
 #endif /* __QEMUD_CONF_H */
diff -r b6d8ebb28723 src/qemu_driver.c
--- a/src/qemu_driver.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/qemu_driver.c	Tue Aug 12 22:21:47 2008 +0100
@@ -22,8 +22,6 @@
  */
 
 #include <config.h>
-
-#ifdef WITH_QEMU
 
 #include <sys/types.h>
 #include <sys/poll.h>
@@ -3950,4 +3948,3 @@
     return 0;
 }
 
-#endif /* WITH_QEMU */
diff -r b6d8ebb28723 src/qemu_driver.h
--- a/src/qemu_driver.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/qemu_driver.h	Tue Aug 12 22:21:47 2008 +0100
@@ -27,12 +27,8 @@
 
 #include <config.h>
 
-#ifdef WITH_QEMU
-
 #include "internal.h"
 
 int qemudRegister(void);
 
-#endif /* WITH_QEMU */
-
 #endif /* QEMUD_DRIVER_H */
diff -r b6d8ebb28723 src/remote_internal.h
--- a/src/remote_internal.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/remote_internal.h	Tue Aug 12 22:21:47 2008 +0100
@@ -26,10 +26,6 @@
 
 #include "libvirt/virterror.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 int remoteRegister (void);
 
 #define LIBVIRTD_LISTEN_ADDR NULL
@@ -48,7 +44,5 @@
 #define LIBVIRT_SERVERKEY LIBVIRT_PKI_DIR "/libvirt/private/serverkey.pem"
 #define LIBVIRT_SERVERCERT LIBVIRT_PKI_DIR "/libvirt/servercert.pem"
 
-#ifdef __cplusplus
-}
-#endif
+
 #endif /* __VIR_REMOTE_INTERNAL_H__ */
diff -r b6d8ebb28723 src/test.c
--- a/src/test.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/test.c	Tue Aug 12 22:21:48 2008 +0100
@@ -23,16 +23,12 @@
 
 #include <config.h>
 
-#ifdef WITH_TEST
-
 #include <stdio.h>
 #include <string.h>
 #include <sys/time.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/stat.h>
-
-#include "socketcompat.h"
 
 #include "test.h"
 #include "buf.h"
@@ -1645,5 +1641,3 @@
         return -1;
     return 0;
 }
-
-#endif /* WITH_TEST */
diff -r b6d8ebb28723 src/test.h
--- a/src/test.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/test.h	Tue Aug 12 22:21:48 2008 +0100
@@ -26,13 +26,6 @@
 
 #include "internal.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 int testRegister(void);
 
-#ifdef __cplusplus
-}
-#endif
 #endif /* __VIR_TEST_INTERNAL_H__ */
diff -r b6d8ebb28723 src/veth.c
--- a/src/veth.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/veth.c	Tue Aug 12 22:21:48 2008 +0100
@@ -10,8 +10,6 @@
  */
 
 #include <config.h>
-
-#ifdef WITH_LXC
 
 #include <string.h>
 
@@ -218,4 +216,4 @@
     VIR_FREE(pid);
     return rc;
 }
-#endif
+
diff -r b6d8ebb28723 src/xen_internal.c
--- a/src/xen_internal.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/xen_internal.c	Tue Aug 12 22:21:48 2008 +0100
@@ -7,8 +7,6 @@
  *
  * Daniel Veillard <veillard redhat com>
  */
-
-#ifdef WITH_XEN
 
 #include <config.h>
 
@@ -3293,4 +3291,3 @@
     return maxcpu;
 }
 
-#endif /* WITH_XEN */
diff -r b6d8ebb28723 src/xen_internal.h
--- a/src/xen_internal.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/xen_internal.h	Tue Aug 12 22:21:48 2008 +0100
@@ -10,10 +10,6 @@
 
 #ifndef __VIR_XEN_INTERNAL_H__
 #define __VIR_XEN_INTERNAL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 #include "internal.h"
 #include "capabilities.h"
@@ -102,7 +98,5 @@
                                           unsigned long long *freeMems,
                                           int startCell,
                                           int maxCells);
-#ifdef __cplusplus
-}
-#endif
+
 #endif                          /* __VIR_XEN_INTERNAL_H__ */
diff -r b6d8ebb28723 src/xen_unified.c
--- a/src/xen_unified.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/xen_unified.c	Tue Aug 12 22:21:48 2008 +0100
@@ -9,8 +9,6 @@
  */
 
 #include <config.h>
-
-#ifdef WITH_XEN
 
 /* Note:
  *
@@ -1383,4 +1381,3 @@
     return virRegisterDriver (&xenUnifiedDriver);
 }
 
-#endif /* WITH_XEN */
diff -r b6d8ebb28723 src/xen_unified.h
--- a/src/xen_unified.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/xen_unified.h	Tue Aug 12 22:21:48 2008 +0100
@@ -19,10 +19,6 @@
 #include <netinet/in.h>
 #else
 #include <winsock2.h>
-#endif
-
-#ifdef __cplusplus
-extern "C" {
 #endif
 
 extern int xenUnifiedRegister (void);
@@ -93,7 +89,6 @@
  */
 struct _xenUnifiedPrivate {
     virCapsPtr caps;
-#ifdef WITH_XEN
     int handle;			/* Xen hypervisor handle */
 
     int xendConfigVersion;      /* XenD config version */
@@ -107,7 +102,6 @@
     struct sockaddr_in addr_in; /* the inet address */
 
     struct xs_handle *xshandle; /* handle to talk to the xenstore */
-#endif /* WITH_XEN */
 
     int proxy;                  /* fd of proxy. */
 
@@ -124,8 +118,5 @@
 int xenNbCells(virConnectPtr conn);
 int xenNbCpus(virConnectPtr conn);
 char *xenDomainUsedCpus(virDomainPtr dom);
-#ifdef __cplusplus
-}
-#endif
 
 #endif /* __VIR_XEN_UNIFIED_H__ */
diff -r b6d8ebb28723 src/xend_internal.c
--- a/src/xend_internal.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/xend_internal.c	Tue Aug 12 22:21:48 2008 +0100
@@ -10,7 +10,6 @@
  *  archive for more details.
  */
 
-#ifdef WITH_XEN
 #include <config.h>
 
 #include <stdio.h>
@@ -5549,4 +5548,3 @@
 }
 
 #endif /* ! PROXY */
-#endif /* WITH_XEN */
diff -r b6d8ebb28723 src/xend_internal.h
--- a/src/xend_internal.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/xend_internal.h	Tue Aug 12 22:21:48 2008 +0100
@@ -24,10 +24,6 @@
 #include "capabilities.h"
 #include "domain_conf.h"
 #include "buf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 int
 xenDaemonOpen_unix(virConnectPtr conn, const char *path);
diff -r b6d8ebb28723 src/xm_internal.c
--- a/src/xm_internal.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/xm_internal.c	Tue Aug 12 22:21:48 2008 +0100
@@ -22,7 +22,6 @@
  *
  */
 
-#ifdef WITH_XEN
 #include <config.h>
 
 #include <dirent.h>
@@ -2685,4 +2684,3 @@
     return -1;
 }
 
-#endif /* WITH_XEN */
diff -r b6d8ebb28723 src/xs_internal.c
--- a/src/xs_internal.c	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/xs_internal.c	Tue Aug 12 22:21:48 2008 +0100
@@ -8,7 +8,6 @@
  * Daniel Veillard <veillard redhat com>
  */
 
-#ifdef WITH_XEN
 #include <config.h>
 
 #include <stdio.h>
@@ -938,5 +937,3 @@
     return xs_read(priv->xshandle, 0, prop, &len);
 }
 
-
-#endif /* WITH_XEN */
diff -r b6d8ebb28723 src/xs_internal.h
--- a/src/xs_internal.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/src/xs_internal.h	Tue Aug 12 22:21:48 2008 +0100
@@ -10,10 +10,6 @@
 
 #ifndef __VIR_XS_INTERNAL_H__
 #define __VIR_XS_INTERNAL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 #include "internal.h"
 
@@ -57,7 +53,4 @@
 char *          xenStoreDomainGetName(virConnectPtr conn,
                                       int id);
 
-#ifdef __cplusplus
-}
-#endif
 #endif /* __VIR_XS_INTERNAL_H__ */
diff -r b6d8ebb28723 tests/testutils.h
--- a/tests/testutils.h	Tue Aug 12 22:21:25 2008 +0100
+++ b/tests/testutils.h	Tue Aug 12 22:21:48 2008 +0100
@@ -13,40 +13,32 @@
 #ifndef __VIT_TEST_UTILS_H__
 #define __VIT_TEST_UTILS_H__
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+double virtTestCountAverage(double *items,
+                            int nitems);
 
+int virtTestRun(const char *title,
+                int nloops,
+                int (*body)(const void *data),
+                const void *data);
+int virtTestLoadFile(const char *name,
+                     char **buf,
+                     int buflen);
+int virtTestCaptureProgramOutput(const char *const argv[],
+                                 char **buf,
+                                 int buflen);
 
-    double virtTestCountAverage(double *items,
-                                int nitems);
 
-    int	virtTestRun(const char *title,
-                    int nloops,
-                    int (*body)(const void *data),
-                    const void *data);
-    int virtTestLoadFile(const char *name,
-                         char **buf,
-                         int buflen);
-    int virtTestCaptureProgramOutput(const char *const argv[],
-                                     char **buf,
-                                     int buflen);
+int virtTestDifference(FILE *stream,
+                       const char *expect,
+                       const char *actual);
 
-
-    int virtTestDifference(FILE *stream,
-                           const char *expect,
-                           const char *actual);
-
-    int virtTestMain(int argc,
-                     char **argv,
-                     int (*func)(int, char **));
+int virtTestMain(int argc,
+                 char **argv,
+                 int (*func)(int, char **));
 
 #define VIRT_TEST_MAIN(func)                    \
     int main(int argc, char **argv)  {          \
         return virtTestMain(argc,argv, func);   \
     }
 
-#ifdef __cplusplus
-}
-#endif
 #endif /* __VIT_TEST_UTILS_H__ */

-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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