Skip to contentSkip to conversation

LVM tools return ECMD_FAILED when they shouldn't (exported vg)

linux-lvm Oren Held 1 participant 1 message Jul 25, 2010

lore
Share & tools
lore

Oren Held

author
#0 lore raw

Hi All,

We have encountered an unexpected behavior, in which 'lvs' command behaves well (lists the LV's) but still returns rc==5. Well, the reason is that we've had an exported vg. It's indeed something the user might care about, yet its severity should be less than other "failed command" situations.

What I suggest, is adding a new error type "EXPORTED_VG_WARNING", for these cases, that would be returned by toollib.c's process_each_lv_in_vg() function in this specific case of failure-because-vg-is-exported.

I've used error number 4 (it seemed available), because the erroring mechanism in process_each_lv cares about the error number's value, so it should be lower than ECMD_FAILED.

Attached is the patch.

Best Regards

Oren Held

? doc/example.conf
? include/.symlinks
? lib/misc/lvm-version.h
? libdm/.exported_symbols_generated
? libdm/ioctl/libdevmapper.so.1.02
? scripts/clvmd_init_red_hat
? scripts/cmirrord_init_red_hat
? scripts/lvm2_monitoring_init_red_hat
? tools/dmsetup
? tools/lvm
Index: lib/commands/errors.h
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/commands/errors.h,v
retrieving revision 1.6

commands/errors.h +1 -0
diff -u -r1.6 errors.h
@@ -19,6 +19,7 @@
 #define ECMD_PROCESSED		1
 #define ENO_SUCH_CMD		2
 #define EINVALID_CMD_LINE	3
+#define ECMD_EXPORTED_VG	4
 #define ECMD_FAILED		5
 
 /* FIXME Also returned by cmdlib. */

Index: tools/toollib.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/toollib.c,v
retrieving revision 1.207

toollib.c +1 -1
diff -u -r1.207 toollib.c
@@ -101,7 +101,7 @@
 	struct lv_list *lvl;
 
 	if (!vg_check_status(vg, EXPORTED_VG))
-		return ECMD_FAILED;
+		return ECMD_EXPORTED_VG;
 
 	if (tags && !dm_list_empty(tags))
 		tags_supplied = 1;