From a20b62374816e9115830e9c69faa644e5b7129bb Mon Sep 17 00:00:00 2001 From: Erik Skultety Date: Thu, 26 Nov 2015 15:02:49 +0100 Subject: [PATCH] libvirt: introduce libvirt/libvirt-common.h.in 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. --- .gitignore | 2 +- cfg.mk | 2 +- configure.ac | 2 +- docs/Makefile.am | 3 +- include/libvirt/Makefile.am | 2 +- include/libvirt/libvirt-admin.h | 3 + .../{libvirt.h.in => libvirt-common.h.in} | 62 ++++++++++++------- include/libvirt/libvirt-host.h | 30 --------- include/libvirt/libvirt.h | 54 ++++++++++++++++ 9 files changed, 103 insertions(+), 57 deletions(-) rename include/libvirt/{libvirt.h.in => libvirt-common.h.in} (61%) create mode 100644 include/libvirt/libvirt.h diff --git a/.gitignore b/.gitignore index 7f3e253aba..35edd113cd 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 c58e38837f..cf3f36c133 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 4b7c9ed6b7..a94308e258 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 bfae35e0dd..13d7a5ff26 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 2d40621116..8e5b1b873d 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 9997cc2880..ae033d1ed9 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 +# undef __VIR_ADMIN_H_INCLUDES__ /** * virAdmConnect: diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt-common.h.in similarity index 61% rename from include/libvirt/libvirt.h.in rename to include/libvirt/libvirt-common.h.in index 77069789fa..efbb91b8ed 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt-common.h.in @@ -1,10 +1,10 @@ /* -*- 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 + * 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) 2005-2006, 2010-2014 Red Hat, Inc. + * 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 @@ -20,11 +20,15 @@ * License along with this library. If not, see * . * - * Author: Daniel Veillard + * Author: Erik Skultety */ -#ifndef __VIR_VIRLIB_H__ -# define __VIR_VIRLIB_H__ +#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 @@ -88,22 +92,36 @@ extern "C" { # define LIBVIR_CHECK_VERSION(major, minor, micro) \ ((major) * 1000000 + (minor) * 1000 + (micro) <= LIBVIR_VERSION_NUMBER) -# define __VIR_LIBVIRT_H_INCLUDES__ -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# undef __VIR_LIBVIRT_H_INCLUDES__ +/* + * 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_VIRLIB_H__ */ +#endif /* __VIR_VIRCOMMON_H__ */ diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 3669711a17..8786fbb4c6 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 0000000000..36f6d60775 --- /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 + * . + * + * Author: Daniel Veillard + */ + +#ifndef __VIR_VIRLIB_H__ +# define __VIR_VIRLIB_H__ + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# define __VIR_LIBVIRT_H_INCLUDES__ +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# undef __VIR_LIBVIRT_H_INCLUDES__ + +# ifdef __cplusplus +} +# endif + +#endif /* __VIR_VIRLIB_H__ */ -- 2.39.5