From ab647a30aa155e72a51f9e7e228d558b8db6ec2a Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Fri, 3 Dec 2010 12:52:49 -0800 Subject: [PATCH] ib_acme: Hide output for -A -O options unless verbose Do not display the contents of generated config files by default. Add a verbose option to ib_acme and only display the contents if verbose is enabled. This reduces the amount of noise using ib_acme to configuring address information across a large cluster. Signed-off-by: Sean Hefty --- linux/acme_linux.c | 4 +++- man/ib_acme.1 | 7 ++++++- src/acme.c | 20 ++++++++++++++------ windows/acme_windows.c | 7 +++++-- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/linux/acme_linux.c b/linux/acme_linux.c index 2cb422a..9477d29 100644 --- a/linux/acme_linux.c +++ b/linux/acme_linux.c @@ -43,6 +43,7 @@ extern struct ibv_context **verbs; extern int dev_cnt; +extern int verbose; static int @@ -202,7 +203,8 @@ int gen_addr_ip(FILE *f) if (ret) continue; - printf("%s %s %d 0x%x\n", ip, verbs[dev_index]->device->name, port, pkey); + if (verbose) + printf("%s %s %d 0x%x\n", ip, verbs[dev_index]->device->name, port, pkey); fprintf(f, "%s %s %d 0x%x\n", ip, verbs[dev_index]->device->name, port, pkey); } ret = 0; diff --git a/man/ib_acme.1 b/man/ib_acme.1 index ba9086a..0c0e332 100644 --- a/man/ib_acme.1 +++ b/man/ib_acme.1 @@ -1,4 +1,4 @@ -.TH "ib_acme" 7 "2009-09-09" "ib_acme" "ib_acme" ib_acme +.TH "ib_acme" 7 "2010-12-06" "ib_acme" "ib_acme" ib_acme .SH NAME ib_acme \- test and configuration utility for the IB ACM .SH SYNOPSIS @@ -47,6 +47,11 @@ assigned to IPoIB device instances. With this option, the ib_acme utility automatically generates the option configuration file acm_opts.cfg. The generated file is currently generated using static information. +.TP +\-V +Enables verbose output. When combined with -A or -O options, ib_acme will +display additional details, such as generated address information saved +to the acm_addr.cfg file. .SH "NOTES" The ib_acme utility performs two main functions. With the -A and -O options, it automatically generates address or options configuration files. The diff --git a/src/acme.c b/src/acme.c index 552f42a..cc34577 100644 --- a/src/acme.c +++ b/src/acme.c @@ -53,12 +53,15 @@ static char addr_type = 'i'; static int verify; static int make_addr; static int make_opts; +int verbose; struct ibv_context **verbs; int dev_cnt; extern int gen_addr_ip(FILE *f); +#define VPRINT(format, ...) do { if (verbose) printf(format, ## __VA_ARGS__ ); } while (0) + static void show_usage(char *program) { printf("usage 1: %s\n", program); @@ -74,6 +77,7 @@ static void show_usage(char *program) printf(" (default is %s)\n", ACM_OPTS_FILE); printf(" -D dest_dir - specify destination directory for output files\n"); printf(" (default is %s)\n", ACM_DEST_DIR); + printf(" -V - enable verbose output\n"); } static void gen_opts_temp(FILE *f) @@ -224,7 +228,7 @@ static int gen_opts(void) { FILE *f; - printf("Generating %s/%s\n", dest_dir, opts_file); + VPRINT("Generating %s/%s\n", dest_dir, opts_file); if (open_dir() || !(f = fopen(opts_file, "w"))) { printf("Failed to open option configuration file: %s\n", strerror(errno)); return -1; @@ -336,7 +340,7 @@ static int gen_addr_names(FILE *f) if (!found_active) { ret = ibv_query_port(verbs[i], p, &port_attr); if (!ret && port_attr.state == IBV_PORT_ACTIVE) { - printf("%s %s %d default\n", + VPRINT("%s %s %d default\n", host_name, verbs[i]->device->name, p); fprintf(f, "%s %s %d default\n", host_name, verbs[i]->device->name, p); @@ -344,7 +348,7 @@ static int gen_addr_names(FILE *f) } } - printf("%s-%d %s %d default\n", + VPRINT("%s-%d %s %d default\n", host_name, index, verbs[i]->device->name, p); fprintf(f, "%s-%d %s %d default\n", host_name, index++, verbs[i]->device->name, p); @@ -359,7 +363,7 @@ static int gen_addr(void) FILE *f; int ret; - printf("Generating %s/%s\n", dest_dir, addr_file); + VPRINT("Generating %s/%s\n", dest_dir, addr_file); if (open_dir() || !(f = fopen(addr_file, "w"))) { printf("Failed to open address configuration file: %s\n", strerror(errno)); return -1; @@ -546,7 +550,7 @@ int CDECL_FUNC main(int argc, char **argv) if (ret) goto out; - while ((op = getopt(argc, argv, "f:s:d:vA::O::D:")) != -1) { + while ((op = getopt(argc, argv, "f:s:d:vA::O::D:V")) != -1) { switch (op) { case 'f': addr_type = optarg[0]; @@ -573,6 +577,9 @@ int CDECL_FUNC main(int argc, char **argv) case 'D': dest_dir = optarg; break; + case 'V': + verbose = 1; + break; default: show_usage(argv[0]); exit(1); @@ -595,6 +602,7 @@ int CDECL_FUNC main(int argc, char **argv) ret = gen_opts(); out: - printf("return status 0x%x\n", ret); + if (verbose || !(make_addr || make_opts) || ret) + printf("return status 0x%x\n", ret); return ret; } diff --git a/windows/acme_windows.c b/windows/acme_windows.c index 52fae7b..8b2397e 100644 --- a/windows/acme_windows.c +++ b/windows/acme_windows.c @@ -34,6 +34,7 @@ extern struct ibv_context **verbs; extern int dev_cnt; +extern int verbose; int gen_addr_ip(FILE *f) { @@ -77,8 +78,10 @@ int gen_addr_ip(FILE *f) for (i = 0; i < dev_cnt; i++) { if (devaddr.DeviceGuid == ibv_get_device_guid(verbs[i]->device)) { - printf("%s %s %d 0x%x\n", ip, verbs[i]->device->name, - devaddr.PortNumber, ntohs(devaddr.Pkey)); + if (verbose) { + printf("%s %s %d 0x%x\n", ip, verbs[i]->device->name, + devaddr.PortNumber, ntohs(devaddr.Pkey)); + } fprintf(f, "%s %s %d 0x%x\n", ip, verbs[i]->device->name, devaddr.PortNumber, ntohs(devaddr.Pkey)); } -- 2.46.0