/* * virsh.c: a Xen shell used to exercise the libvirt API * * Copyright (C) 2005, 2007-2009 Red Hat, Inc. * * See COPYING.LIB for the License of this software * * Daniel Veillard * Karel Zak * Daniel P. Berrange */ #include #include #include #include #include #include #include #include #include #include #include "c-ctype.h" #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_READLINE_READLINE_H #include #include #endif #include "internal.h" #include "virterror_internal.h" #include "base64.h" #include "buf.h" #include "console.h" #include "util.h" #include "memory.h" static char *progname; #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #define VIRSH_MAX_XML_FILE 10*1024*1024 #define VSH_PROMPT_RW "virsh # " #define VSH_PROMPT_RO "virsh > " #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) /** * 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" #ifndef WEXITSTATUS # define WEXITSTATUS(x) ((x) & 0xff) #endif /** * vshErrorLevel: * * Indicates the level of an log message */ typedef enum { VSH_ERR_DEBUG = 0, VSH_ERR_INFO, VSH_ERR_NOTICE, VSH_ERR_WARNING, VSH_ERR_ERROR } vshErrorLevel; /* * virsh command line grammar: * * command_line = \n | ; ; ... * * command =