From c2e494cc570540827d3ba8562a56349686bc2cc2 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 17 Aug 2012 21:16:04 -0600 Subject: [PATCH] virsh: split out virsh.h Having one .c file include another does not give any compilation benefits; move towards modular .o files by first splitting out reused declarations into a new virsh.h. This patch doesn't try very hard to see which functions are used or not, to make it easier to review the file split. Future patches can further trim the header to be smaller. * tools/Makefile.am (virsh_SOURCES): List new file, and prepare for others. * tools/virsh.c: Split declarations... * tools/virsh.h: ...into new file, and make several functions non-static. * tools/virsh-domain-monitor.c (vshGetDomainDescription): Make non-static. --- tools/Makefile.am | 15 +- tools/virsh-domain-monitor.c | 2 +- tools/virsh.c | 407 ++++------------------------------- tools/virsh.h | 370 +++++++++++++++++++++++++++++++ 4 files changed, 431 insertions(+), 363 deletions(-) create mode 100644 tools/virsh.h diff --git a/tools/Makefile.am b/tools/Makefile.am index 7c048b204b..52a869987e 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -105,7 +105,20 @@ virt_host_validate_CFLAGS = \ virsh_SOURCES = \ console.c console.h \ - virsh.c + virsh.c virsh.h \ + $(NULL) +# virsh-domain.c virsh-domain.h \ +# virsh-domain-monitor.c virsh-domain-monitor.h \ +# virsh-host.c virsh-host.h \ +# virsh-interface.c virsh-interface.h \ +# virsh-network.c virsh-network.h \ +# virsh-nodedev.c virsh-nodedev.h \ +# virsh-nwfilter.c virsh-nwfilter.h \ +# virsh-pool.c virsh-pool.h \ +# virsh-secret.c virsh-secret.h \ +# virsh-snapshot.c virsh-snapshot.h \ +# virsh-volume.c virsh-volume.h \ +# virsh_LDFLAGS = $(WARN_LDFLAGS) $(COVERAGE_LDFLAGS) virsh_LDADD = \ diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 1272a0575c..52e44c9275 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -43,7 +43,7 @@ vshDomainIOErrorToString(int error) } /* extract description or title from domain xml */ -static char * +char * vshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title, unsigned int flags) { diff --git a/tools/virsh.c b/tools/virsh.c index 3be2f99520..610236ba1b 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -23,6 +23,7 @@ */ #include +#include "virsh.h" #include #include @@ -79,322 +80,12 @@ static char *progname; -#define VIRSH_MAX_XML_FILE 10*1024*1024 - -#define VSH_PROMPT_RW "virsh # " -#define VSH_PROMPT_RO "virsh > " - -#define VIR_FROM_THIS VIR_FROM_NONE - -#define GETTIMEOFDAY(T) gettimeofday(T, NULL) -#define DIFF_MSEC(T, U) \ - ((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \ - ((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0) - -/* Default escape char Ctrl-] as per telnet */ -#define CTRL_CLOSE_BRACKET "^]" - -/** - * The log configuration - */ -#define MSG_BUFFER 4096 -#define SIGN_NAME "virsh" -#define DIR_MODE (S_IWUSR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) /* 0755 */ -#define FILE_MODE (S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH) /* 0644 */ -#define LOCK_MODE (S_IWUSR | S_IRUSR) /* 0600 */ -#define LVL_DEBUG "DEBUG" -#define LVL_INFO "INFO" -#define LVL_NOTICE "NOTICE" -#define LVL_WARNING "WARNING" -#define LVL_ERROR "ERROR" - -/** - * vshErrorLevel: - * - * Indicates the level of a log message - */ -typedef enum { - VSH_ERR_DEBUG = 0, - VSH_ERR_INFO, - VSH_ERR_NOTICE, - VSH_ERR_WARNING, - VSH_ERR_ERROR -} vshErrorLevel; - -#define VSH_DEBUG_DEFAULT VSH_ERR_ERROR - -/* - * virsh command line grammar: - * - * command_line = \n | ; ; ... - * - * command =