[PATCH v3 0.5/11] libvirt: introduce libvirt/libvirt-common.h.in

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

 



As it turned out, we need to share some enums and declarations between
libvirt.h and libvirt-admin.h, but since our policy forbids direct includes of
libvirt*.h, there has to be some header exempt from this rule. This patch moves
the relevant part of code from libvirt.h.in to libvirt-common.h.in. Moreover,
since there is no need to have libvirt.h generated anymore, introduce a new
header libvirt.h which was previosly ignored from git and make the common
header ignored and generated instead.
---
I'd like add a couple more patches as a reaction to some reviews of this
series, namely, adding a new admin configuration file, adding a new common
public header file and also admin reimplementation of virGetVersion.

.gitignore                          |   2 +-
 cfg.mk                              |   2 +-
 configure.ac                        |   2 +-
 docs/Makefile.am                    |   3 +-
 include/libvirt/Makefile.am         |   2 +-
 include/libvirt/libvirt-admin.h     |   3 +
 include/libvirt/libvirt-common.h.in | 127 ++++++++++++++++++++++++++++++++++++
 include/libvirt/libvirt-host.h      |  30 ---------
 include/libvirt/libvirt.h           |  54 +++++++++++++++
 include/libvirt/libvirt.h.in        | 109 -------------------------------
 10 files changed, 190 insertions(+), 144 deletions(-)
 create mode 100644 include/libvirt/libvirt-common.h.in
 create mode 100644 include/libvirt/libvirt.h
 delete mode 100644 include/libvirt/libvirt.h.in

diff --git a/.gitignore b/.gitignore
index 2d52a8f..63f4edf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -87,7 +87,7 @@
 /gnulib/lib/*
 /gnulib/m4/*
 /gnulib/tests/*
-/include/libvirt/libvirt.h
+/include/libvirt/libvirt-common.h
 /libtool
 /libvirt-*.tar.gz
 /libvirt-[0-9]*
diff --git a/cfg.mk b/cfg.mk
index fd9fd75..85cbf95 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1215,7 +1215,7 @@ exclude_file_name_regexp--sc_prohibit_include_public_headers_quote = \
   ^(src/internal\.h$$|tools/wireshark/src/packet-libvirt.h$$)
 
 exclude_file_name_regexp--sc_prohibit_include_public_headers_brackets = \
-  ^(tools/|examples/|include/libvirt/(virterror|libvirt-(qemu|lxc))\.h$$)
+  ^(tools/|examples/|include/libvirt/(virterror|libvirt(-(admin|qemu|lxc))?)\.h$$)
 
 exclude_file_name_regexp--sc_prohibit_int_ijk = \
   ^(src/remote_protocol-structs|src/remote/remote_protocol.x|cfg.mk|include/)$
diff --git a/configure.ac b/configure.ac
index 4b7c9ed..a94308e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2789,7 +2789,7 @@ AC_CONFIG_FILES([\
         src/libvirt-lxc.pc \
         libvirt.spec mingw-libvirt.spec \
         po/Makefile.in \
-        include/libvirt/Makefile include/libvirt/libvirt.h \
+        include/libvirt/Makefile include/libvirt/libvirt-common.h \
         daemon/Makefile \
         tools/Makefile \
         tests/Makefile \
diff --git a/docs/Makefile.am b/docs/Makefile.am
index bfae35e..13d7a5f 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -301,7 +301,8 @@ EXTRA_DIST += $(APIBUILD_STAMP)
 $(python_generated_files): $(APIBUILD_STAMP)
 
 $(APIBUILD_STAMP): $(srcdir)/apibuild.py \
-		$(top_srcdir)/include/libvirt/libvirt.h.in \
+		$(top_srcdir)/include/libvirt/libvirt.h \
+		$(top_srcdir)/include/libvirt/libvirt-common.h.in \
 		$(top_srcdir)/include/libvirt/libvirt-domain-snapshot.h \
 		$(top_srcdir)/include/libvirt/libvirt-domain.h \
 		$(top_srcdir)/include/libvirt/libvirt-event.h \
diff --git a/include/libvirt/Makefile.am b/include/libvirt/Makefile.am
index 2d40621..8e5b1b8 100644
--- a/include/libvirt/Makefile.am
+++ b/include/libvirt/Makefile.am
@@ -37,7 +37,7 @@ virinc_HEADERS = libvirt.h		\
 install-exec-hook:
 	$(mkinstalldirs) $(DESTDIR)$(virincdir)
 
-EXTRA_DIST = libvirt.h.in
+EXTRA_DIST = libvirt-common.h.in
 
 # Temporarily disabled, but we need it for building
 EXTRA_DIST += libvirt-admin.h
diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h
index 9997cc2..ae033d1 100644
--- a/include/libvirt/libvirt-admin.h
+++ b/include/libvirt/libvirt-admin.h
@@ -30,6 +30,9 @@
 extern "C" {
 # endif
 
+# define __VIR_ADMIN_H_INCLUDES__
+# include <libvirt/libvirt-common.h>
+# undef __VIR_ADMIN_H_INCLUDES__
 
 /**
  * virAdmConnect:
diff --git a/include/libvirt/libvirt-common.h.in b/include/libvirt/libvirt-common.h.in
new file mode 100644
index 0000000..efbb91b
--- /dev/null
+++ b/include/libvirt/libvirt-common.h.in
@@ -0,0 +1,127 @@
+/* -*- c -*-
+ * libvirt-common.h
+ * Summary: common macros and enums for the libvirt and libvirt-admin library
+ * Description: Provides common macros and enums needed by both libvirt and
+ *              libvirt-admin libraries
+ *
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Erik Skultety <eskultet@xxxxxxxxxx>
+ */
+
+#if !defined __VIR_LIBVIRT_H_INCLUDES__ && !defined __VIR_ADMIN_H_INCLUDES__
+# error "Don't include this file directly"
+#endif
+
+#ifndef __VIR_VIRCOMMON_H__
+# define __VIR_VIRCOMMON_H__
+
+# include <sys/types.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# ifndef VIR_DEPRECATED
+  /* The feature is present in gcc-3.1 and newer.  */
+#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#   define VIR_DEPRECATED __attribute__((__deprecated__))
+#  else
+#   define VIR_DEPRECATED /* nothing */
+#  endif
+# endif /* VIR_DEPRECATED */
+
+# ifdef WIN32
+#  ifdef LIBVIRT_STATIC
+#   define VIR_EXPORT_VAR extern
+#  else
+#   ifdef IN_LIBVIRT
+#    define VIR_EXPORT_VAR __declspec(dllexport)
+#   else
+#    define VIR_EXPORT_VAR __declspec(dllimport) extern
+#   endif
+#  endif
+# else
+#  define VIR_EXPORT_VAR extern
+# endif
+
+/* General note - in the header files, any linear enumeration which
+ * might be expanded in the future has an optional *_LAST value that
+ * gives the size of the enum at the time of compilation, if the user
+ * defines VIR_ENUM_SENTINELS.  Enumerations for bit values do not
+ * have a *_LAST value, but additional bits may be defined.  */
+
+/* library versioning */
+
+/**
+ * LIBVIR_VERSION_NUMBER:
+ *
+ * Macro providing the version of the library as
+ * version * 1,000,000 + minor * 1000 + micro
+ */
+
+# define LIBVIR_VERSION_NUMBER @LIBVIRT_VERSION_NUMBER@
+
+/**
+ * LIBVIR_CHECK_VERSION:
+ * @major: major component of the version number
+ * @minor: minor component of the version number
+ * @micro: micro component of the version number
+ *
+ * Macro for developers to easily check what version of the library
+ * their code is compiling against.
+ * e.g.
+ *   #if LIBVIR_CHECK_VERSION(1,1,3)
+ *     // some code that only works in 1.1.3 and newer
+ *   #endif
+ */
+# define LIBVIR_CHECK_VERSION(major, minor, micro) \
+    ((major) * 1000000 + (minor) * 1000 + (micro) <= LIBVIR_VERSION_NUMBER)
+
+/*
+ * virFreeCallback:
+ * @opaque: opaque user data provided at registration
+ *
+ * Type for a callback cleanup function to be paired with a callback.  This
+ * function will be called as a final chance to clean up the @opaque
+ * registered with the primary callback, at the time when the primary
+ * callback is deregistered.
+ *
+ * It is forbidden to call any other libvirt APIs from an
+ * implementation of this callback, since it can be invoked
+ * from a context which is not re-entrant safe. Failure to
+ * abide by this requirement may lead to application deadlocks
+ * or crashes.
+ */
+typedef void (*virFreeCallback)(void *opaque);
+
+typedef enum {
+    VIR_CONNECT_CLOSE_REASON_ERROR     = 0, /* Misc I/O error */
+    VIR_CONNECT_CLOSE_REASON_EOF       = 1, /* End-of-file from server */
+    VIR_CONNECT_CLOSE_REASON_KEEPALIVE = 2, /* Keepalive timer triggered */
+    VIR_CONNECT_CLOSE_REASON_CLIENT    = 3, /* Client requested it */
+
+# ifdef VIR_ENUM_SENTINELS
+    VIR_CONNECT_CLOSE_REASON_LAST
+# endif
+} virConnectCloseReason;
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif /* __VIR_VIRCOMMON_H__ */
diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h
index 3669711..8786fbb 100644
--- a/include/libvirt/libvirt-host.h
+++ b/include/libvirt/libvirt-host.h
@@ -29,24 +29,6 @@
 # endif
 
 
-/*
- * virFreeCallback:
- * @opaque: opaque user data provided at registration
- *
- * Type for a callback cleanup function to be paired with a callback.  This
- * function will be called as a final chance to clean up the @opaque
- * registered with the primary callback, at the time when the primary
- * callback is deregistered.
- *
- * It is forbidden to call any other libvirt APIs from an
- * implementation of this callback, since it can be invoked
- * from a context which is not re-entrant safe. Failure to
- * abide by this requirement may lead to application deadlocks
- * or crashes.
- */
-typedef void (*virFreeCallback)(void *opaque);
-
-
 /**
  * virConnect:
  *
@@ -755,18 +737,6 @@ char *                  virConnectGetSysinfo    (virConnectPtr conn,
 int virConnectSetKeepAlive(virConnectPtr conn,
                            int interval,
                            unsigned int count);
-
-typedef enum {
-    VIR_CONNECT_CLOSE_REASON_ERROR     = 0, /* Misc I/O error */
-    VIR_CONNECT_CLOSE_REASON_EOF       = 1, /* End-of-file from server */
-    VIR_CONNECT_CLOSE_REASON_KEEPALIVE = 2, /* Keepalive timer triggered */
-    VIR_CONNECT_CLOSE_REASON_CLIENT    = 3, /* Client requested it */
-
-# ifdef VIR_ENUM_SENTINELS
-    VIR_CONNECT_CLOSE_REASON_LAST
-# endif
-} virConnectCloseReason;
-
 /**
  * virConnectCloseFunc:
  * @conn: virConnect connection
diff --git a/include/libvirt/libvirt.h b/include/libvirt/libvirt.h
new file mode 100644
index 0000000..36f6d60
--- /dev/null
+++ b/include/libvirt/libvirt.h
@@ -0,0 +1,54 @@
+/* -*- c -*-
+ * libvirt.h: Core interfaces for the libvirt library
+ * Summary: core interfaces for the libvirt library
+ * Description: Provides the interfaces of the libvirt library to handle
+ *              virtualized domains
+ *
+ * Copyright (C) 2005-2006, 2010-2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Daniel Veillard <veillard@xxxxxxxxxx>
+ */
+
+#ifndef __VIR_VIRLIB_H__
+# define __VIR_VIRLIB_H__
+
+# include <sys/types.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# define __VIR_LIBVIRT_H_INCLUDES__
+# include <libvirt/libvirt-common.h>
+# include <libvirt/libvirt-host.h>
+# include <libvirt/libvirt-domain.h>
+# include <libvirt/libvirt-domain-snapshot.h>
+# include <libvirt/libvirt-event.h>
+# include <libvirt/libvirt-interface.h>
+# include <libvirt/libvirt-network.h>
+# include <libvirt/libvirt-nodedev.h>
+# include <libvirt/libvirt-nwfilter.h>
+# include <libvirt/libvirt-secret.h>
+# include <libvirt/libvirt-storage.h>
+# include <libvirt/libvirt-stream.h>
+# undef __VIR_LIBVIRT_H_INCLUDES__
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif /* __VIR_VIRLIB_H__ */
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
deleted file mode 100644
index 7706978..0000000
--- a/include/libvirt/libvirt.h.in
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- c -*-
- * libvirt.h: Core interfaces for the libvirt library
- * Summary: core interfaces for the libvirt library
- * Description: Provides the interfaces of the libvirt library to handle
- *              virtualized domains
- *
- * Copyright (C) 2005-2006, 2010-2014 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * Author: Daniel Veillard <veillard@xxxxxxxxxx>
- */
-
-#ifndef __VIR_VIRLIB_H__
-# define __VIR_VIRLIB_H__
-
-# include <sys/types.h>
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-# ifndef VIR_DEPRECATED
-  /* The feature is present in gcc-3.1 and newer.  */
-#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
-#   define VIR_DEPRECATED __attribute__((__deprecated__))
-#  else
-#   define VIR_DEPRECATED /* nothing */
-#  endif
-# endif /* VIR_DEPRECATED */
-
-# ifdef WIN32
-#  ifdef LIBVIRT_STATIC
-#   define VIR_EXPORT_VAR extern
-#  else
-#   ifdef IN_LIBVIRT
-#    define VIR_EXPORT_VAR __declspec(dllexport)
-#   else
-#    define VIR_EXPORT_VAR __declspec(dllimport) extern
-#   endif
-#  endif
-# else
-#  define VIR_EXPORT_VAR extern
-# endif
-
-/* General note - in the header files, any linear enumeration which
- * might be expanded in the future has an optional *_LAST value that
- * gives the size of the enum at the time of compilation, if the user
- * defines VIR_ENUM_SENTINELS.  Enumerations for bit values do not
- * have a *_LAST value, but additional bits may be defined.  */
-
-/* library versioning */
-
-/**
- * LIBVIR_VERSION_NUMBER:
- *
- * Macro providing the version of the library as
- * version * 1,000,000 + minor * 1000 + micro
- */
-
-# define LIBVIR_VERSION_NUMBER @LIBVIRT_VERSION_NUMBER@
-
-/**
- * LIBVIR_CHECK_VERSION:
- * @major: major component of the version number
- * @minor: minor component of the version number
- * @micro: micro component of the version number
- *
- * Macro for developers to easily check what version of the library
- * their code is compiling against.
- * e.g.
- *   #if LIBVIR_CHECK_VERSION(1,1,3)
- *     // some code that only works in 1.1.3 and newer
- *   #endif
- */
-# define LIBVIR_CHECK_VERSION(major, minor, micro) \
-    ((major) * 1000000 + (minor) * 1000 + (micro) <= LIBVIR_VERSION_NUMBER)
-
-# define __VIR_LIBVIRT_H_INCLUDES__
-# include <libvirt/libvirt-host.h>
-# include <libvirt/libvirt-domain.h>
-# include <libvirt/libvirt-domain-snapshot.h>
-# include <libvirt/libvirt-event.h>
-# include <libvirt/libvirt-interface.h>
-# include <libvirt/libvirt-network.h>
-# include <libvirt/libvirt-nodedev.h>
-# include <libvirt/libvirt-nwfilter.h>
-# include <libvirt/libvirt-secret.h>
-# include <libvirt/libvirt-storage.h>
-# include <libvirt/libvirt-stream.h>
-# undef __VIR_LIBVIRT_H_INCLUDES__
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif /* __VIR_VIRLIB_H__ */
-- 
2.4.3

--
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]