summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2014-10-21 16:42:27 -0500
committerDavid Teigland <teigland@redhat.com>2014-10-21 16:42:27 -0500
commit0505a6b2f156f82d8426eb714ba05d791de53ac5 (patch)
tree2311c96f6ffb54491c8e2a0b990fc11e48377b8d
parent9b187a2c48e11e0846fee0d6b656a2c39cf245f2 (diff)
downloadlvm2-0505a6b2f156f82d8426eb714ba05d791de53ac5.tar.gz
toollib: command should fail if ignoring named arg
If a foreign VG is ignored when it's included by "all vgs", then the command shouldn't fail. If a foreign VG is ignored when it's named explicitly as a command arg, then the command should fail.
-rw-r--r--tools/reporter.c4
-rw-r--r--tools/toollib.c25
-rw-r--r--tools/toollib.h3
3 files changed, 24 insertions, 8 deletions
diff --git a/tools/reporter.c b/tools/reporter.c
index c8a394023..1fca9bf32 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -230,7 +230,7 @@ static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name,
{
int ret = ECMD_PROCESSED;
- if (ignore_vg(vg, vg_name, 0, &ret)) {
+ if (ignore_vg(cmd, vg, vg_name, NULL, 0, &ret)) {
stack;
return ret;
}
@@ -244,7 +244,7 @@ static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name,
{
int ret = ECMD_PROCESSED;
- if (ignore_vg(vg, vg_name, 0, &ret)) {
+ if (ignore_vg(cmd, vg, vg_name, NULL, 0, &ret)) {
stack;
return ret;
}
diff --git a/tools/toollib.c b/tools/toollib.c
index 451bb8efc..36975b0e6 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -160,7 +160,8 @@ const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
/*
* Returns 1 if VG should be ignored.
*/
-int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsistent, int *ret)
+int ignore_vg(struct cmd_context *cmd, struct volume_group *vg, const char *vg_name,
+ struct dm_list *arg_vgnames, int allow_inconsistent, int *ret)
{
uint32_t read_error = vg_read_error(vg);
@@ -170,8 +171,21 @@ int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsiste
if ((read_error == FAILED_INCONSISTENT) && allow_inconsistent)
return 0;
- if (read_error == FAILED_SYSTEMID)
+ /*
+ * Commands that operate on "all vgs" shouldn't be bothered by
+ * skipping a foreign VG, and the command shouldn't fail when
+ * one is skipped. But, if the command explicitly asked to
+ * operate on a foreign VG and it's skipped, then the command
+ * would expect to fail.
+ */
+ if (read_error == FAILED_SYSTEMID) {
+ if (arg_vgnames && str_list_match_item(arg_vgnames, vg->name)) {
+ log_error("Skipping volume group %s with system id %s",
+ vg->name, vg->system_id);
+ *ret = ECMD_FAILED;
+ }
return 1;
+ }
if (read_error == FAILED_NOTFOUND)
*ret = ECMD_FAILED;
@@ -1470,9 +1484,10 @@ static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
ret = 0;
vg = vg_read(cmd, vg_name, vg_uuid, flags);
- if (ignore_vg(vg, vg_name, flags & READ_ALLOW_INCONSISTENT, &ret)) {
+ if (ignore_vg(cmd, vg, vg_name, arg_vgnames, flags & READ_ALLOW_INCONSISTENT, &ret)) {
if (ret > ret_max)
ret_max = ret;
+
release_vg(vg);
stack;
continue;
@@ -1842,7 +1857,7 @@ static int _process_lv_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
}
vg = vg_read(cmd, vg_name, vg_uuid, flags);
- if (ignore_vg(vg, vg_name, flags & READ_ALLOW_INCONSISTENT, &ret)) {
+ if (ignore_vg(cmd, vg, vg_name, arg_vgnames, flags & READ_ALLOW_INCONSISTENT, &ret)) {
if (ret > ret_max)
ret_max = ret;
release_vg(vg);
@@ -2158,7 +2173,7 @@ static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t flags,
skip = 0;
vg = vg_read(cmd, vg_name, vg_uuid, flags | READ_WARN_INCONSISTENT);
- if (ignore_vg(vg, vg_name, flags & READ_ALLOW_INCONSISTENT, &ret)) {
+ if (ignore_vg(cmd, vg, vg_name, NULL, flags & READ_ALLOW_INCONSISTENT, &ret)) {
if (ret > ret_max)
ret_max = ret;
skip = 1;
diff --git a/tools/toollib.h b/tools/toollib.h
index 50cc26c1e..dcae5034e 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -20,7 +20,8 @@
int become_daemon(struct cmd_context *cmd, int skip_lvm);
-int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsistent, int *ret);
+int ignore_vg(struct cmd_context *cmd, struct volume_group *vg, const char *vg_name,
+ struct dm_list *arg_vgnames, int allow_inconsistent, int *ret);
typedef int (*process_single_vg_fn_t) (struct cmd_context * cmd,
const char *vg_name,