summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cache/lvmetad.c2
-rw-r--r--lib/commands/toolcontext.c5
-rw-r--r--lib/commands/toolcontext.h1
-rw-r--r--lib/config/defaults.h1
-rw-r--r--lib/display/display.c2
-rw-r--r--lib/log/log.h1
-rw-r--r--lib/metadata/lv_manip.c14
-rw-r--r--lib/metadata/metadata.c10
-rw-r--r--lib/metadata/mirror.c4
-rw-r--r--lib/metadata/raid_manip.c13
-rw-r--r--lib/misc/lvm-globals.c13
-rw-r--r--lib/misc/lvm-globals.h2
12 files changed, 44 insertions, 24 deletions
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 6e1759b4..feab3611 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -710,7 +710,7 @@ int pvscan_lvmetad_single(struct cmd_context *cmd, struct device *dev,
}
if (!label_read(dev, &label, 0)) {
- log_print("No PV label found on %s.", dev_name(dev));
+ log_print_unless_silent("No PV label found on %s.", dev_name(dev));
if (!lvmetad_pv_gone_by_dev(dev, handler))
goto_bad;
return 1;
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 529bd51e..57667b64 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -144,6 +144,11 @@ static void _init_logging(struct cmd_context *cmd)
find_config_tree_int(cmd, "log/level", DEFAULT_LOGLEVEL);
init_debug(cmd->default_settings.debug);
+ /* Suppress all non-essential stdout? */
+ cmd->default_settings.silent =
+ find_config_tree_int(cmd, "log/silent", DEFAULT_SILENT);
+ init_silent(cmd->default_settings.silent);
+
/* Verbose level for tty output */
cmd->default_settings.verbose =
find_config_tree_int(cmd, "log/verbose", DEFAULT_VERBOSE);
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 6fba6869..e0ef0411 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -27,6 +27,7 @@
struct config_info {
int debug;
int verbose;
+ int silent;
int test;
int syslog;
int activation;
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index bee3d563..9730a2d7 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -111,6 +111,7 @@
#define DEFAULT_SYSLOG 1
#define DEFAULT_VERBOSE 0
+#define DEFAULT_SILENT 0
#define DEFAULT_LOGLEVEL 0
#define DEFAULT_INDENT 1
#define DEFAULT_ABORT_ON_INTERNAL_ERRORS 0
diff --git a/lib/display/display.c b/lib/display/display.c
index 8ceb4495..2422b51e 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -935,7 +935,7 @@ char yes_no_prompt(const char *prompt, ...)
sigint_restore();
if (c != '\n')
- printf("\n");
+ fprintf(stderr, "\n");
return ret;
}
diff --git a/lib/log/log.h b/lib/log/log.h
index 0071a337..f0da64f3 100644
--- a/lib/log/log.h
+++ b/lib/log/log.h
@@ -68,6 +68,7 @@
#define log_very_verbose(args...) log_info(args)
#define log_verbose(args...) log_notice(args)
#define log_print(args...) LOG_LINE(_LOG_WARN, args)
+#define log_print_unless_silent(args...) LOG_LINE(silent_mode() ? _LOG_NOTICE : _LOG_WARN, args)
#define log_error(args...) log_err(args)
#define log_error_suppress(s, args...) log_err_suppress(s, args)
#define log_error_once(args...) log_err_once(args)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 59e14291..d591b7b5 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -2152,8 +2152,8 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status,
size = ((uint64_t)lv->vg->extent_size * extents + size - 1) /
size * size / lv->vg->extent_size;
if (size != extents) {
- log_print("Rounding size (%d extents) up to chunk boundary "
- "size (%d extents).", extents, size);
+ log_print_unless_silent("Rounding size (%d extents) up to chunk boundary "
+ "size (%d extents).", extents, size);
extents = size;
}
}
@@ -2738,7 +2738,7 @@ int lv_extend(struct logical_volume *lv,
percent_t sync_percent = PERCENT_INVALID;
if (!lv_is_active(lv)) {
- log_print("%s/%s is not active."
+ log_error("%s/%s is not active."
" Unable to get sync percent.",
lv->vg->name, lv->name);
if (yes_no_prompt("Do full resync of extended "
@@ -3378,7 +3378,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
backup(vg);
if (visible)
- log_print("Logical volume \"%s\" successfully removed", lv->name);
+ log_print_unless_silent("Logical volume \"%s\" successfully removed", lv->name);
return 1;
}
@@ -4207,8 +4207,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
}
if ((size_rest = lp->extents % lp->stripes)) {
- log_print("Rounding size (%d extents) up to stripe boundary "
- "size (%d extents)", lp->extents,
+ log_print_unless_silent("Rounding size (%d extents) up to stripe boundary "
+ "size (%d extents)", lp->extents,
lp->extents - size_rest + lp->stripes);
lp->extents = lp->extents - size_rest + lp->stripes;
}
@@ -4650,7 +4650,7 @@ int lv_create_single(struct volume_group *vg,
return_0;
out:
- log_print("Logical volume \"%s\" created", lv->name);
+ log_print_unless_silent("Logical volume \"%s\" created", lv->name);
return 1;
}
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 205f77ea..220e0c15 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -623,7 +623,7 @@ int vg_remove(struct volume_group *vg)
stack;
if (ret)
- log_print("Volume group \"%s\" successfully removed", vg->name);
+ log_print_unless_silent("Volume group \"%s\" successfully removed", vg->name);
else
log_error("Volume group \"%s\" not properly removed", vg->name);
@@ -988,8 +988,8 @@ uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
{
if (size % extent_size) {
size += extent_size - size % extent_size;
- log_print("Rounding up size to full physical extent %s",
- display_size(cmd, size));
+ log_print_unless_silent("Rounding up size to full physical extent %s",
+ display_size(cmd, size));
}
if (size > (uint64_t) MAX_EXTENT_COUNT * extent_size) {
@@ -1305,7 +1305,7 @@ static int _wipe_sb(struct device *dev, const char *type, const char *name,
return 0;
}
- log_print("Wiping %s on %s.", type, name);
+ log_print_unless_silent("Wiping %s on %s.", type, name);
if (!dev_set(dev, superblock, wipe_len, 0)) {
log_error("Failed to wipe %s on %s.", type, name);
return 0;
@@ -1477,7 +1477,7 @@ static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_create *pvc)
return 0;
}
- log_print("Physical volume \"%s\" successfully created", pv_name);
+ log_print_unless_silent("Physical volume \"%s\" successfully created", pv_name);
return 1;
}
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index e3662c12..c4683dff 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -168,8 +168,8 @@ uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
if (region_max < UINT32_MAX && region_size > region_max) {
region_size = (uint32_t) region_max;
- log_print("Using reduced mirror region size of %" PRIu32
- " sectors", region_size);
+ log_print_unless_silent("Using reduced mirror region size of %" PRIu32
+ " sectors", region_size);
}
return region_size;
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 0d4640f5..11888911 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1311,8 +1311,8 @@ int lv_raid_split_and_track(struct logical_volume *lv,
return 0;
}
- log_print("%s split from %s for read-only purposes.",
- seg_lv(seg, s)->name, lv->name);
+ log_print_unless_silent("%s split from %s for read-only purposes.",
+ seg_lv(seg, s)->name, lv->name);
/* Resume original LV */
if (!resume_lv(lv->vg->cmd, lv)) {
@@ -1325,8 +1325,8 @@ int lv_raid_split_and_track(struct logical_volume *lv,
if (!_activate_sublv_preserving_excl(lv, seg_lv(seg, s)))
return 0;
- log_print("Use 'lvconvert --merge %s/%s' to merge back into %s",
- lv->vg->name, seg_lv(seg, s)->name, lv->name);
+ log_print_unless_silent("Use 'lvconvert --merge %s/%s' to merge back into %s",
+ lv->vg->name, seg_lv(seg, s)->name, lv->name);
return 1;
}
@@ -1410,9 +1410,8 @@ int lv_raid_merge(struct logical_volume *image_lv)
return 0;
}
- log_print("%s/%s successfully merged back into %s/%s",
- vg->name, image_lv->name,
- vg->name, lv->name);
+ log_print_unless_silent("%s/%s successfully merged back into %s/%s",
+ vg->name, image_lv->name, vg->name, lv->name);
return 1;
}
diff --git a/lib/misc/lvm-globals.c b/lib/misc/lvm-globals.c
index 1c72f85a..fe380089 100644
--- a/lib/misc/lvm-globals.c
+++ b/lib/misc/lvm-globals.c
@@ -23,6 +23,7 @@
#include <stdarg.h>
static int _verbose_level = VERBOSE_BASE_LEVEL;
+static int _silent = 0;
static int _test = 0;
static int _md_filtering = 0;
static int _pvmove = 0;
@@ -54,10 +55,15 @@ void init_verbose(int level)
_verbose_level = level;
}
+void init_silent(int silent)
+{
+ _silent = silent;
+}
+
void init_test(int level)
{
if (!_test && level)
- log_print("Test mode: Metadata will NOT be updated and volumes will not be (de)activated.");
+ log_warn("TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.");
_test = level;
}
@@ -267,6 +273,11 @@ int debug_level(void)
return _debug_level;
}
+int silent_mode(void)
+{
+ return _silent;
+}
+
unsigned is_static(void)
{
return _is_static;
diff --git a/lib/misc/lvm-globals.h b/lib/misc/lvm-globals.h
index 3ffdec4a..7fe3288e 100644
--- a/lib/misc/lvm-globals.h
+++ b/lib/misc/lvm-globals.h
@@ -21,6 +21,7 @@
#define PV_MIN_SIZE_KB 512
void init_verbose(int level);
+void init_silent(int silent);
void init_test(int level);
void init_md_filtering(int level);
void init_pvmove(int level);
@@ -55,6 +56,7 @@ int full_scan_done(void);
int obtain_device_list_from_udev(void);
int trust_cache(void);
int verbose_level(void);
+int silent_mode(void);
int debug_level(void);
int ignorelockingfailure(void);
int lockingfailed(void);