diff --git a/etc/vz.conf b/etc/vz.conf index 29d13ff..a230f5a 100644 --- a/etc/vz.conf +++ b/etc/vz.conf @@ -8,6 +8,7 @@ VE0CPUUNITS=1000 LOGGING=yes LOGFILE=/var/log/vzctl.log LOG_LEVEL=0 +VERBOSE=0 ## Disk quota parameters DISK_QUOTA=yes diff --git a/include/vzctl_param.h b/include/vzctl_param.h index ab4790e..0037b5c 100644 --- a/include/vzctl_param.h +++ b/include/vzctl_param.h @@ -129,6 +129,7 @@ #define PARAM_NETIF_IFNAME 355 #define PARAM_NETIF_HOST_MAC 356 #define PARAM_NETIF_HOST_IFNAME 357 +#define PARAM_VERBOSE 358 #define PARAM_LINE "e:p:f:t:i:l:k:a:b:n:x:h" #endif diff --git a/src/lib/config.c b/src/lib/config.c index 3128ce9..bd3db10 100644 --- a/src/lib/config.c +++ b/src/lib/config.c @@ -53,6 +53,7 @@ static vps_config config[] = { {"LOGGING", NULL, PARAM_LOGGING}, {"LOG_LEVEL", NULL, PARAM_LOGLEVEL}, {"LOGFILE", NULL, PARAM_LOGFILE}, +{"VERBOSE", NULL, PARAM_VERBOSE}, {"IPTABLES", NULL, PARAM_IPTABLES}, /* UB */ @@ -1806,6 +1807,11 @@ static int parse(envid_t veid, vps_param *vps_p, char *val, int id) break; vps_p->log.level = int_id; break; + case PARAM_VERBOSE: + if (parse_int(val, &int_id)) + break; + vps_p->log.verbose = int_id; + break; case PARAM_IPTABLES: ret = parse_iptables(&vps_p->res.env, val); break; diff --git a/src/vzctl.c b/src/vzctl.c index cdfcd3f..5a0d773 100644 --- a/src/vzctl.c +++ b/src/vzctl.c @@ -102,6 +102,9 @@ int main(int argc, char *argv[], char *envp[]) { int action = 0; int verbose = 0; + int verbose_inc = 0; + int verbose_abs = 0; + int verbose_abs_unset = 1; int quiet = 0; int veid, ret, skiplock = 0; char buf[256]; @@ -116,6 +119,7 @@ int main(int argc, char *argv[], char *envp[]) gparam = init_vps_param(); vps_p = init_vps_param(); cmd_p = init_vps_param(); + gparam->log.verbose = 0; sigemptyset(&act.sa_mask); act.sa_handler = SIG_IGN; @@ -124,7 +128,16 @@ int main(int argc, char *argv[], char *envp[]) while (argc > 1) { if (!strcmp(argv[1], "--verbose")) { - verbose = 2; + verbose_inc++; + } else if (!strncmp(argv[1], "--verbose=", 10)) { + if(argv[1][10] != '\0') { + verbose_abs_unset = parse_int(&argv[1][10], &verbose_abs); + verbose_inc = 0; + } + if(verbose_abs_unset) { + printf("Invalid value for --verbose\n"); + exit(VZ_INVALID_PARAMETER_SYNTAX); + } } else if (!strcmp(argv[1], "--quiet")) quiet = 1; else if (!strcmp(argv[1], "--version")) { @@ -140,6 +153,13 @@ int main(int argc, char *argv[], char *envp[]) usage(); exit(VZ_INVALID_PARAMETER_SYNTAX); } + if(verbose_abs_unset) + verbose = gparam->log.verbose; + else + verbose = verbose_abs; + verbose += verbose_inc; + if(verbose < -1) + verbose = -1; action_nm = argv[1]; init_log(NULL, 0, 1, 0, 0, verbose, NULL); if (!strcmp(argv[1], "set")) { diff --git a/man/vzctl.8 b/man/vzctl.8 index c98c779..c6edd78 100644 --- a/man/vzctl.8 +++ b/man/vzctl.8 @@ -29,9 +29,9 @@ OpenVZ internal purposes. .SS Flags These flags can be used with almost any option. .IP \fB--quiet\fR 4 -Disables logging to log file and screen. -.IP \fB--verbose\fR 4 -Sets logging level to maximum value. +Disables logging to screen. +.IP \fB--verbose[=value]\fR 4 +Increase or set the logging level. No arguments will increase the current value by one. .SS Setting VE parameters .IP "\fBset\fR \fIveid\fR [\fIparameters\fR] [\fB--save\fR]" 4 This command sets various VE parameters. If flag \fB--save\fR is given,