[lxc-devel] [PATCH] lxc: cleanup <lxc/lxc.h>

Cedric Le Goater clg at fr.ibm.com
Tue Nov 17 09:41:43 UTC 2009


<lxc/lxc.h>  should only include what is needed. This patch removes
all useless headers from lxc.h and fixed other .c files.

Signed-off-by: Cedric Le Goater <clg at fr.ibm.com>
---
 src/lxc/cgroup.c         |    3 ++-
 src/lxc/checkpoint.c     |    7 ++-----
 src/lxc/commands.c       |    4 +++-
 src/lxc/conf.c           |    3 ++-
 src/lxc/conf.h           |    2 ++
 src/lxc/confile.c        |    2 +-
 src/lxc/confile.h        |    2 ++
 src/lxc/console.c        |    5 ++++-
 src/lxc/freezer.c        |    3 ++-
 src/lxc/lxc.h            |   12 +++---------
 src/lxc/lxc_cgroup.c     |    2 ++
 src/lxc/lxc_checkpoint.c |    5 ++++-
 src/lxc/lxc_console.c    |    6 ++++--
 src/lxc/lxc_execute.c    |    4 +++-
 src/lxc/lxc_freeze.c     |    2 ++
 src/lxc/lxc_info.c       |    2 ++
 src/lxc/lxc_init.c       |    6 +++++-
 src/lxc/lxc_monitor.c    |    2 ++
 src/lxc/lxc_restart.c    |    4 +++-
 src/lxc/lxc_start.c      |    2 ++
 src/lxc/lxc_stop.c       |    2 ++
 src/lxc/lxc_unfreeze.c   |    2 ++
 src/lxc/lxc_unshare.c    |    3 ++-
 src/lxc/lxc_wait.c       |    2 ++
 src/lxc/monitor.c        |    4 +++-
 src/lxc/namespace.c      |    2 +-
 src/lxc/restart.c        |    3 ---
 src/lxc/start.c          |   13 ++++++++-----
 src/lxc/start.h          |    7 ++++++-
 src/lxc/state.c          |    2 +-
 src/lxc/stop.c           |    4 +++-
 31 files changed, 82 insertions(+), 40 deletions(-)

diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c
index 17abb16..3fff51e 100644
--- a/src/lxc/cgroup.c
+++ b/src/lxc/cgroup.c
@@ -39,8 +39,9 @@
 #include "error.h"
 #include "config.h"

-#include <lxc/lxc.h>
 #include <lxc/log.h>
+#include <lxc/cgroup.h>
+#include <lxc/start.h>

 lxc_log_define(lxc_cgroup, lxc);

diff --git a/src/lxc/checkpoint.c b/src/lxc/checkpoint.c
index b7f172d..e07b010 100644
--- a/src/lxc/checkpoint.c
+++ b/src/lxc/checkpoint.c
@@ -36,12 +36,9 @@
 #include <netinet/in.h>
 #include <net/if.h>

-#include "error.h"
-#include "lxc_plugin.h"
-#include <lxc.h>
-
 #include <lxc/log.h>
-
+#include "lxc_plugin.h"
+   
 lxc_log_define(lxc_checkpoint, lxc);

 int lxc_checkpoint(const char *name, int fd, unsigned long flags)
diff --git a/src/lxc/commands.c b/src/lxc/commands.c
index e0ca348..02239e5 100644
--- a/src/lxc/commands.c
+++ b/src/lxc/commands.c
@@ -30,7 +30,9 @@
 #include <sys/poll.h>
 #include <sys/param.h>

-#include <lxc/lxc.h>
+#include <lxc/log.h>
+#include <lxc/conf.h>
+#include <lxc/start.h>	/* for struct lxc_handler */

 #include "commands.h"
 #include "mainloop.h"
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index ab324ab..b4e3a3e 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -50,8 +50,9 @@
 #include "parse.h"
 #include "config.h"

-#include <lxc/lxc.h>
+#include <lxc/conf.h>
 #include <lxc/log.h>
+#include <lxc/lxc.h>	/* for lxc_cgroup_set() */

 lxc_log_define(lxc_conf, lxc);

diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index 8a3ebf0..215f1e5 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -26,6 +26,8 @@
 #include <netinet/in.h>
 #include <sys/param.h>

+#include <lxc/list.h>
+
 enum {
 	EMPTY,
 	VETH,
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 5e0081c..43bede4 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -34,8 +34,8 @@

 #include "parse.h"

-#include <lxc/lxc.h>
 #include <lxc/log.h>
+#include <lxc/conf.h>

 lxc_log_define(lxc_confile, lxc);

diff --git a/src/lxc/confile.h b/src/lxc/confile.h
index d0e7653..20c9b39 100644
--- a/src/lxc/confile.h
+++ b/src/lxc/confile.h
@@ -21,6 +21,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */

+struct lxc_conf;
+
 extern int lxc_config_read(const char *file, struct lxc_conf *conf);


diff --git a/src/lxc/console.c b/src/lxc/console.c
index bd117a5..52f6cec 100644
--- a/src/lxc/console.c
+++ b/src/lxc/console.c
@@ -27,7 +27,10 @@
 #include <sys/types.h>
 #include <sys/un.h>

-#include <lxc/lxc.h>
+#include <lxc/log.h>
+#include <lxc/conf.h>
+#include <lxc/start.h> 	/* for struct lxc_handler */
+
 #include "commands.h"
 #include "af_unix.h"

diff --git a/src/lxc/freezer.c b/src/lxc/freezer.c
index f4b4018..cff954e 100644
--- a/src/lxc/freezer.c
+++ b/src/lxc/freezer.c
@@ -32,8 +32,9 @@
 #include <sys/param.h>

 #include "error.h"
-#include <lxc/lxc.h>
+
 #include <lxc/log.h>
+#include <lxc/cgroup.h>

 lxc_log_define(lxc_freezer, lxc);

diff --git a/src/lxc/lxc.h b/src/lxc/lxc.h
index 1d04b9f..a78fb65 100644
--- a/src/lxc/lxc.h
+++ b/src/lxc/lxc.h
@@ -33,16 +33,10 @@ extern "C" {
  lxc/lxc.h will contain exports of liblxc
  **/

+#include <stddef.h>
 #include <lxc/state.h>
-#include <lxc/list.h>
-#include <lxc/log.h>
-#include <lxc/conf.h>
-#include <lxc/namespace.h>
-#include <lxc/utils.h>
-#include <lxc/error.h>
-#include <lxc/cgroup.h>
-#include <lxc/monitor.h>
-#include <lxc/start.h>
+
+struct lxc_msg;

 /*
  * Start the specified command inside a container
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index ae1c964..f394d26 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -27,6 +27,8 @@
 #include <sys/types.h>

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
 #include "arguments.h"

 lxc_log_define(lxc_cgroup, lxc);
diff --git a/src/lxc/lxc_checkpoint.c b/src/lxc/lxc_checkpoint.c
index 4d0e210..ff59048 100644
--- a/src/lxc/lxc_checkpoint.c
+++ b/src/lxc/lxc_checkpoint.c
@@ -27,7 +27,10 @@
 #include <unistd.h>
 #include <sys/types.h>

-#include <lxc.h>
+#include <lxc/lxc.h>
+#include <lxc/log.h>
+#include <lxc/utils.h>
+
 #include "arguments.h"
 #include "config.h"

diff --git a/src/lxc/lxc_console.c b/src/lxc/lxc_console.c
index b662572..cff208f 100644
--- a/src/lxc/lxc_console.c
+++ b/src/lxc/lxc_console.c
@@ -37,8 +37,10 @@
 #include <sys/stat.h>
 #include <sys/poll.h>

-#include "error.h"
-#include "lxc.h"
+#include <lxc/error.h>
+#include <lxc/lxc.h>
+#include <lxc/log.h>
+
 #include "arguments.h"

 lxc_log_define(lxc_console, lxc);
diff --git a/src/lxc/lxc_execute.c b/src/lxc/lxc_execute.c
index 746cb4e..5821350 100644
--- a/src/lxc/lxc_execute.c
+++ b/src/lxc/lxc_execute.c
@@ -31,8 +31,10 @@
 #include <sys/stat.h>
 #include <sys/param.h>

+#include <lxc/log.h>
+#include <lxc/confile.h>
 #include <lxc/lxc.h>
-#include "confile.h"
+
 #include "arguments.h"
 #include "config.h"

diff --git a/src/lxc/lxc_freeze.c b/src/lxc/lxc_freeze.c
index a5be16c..770d923 100644
--- a/src/lxc/lxc_freeze.c
+++ b/src/lxc/lxc_freeze.c
@@ -27,6 +27,8 @@
 #include <string.h>

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
 #include "arguments.h"

 static const struct option my_longopts[] = {
diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c
index 34518d9..4facbf2 100644
--- a/src/lxc/lxc_info.c
+++ b/src/lxc/lxc_info.c
@@ -26,6 +26,8 @@
 #include <sys/types.h>

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
 #include "arguments.h"

 static const struct option my_longopts[] = {
diff --git a/src/lxc/lxc_init.c b/src/lxc/lxc_init.c
index deef343..191f7c4 100644
--- a/src/lxc/lxc_init.c
+++ b/src/lxc/lxc_init.c
@@ -33,7 +33,11 @@
 #include <sys/mount.h>
 #define _GNU_SOURCE
 #include <getopt.h>
-#include "lxc.h"
+
+#include <lxc/lxc.h>
+#include <lxc/log.h>
+#include <lxc/utils.h>
+#include <lxc/error.h>

 lxc_log_define(lxc_init, lxc);

diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index 4befa15..7d14188 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -29,6 +29,8 @@
 #include <sys/types.h>

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+#include <lxc/monitor.h>
 #include "arguments.h"

 lxc_log_define(monitor, lxc);
diff --git a/src/lxc/lxc_restart.c b/src/lxc/lxc_restart.c
index 9f4bb1d..77895a0 100644
--- a/src/lxc/lxc_restart.c
+++ b/src/lxc/lxc_restart.c
@@ -25,7 +25,9 @@
 #include <unistd.h>
 #include <sys/types.h>

-#include <lxc.h>
+#include <lxc/lxc.h>
+#include <lxc/log.h>
+
 #include "arguments.h"

 static int my_checker(const struct lxc_arguments* args)
diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c
index ffeb66b..de78290 100644
--- a/src/lxc/lxc_start.c
+++ b/src/lxc/lxc_start.c
@@ -39,6 +39,8 @@

 #include <lxc/lxc.h>
 #include <lxc/log.h>
+#include <lxc/utils.h>
+
 #include "arguments.h"

 lxc_log_define(lxc_start, lxc);
diff --git a/src/lxc/lxc_stop.c b/src/lxc/lxc_stop.c
index 01d6d8f..639b750 100644
--- a/src/lxc/lxc_stop.c
+++ b/src/lxc/lxc_stop.c
@@ -26,6 +26,8 @@
 #include <sys/types.h>

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
 #include "arguments.h"

 static const struct option my_longopts[] = {
diff --git a/src/lxc/lxc_unfreeze.c b/src/lxc/lxc_unfreeze.c
index 02ca70d..22be839 100644
--- a/src/lxc/lxc_unfreeze.c
+++ b/src/lxc/lxc_unfreeze.c
@@ -26,6 +26,8 @@
 #include <sys/types.h>

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
 #include "arguments.h"

 static const struct option my_longopts[] = {
diff --git a/src/lxc/lxc_unshare.c b/src/lxc/lxc_unshare.c
index f91d4cd..4639687 100644
--- a/src/lxc/lxc_unshare.c
+++ b/src/lxc/lxc_unshare.c
@@ -32,7 +32,8 @@
 #include <sys/wait.h>
 #include <pwd.h>

-#include <lxc/lxc.h>
+#include <lxc/log.h>
+#include <lxc/namespace.h>

 lxc_log_define(lxc_unshare, lxc);

diff --git a/src/lxc/lxc_wait.c b/src/lxc/lxc_wait.c
index bc1bb06..a5199e2 100644
--- a/src/lxc/lxc_wait.c
+++ b/src/lxc/lxc_wait.c
@@ -27,6 +27,8 @@
 #include <sys/types.h>

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+#include <lxc/monitor.h>
 #include "arguments.h"

 lxc_log_define(lxc_wait, lxc);
diff --git a/src/lxc/monitor.c b/src/lxc/monitor.c
index 700f5bc..7ec1701 100644
--- a/src/lxc/monitor.c
+++ b/src/lxc/monitor.c
@@ -36,8 +36,10 @@

 #include "error.h"
 #include "af_unix.h"
-#include <lxc/lxc.h>
+
 #include <lxc/log.h>
+#include <lxc/state.h>
+#include <lxc/monitor.h>

 lxc_log_define(lxc_monitor, lxc);

diff --git a/src/lxc/namespace.c b/src/lxc/namespace.c
index 70f6726..72e47e1 100644
--- a/src/lxc/namespace.c
+++ b/src/lxc/namespace.c
@@ -27,7 +27,7 @@
 #include <signal.h>
 #include <namespace.h>

-#include <lxc/lxc.h>
+#include <lxc/log.h>

 lxc_log_define(lxc_namespace, lxc);

diff --git a/src/lxc/restart.c b/src/lxc/restart.c
index f382ae3..ce8cd80 100644
--- a/src/lxc/restart.c
+++ b/src/lxc/restart.c
@@ -44,9 +44,6 @@

 lxc_log_define(lxc_restart, lxc);

-LXC_TTY_HANDLER(SIGINT);
-LXC_TTY_HANDLER(SIGQUIT);
-
 int lxc_restart(const char *name, int fd, unsigned long flags)
 {
 	return 0;
diff --git a/src/lxc/start.c b/src/lxc/start.c
index 6537780..e59b4e3 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -44,9 +44,6 @@
 #include <sys/un.h>
 #include <sys/poll.h>

-#include <lxc/lxc.h>
-#include <lxc/confile.h>
-
 #ifdef HAVE_SYS_SIGNALFD_H 
 #  include <sys/signalfd.h>
 #else
@@ -91,13 +88,19 @@ int signalfd(int fd, const sigset_t *mask, int flags)
 #define PR_CAPBSET_DROP 24
 #endif

+#include <lxc/log.h>
+#include <lxc/conf.h>
+#include <lxc/confile.h>
+#include <lxc/start.h>
+#include <lxc/utils.h>
+#include <lxc/cgroup.h>
+#include <lxc/monitor.h>
+
 #include "error.h"
 #include "af_unix.h"
 #include "mainloop.h"
 #include "commands.h"

-#include <lxc/lxc.h>
-#include <lxc/log.h>

 lxc_log_define(lxc_start, lxc);

diff --git a/src/lxc/start.h b/src/lxc/start.h
index 03d8762..ca0c08a 100644
--- a/src/lxc/start.h
+++ b/src/lxc/start.h
@@ -20,6 +20,11 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+#ifndef __lxc_state_h
+#define __lxc_state_h
+
+#include <lxc/conf.h>
+#include <lxc/state.h>

 struct lxc_handler {

@@ -40,5 +45,5 @@ extern int lxc_poll(const char *name, struct lxc_handler *handler);
 extern void lxc_abort(const char *name, struct lxc_handler *handler);
 extern void lxc_fini(const char *name, struct lxc_handler *handler);

-
+#endif

diff --git a/src/lxc/state.c b/src/lxc/state.c
index 6125fa3..0496657 100644
--- a/src/lxc/state.c
+++ b/src/lxc/state.c
@@ -31,8 +31,8 @@
 #include <sys/stat.h>
 #include <sys/file.h>

-#include <lxc/lxc.h>
 #include <lxc/log.h>
+#include <lxc/start.h>
 #include "commands.h"
 #include "config.h"

diff --git a/src/lxc/stop.c b/src/lxc/stop.c
index 504d27e..b751af5 100644
--- a/src/lxc/stop.c
+++ b/src/lxc/stop.c
@@ -29,10 +29,12 @@
 #include <sys/signal.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/socket.h>
 #include <fcntl.h>

-#include <lxc/lxc.h>
 #include <lxc/log.h>
+#include <lxc/start.h>
+
 #include "commands.h"

 lxc_log_define(lxc_stop, lxc);




More information about the lxc-devel mailing list