All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Add vg/lv tag addition/deletion to lvm2app, v2
@ 2010-02-17 17:28 Dave Wysochanski
  2010-02-17 17:28 ` [PATCH 1/8] Refactor _vgchange_tag() to vg_change_tag() library function Dave Wysochanski
  0 siblings, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-17 17:28 UTC (permalink / raw)
  To: lvm-devel


This is a second iteration of the lv/vg tag add/delete to lvm2app.
pv tags will be handled later when the pv refactoring patches
are done since they need the pv->vg link for the vgmem handle.
Partially fixes rhbz 562909.

Changes since last set:
1) Address all feedback; change return of 'get' fns to NULL if problem
obtaining list, empty list if no tags; use dm_pool_strdup, return_0, etc
2) Patch #5, Add tag_list_copy() supporting function; re-use code that
duplicates the tag list



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/8] Refactor _vgchange_tag() to vg_change_tag() library function.
  2010-02-17 17:28 [PATCH 0/8] Add vg/lv tag addition/deletion to lvm2app, v2 Dave Wysochanski
@ 2010-02-17 17:28 ` Dave Wysochanski
  2010-02-17 17:28   ` [PATCH 2/8] Refactor vgcreate to call new vg_change_tag() function Dave Wysochanski
  0 siblings, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-17 17:28 UTC (permalink / raw)
  To: lvm-devel

Pull out common code to be called from tools as well as lvm2app.
Leave archive() at tool level so we can use from vgcreate
as well as vgchange.  Should be no functional change.
- add stack macro in vgchange

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 lib/metadata/metadata-exported.h |    1 +
 lib/metadata/metadata.c          |   23 +++++++++++++++++++++++
 tools/vgchange.c                 |   20 +++-----------------
 3 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 164ce36..fae9551 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -463,6 +463,7 @@ int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names,
 	      struct pvcreate_params *pp);
 int vg_reduce(struct volume_group *vg, char *pv_name);
+int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag);
 int vg_set_extent_size(struct volume_group *vg, uint32_t new_extent_size);
 int vg_set_max_lv(struct volume_group *vg, uint32_t max_lv);
 int vg_set_max_pv(struct volume_group *vg, uint32_t max_pv);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index b3b3778..52bbc46 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -665,6 +665,29 @@ int vg_reduce(struct volume_group *vg, char *pv_name)
 	return 0;
 }
 
+int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag)
+{
+	if (!(vg->fid->fmt->features & FMT_TAGS)) {
+		log_error("Volume group %s does not support tags", vg->name);
+		return 0;
+	}
+
+	if (add_tag) {
+		if (!str_list_add(vg->vgmem, &vg->tags, tag)) {
+			log_error("Failed to add tag %s to volume group %s",
+				  tag, vg->name);
+			return 0;
+		}
+	} else {
+		if (!str_list_del(&vg->tags, tag)) {
+			log_error("Failed to remove tag %s from volume group "
+				  "%s", tag, vg->name);
+			return 0;
+		}
+	}
+	return 1;
+}
+
 const char *strip_dir(const char *vg_name, const char *dev_dir)
 {
 	size_t len = strlen(dev_dir);
diff --git a/tools/vgchange.c b/tools/vgchange.c
index b4f5d00..6d869f9 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -447,28 +447,14 @@ static int _vgchange_tag(struct cmd_context *cmd, struct volume_group *vg,
 		return ECMD_FAILED;
 	}
 
-	if (!(vg->fid->fmt->features & FMT_TAGS)) {
-		log_error("Volume group %s does not support tags", vg->name);
-		return ECMD_FAILED;
-	}
-
 	if (!archive(vg)) {
 		stack;
 		return ECMD_FAILED;
 	}
 
-	if ((arg == addtag_ARG)) {
-		if (!str_list_add(cmd->mem, &vg->tags, tag)) {
-			log_error("Failed to add tag %s to volume group %s",
-				  tag, vg->name);
-			return ECMD_FAILED;
-		}
-	} else {
-		if (!str_list_del(&vg->tags, tag)) {
-			log_error("Failed to remove tag %s from volume group "
-				  "%s", tag, vg->name);
-			return ECMD_FAILED;
-		}
+	if (!vg_change_tag(vg, tag, arg == addtag_ARG)) {
+		stack;
+		return ECMD_FAILED;
 	}
 
 	if (!vg_write(vg) || !vg_commit(vg)) {
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/8] Refactor vgcreate to call new vg_change_tag() function.
  2010-02-17 17:28 ` [PATCH 1/8] Refactor _vgchange_tag() to vg_change_tag() library function Dave Wysochanski
@ 2010-02-17 17:28   ` Dave Wysochanski
  2010-02-17 17:28     ` [PATCH 3/8] Refactor lvchange_tag() to call lv_change_tag() library function Dave Wysochanski
  0 siblings, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-17 17:28 UTC (permalink / raw)
  To: lvm-devel

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 tools/vgcreate.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 5113b1f..6087145 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -94,16 +94,8 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
 			goto bad;
 		}
 
-		if (!(vg->fid->fmt->features & FMT_TAGS)) {
-			log_error("Volume group format does not support tags");
-			goto bad;
-		}
-
-		if (!str_list_add(cmd->mem, &vg->tags, tag)) {
-			log_error("Failed to add tag %s to volume group %s",
-				  tag, vp_new.vg_name);
-			goto bad;
-		}
+		if (!vg_change_tag(vg, tag, 1))
+			goto_bad;
 	}
 
 	if (vg_is_clustered(vg)) {
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 3/8] Refactor lvchange_tag() to call lv_change_tag() library function.
  2010-02-17 17:28   ` [PATCH 2/8] Refactor vgcreate to call new vg_change_tag() function Dave Wysochanski
@ 2010-02-17 17:28     ` Dave Wysochanski
  2010-02-17 17:29       ` [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag() Dave Wysochanski
  0 siblings, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-17 17:28 UTC (permalink / raw)
  To: lvm-devel

Similar refactoring to vgchange - pull out common parts and put into
library function for reuse.  Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 lib/metadata/metadata-exported.h |    2 ++
 lib/metadata/metadata.c          |   24 ++++++++++++++++++++++++
 tools/lvchange.c                 |   21 ++-------------------
 3 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index fae9551..9540285 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -493,6 +493,8 @@ struct logical_volume *lv_create_empty(const char *name,
 int set_lv(struct cmd_context *cmd, struct logical_volume *lv,
            uint64_t sectors, int value);
 
+int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag);
+
 /* Reduce the size of an LV by extents */
 int lv_reduce(struct logical_volume *lv, uint32_t extents);
 
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 52bbc46..2b8a1be 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -665,6 +665,30 @@ int vg_reduce(struct volume_group *vg, char *pv_name)
 	return 0;
 }
 
+int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
+{
+	if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
+		log_error("Logical volume %s/%s does not support tags",
+			  lv->vg->name, lv->name);
+		return 0;
+	}
+
+	if (add_tag) {
+		if (!str_list_add(lv->vg->vgmem, &lv->tags, tag)) {
+			log_error("Failed to add tag %s to %s/%s",
+				  tag, lv->vg->name, lv->name);
+			return 0;
+		}
+	} else {
+		if (!str_list_del(&lv->tags, tag)) {
+			log_error("Failed to remove tag %s from %s/%s",
+				  tag, lv->vg->name, lv->name);
+			return 0;
+		}
+	}
+	return 1;
+}
+
 int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag)
 {
 	if (!(vg->fid->fmt->features & FMT_TAGS)) {
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 5118e51..2d7955e 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -500,25 +500,8 @@ static int lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv,
 		return 0;
 	}
 
-	if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
-		log_error("Logical volume %s/%s does not support tags",
-			  lv->vg->name, lv->name);
-		return 0;
-	}
-
-	if ((arg == addtag_ARG)) {
-		if (!str_list_add(cmd->mem, &lv->tags, tag)) {
-			log_error("Failed to add tag %s to %s/%s",
-				  tag, lv->vg->name, lv->name);
-			return 0;
-		}
-	} else {
-		if (!str_list_del(&lv->tags, tag)) {
-			log_error("Failed to remove tag %s from %s/%s",
-				  tag, lv->vg->name, lv->name);
-			return 0;
-		}
-	}
+	if (!lv_change_tag(lv, tag, arg == addtag_ARG))
+		return_0;
 
 	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
 
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag()
  2010-02-17 17:28     ` [PATCH 3/8] Refactor lvchange_tag() to call lv_change_tag() library function Dave Wysochanski
@ 2010-02-17 17:29       ` Dave Wysochanski
  2010-02-17 17:29         ` [PATCH 5/8] Add tag_list_copy() supporting function inside lvm2app Dave Wysochanski
  2010-02-18  8:55         ` [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag() Zdenek Kabelac
  0 siblings, 2 replies; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-17 17:29 UTC (permalink / raw)
  To: lvm-devel

We need to allocate memory for the tag and copy the tag value before we
add it to the list of tags.  We could put this inside lvm2app since the
tools keep their memory around until vg_write/vg_commit is called, but
we put it inside the internal library to minimize code in lvm2app.
We need to copy the tag passed in by the caller to ensure the lifetime of
the memory until the {vg|lv} handle is released.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 lib/metadata/metadata.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 2b8a1be..2667e90 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -667,6 +667,8 @@ int vg_reduce(struct volume_group *vg, char *pv_name)
 
 int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
 {
+	char *tag_new;
+
 	if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
 		log_error("Logical volume %s/%s does not support tags",
 			  lv->vg->name, lv->name);
@@ -674,7 +676,10 @@ int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
 	}
 
 	if (add_tag) {
-		if (!str_list_add(lv->vg->vgmem, &lv->tags, tag)) {
+		if (!(tag_new = dm_pool_strdup(lv->vg->vgmem, tag))) {
+			return_0;
+		}
+		if (!str_list_add(lv->vg->vgmem, &lv->tags, tag_new)) {
 			log_error("Failed to add tag %s to %s/%s",
 				  tag, lv->vg->name, lv->name);
 			return 0;
@@ -691,13 +696,18 @@ int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
 
 int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag)
 {
+	char *tag_new;
+
 	if (!(vg->fid->fmt->features & FMT_TAGS)) {
 		log_error("Volume group %s does not support tags", vg->name);
 		return 0;
 	}
 
 	if (add_tag) {
-		if (!str_list_add(vg->vgmem, &vg->tags, tag)) {
+		if (!(tag_new = dm_pool_strdup(vg->vgmem, tag))) {
+			return_0;
+		}
+		if (!str_list_add(vg->vgmem, &vg->tags, tag_new)) {
 			log_error("Failed to add tag %s to volume group %s",
 				  tag, vg->name);
 			return 0;
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5/8] Add tag_list_copy() supporting function inside lvm2app.
  2010-02-17 17:29       ` [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag() Dave Wysochanski
@ 2010-02-17 17:29         ` Dave Wysochanski
  2010-02-17 17:29           ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Dave Wysochanski
  2010-02-18  8:55         ` [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag() Zdenek Kabelac
  1 sibling, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-17 17:29 UTC (permalink / raw)
  To: lvm-devel

Add a supporting function to copy a list of internal tags to lvm2app list.
We need to put this here because of the lvm_str_list_t type which we export
in lvm2app.h.  If we didn't export this type, we could put this in the
internal library and use struct str_list.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/Makefile.in |    1 +
 liblvm/lvm_misc.c  |   43 +++++++++++++++++++++++++++++++++++++++++++
 liblvm/lvm_misc.h  |   29 +++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 0 deletions(-)
 create mode 100644 liblvm/lvm_misc.c
 create mode 100644 liblvm/lvm_misc.h

diff --git a/liblvm/Makefile.in b/liblvm/Makefile.in
index d9afc40..5e6dfd4 100644
--- a/liblvm/Makefile.in
+++ b/liblvm/Makefile.in
@@ -18,6 +18,7 @@ top_builddir = @top_builddir@
 VPATH = @srcdir@
 
 SOURCES =\
+	lvm_misc.c \
 	lvm_base.c \
 	lvm_lv.c \
 	lvm_pv.c \
diff --git a/liblvm/lvm_misc.c b/liblvm/lvm_misc.c
new file mode 100644
index 0000000..f52c563
--- /dev/null
+++ b/liblvm/lvm_misc.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2008,2010 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "lvm_misc.h"
+
+struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list)
+{
+	struct dm_list *list;
+	lvm_str_list_t *lsl;
+	struct str_list *sl;
+
+	if (!(list = dm_pool_zalloc(p, sizeof(*list)))) {
+		log_errno(ENOMEM, "Memory allocation fail for dm_list.");
+		return NULL;
+	}
+	dm_list_init(list);
+
+	dm_list_iterate_items(sl, tag_list) {
+		if (!(lsl = dm_pool_zalloc(p, sizeof(*lsl)))) {
+			log_errno(ENOMEM,
+				"Memory allocation fail for lvm_lv_list.");
+			return NULL;
+		}
+		if (!(lsl->str = dm_pool_strdup(p, sl->str))) {
+			log_errno(ENOMEM,
+				"Memory allocation fail for lvm_lv_list->str.");
+			return NULL;
+		}
+		dm_list_add(list, &lsl->list);
+	}
+	return list;
+}
diff --git a/liblvm/lvm_misc.h b/liblvm/lvm_misc.h
new file mode 100644
index 0000000..1d73532
--- /dev/null
+++ b/liblvm/lvm_misc.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2008,2010 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifndef _LVM2APP_MISC_H
+#define _LVM2APP_MISC_H
+
+#include "lib.h"
+#include "lvm2app.h"
+#include "toolcontext.h"
+#include "metadata-exported.h"
+#include "archiver.h"
+#include "locking.h"
+#include "lvm-string.h"
+#include "lvmcache.h"
+#include "metadata.h"
+
+struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list);
+
+#endif
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag().
  2010-02-17 17:29         ` [PATCH 5/8] Add tag_list_copy() supporting function inside lvm2app Dave Wysochanski
@ 2010-02-17 17:29           ` Dave Wysochanski
  2010-02-17 17:29             ` [PATCH 7/8] Add lvm_lv_get_tags(), lvm_lv_add_tag(), and lvm_lv_remove_tag() Dave Wysochanski
  2010-02-18  9:05             ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Zdenek Kabelac
  0 siblings, 2 replies; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-17 17:29 UTC (permalink / raw)
  To: lvm-devel

Add lvm2app functions to manage VG tags.
For lvm_vg_get_tags(), we return a list of tags, similar to other
functions that return lists.  An empty list is returned if there
are no VG tags.  NULL is returned if there is a problem obtaining
the list of tags.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/.exported_symbols |    3 ++
 liblvm/lvm2app.h         |   51 ++++++++++++++++++++++++++++++++++++++++++++-
 liblvm/lvm_vg.c          |   34 ++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/liblvm/.exported_symbols b/liblvm/.exported_symbols
index c184a88..7431248 100644
--- a/liblvm/.exported_symbols
+++ b/liblvm/.exported_symbols
@@ -18,6 +18,7 @@ lvm_vg_get_extent_size
 lvm_vg_get_extent_count
 lvm_vg_get_free_extent_count
 lvm_vg_get_pv_count
+lvm_vg_get_tags
 lvm_lv_activate
 lvm_lv_deactivate
 lvm_lv_get_uuid
@@ -33,6 +34,8 @@ lvm_vg_write
 lvm_vg_open
 lvm_vg_close
 lvm_vg_remove
+lvm_vg_add_tag
+lvm_vg_remove_tag
 lvm_scan
 lvm_errno
 lvm_errmsg
diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
index 39bfff8..41ce18c 100644
--- a/liblvm/lvm2app.h
+++ b/liblvm/lvm2app.h
@@ -159,10 +159,10 @@ typedef struct lvm_pv_list {
  * Lists of these structures are returned by lvm_list_vg_names and
  * lvm_list_vg_uuids.
  */
-struct lvm_str_list {
+typedef struct lvm_str_list {
 	struct dm_list list;
 	const char *str;
-};
+} lvm_str_list_t;
 
 /*************************** generic lvm handling ***************************/
 /**
@@ -458,6 +458,26 @@ int lvm_vg_extend(vg_t vg, const char *device);
 int lvm_vg_reduce(vg_t vg, const char *device);
 
 /**
+ * Add/remove a tag to/from a VG.
+ *
+ * These functions require calling lvm_vg_write to commit the change to disk.
+ * After successfully adding/removing a tag, use lvm_vg_write to commit the
+ * new VG to disk.  Upon failure, retry the operation or release the VG handle
+ * with lvm_vg_close.
+ *
+ * \param   vg
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \param   tag
+ * Tag to add/remove to/from VG.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
+ */
+int lvm_vg_add_tag(vg_t vg, const char *tag);
+int lvm_vg_remove_tag(vg_t vg, const char *tag);
+
+/**
  * Set the extent size of a VG.
  *
  * This function requires calling lvm_vg_write to commit the change to disk.
@@ -644,6 +664,33 @@ uint64_t lvm_vg_get_max_pv(const vg_t vg);
  */
 uint64_t lvm_vg_get_max_lv(const vg_t vg);
 
+/**
+ * Return the list of volume group tags.
+ *
+ * The memory allocated for the list is tied to the vg_t handle and will be
+ * released when lvm_vg_close is called.
+ *
+ * To process the list, use the dm_list iterator functions.  For example:
+ *      vg_t vg;
+ *      struct dm_list *tags;
+ *      struct lvm_str_list *strl;
+ *
+ *      tags = lvm_vg_get_tags(vg);
+ *	dm_list_iterate_items(strl, tags) {
+ *		tag = strl->str;
+ *              // do something with tag
+ *      }
+ *
+ *
+ * \return
+ * A list with entries of type struct lvm_str_list, containing the
+ * tag strings attached to volume group.
+ * If no tags are attached to the given VG, an empty list is returned
+ * (check with dm_list_empty()).
+ * If there is a problem obtaining the list of tags, NULL is returned.
+ */
+struct dm_list *lvm_vg_get_tags(const vg_t vg);
+
 /************************** logical volume handling *************************/
 
 /**
diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c
index 0c166d5..ec829e8 100644
--- a/liblvm/lvm_vg.c
+++ b/liblvm/lvm_vg.c
@@ -21,10 +21,39 @@
 #include "lvm-string.h"
 #include "lvmcache.h"
 #include "metadata.h"
+#include "lvm_misc.h"
 
 #include <errno.h>
 #include <string.h>
 
+int lvm_vg_add_tag(vg_t vg, const char *tag)
+{
+	if (vg_read_error(vg))
+		return -1;
+
+	if (!vg_check_write_mode(vg))
+		return -1;
+
+	if (!vg_change_tag(vg, tag, 1))
+		return -1;
+	return 0;
+}
+
+
+int lvm_vg_remove_tag(vg_t vg, const char *tag)
+{
+	if (vg_read_error(vg))
+		return -1;
+
+	if (!vg_check_write_mode(vg))
+		return -1;
+
+	if (!vg_change_tag(vg, tag, 0))
+		return -1;
+	return 0;
+}
+
+
 vg_t lvm_vg_create(lvm_t libh, const char *vg_name)
 {
 	struct volume_group *vg;
@@ -233,6 +262,11 @@ struct dm_list *lvm_vg_list_lvs(vg_t vg)
 	return list;
 }
 
+struct dm_list *lvm_vg_get_tags(const vg_t vg)
+{
+	return tag_list_copy(vg->vgmem, &vg->tags);
+}
+
 uint64_t lvm_vg_get_seqno(const vg_t vg)
 {
 	return vg_seqno(vg);
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 7/8] Add lvm_lv_get_tags(), lvm_lv_add_tag(), and lvm_lv_remove_tag().
  2010-02-17 17:29           ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Dave Wysochanski
@ 2010-02-17 17:29             ` Dave Wysochanski
  2010-02-17 17:29               ` [PATCH 8/8] Update lvm2app interactive unit test for vg/lv tags Dave Wysochanski
  2010-02-18  9:05             ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Zdenek Kabelac
  1 sibling, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-17 17:29 UTC (permalink / raw)
  To: lvm-devel

Add lvm2app functions to manage LV tags.
For lvm_lv_get_tags(), we return a list of tags, similar to other
functions that return lists.  An empty list is returned if there
are no tags.  NULL is returned if there is a problem obtaining
the list of tags.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/.exported_symbols |    3 ++
 liblvm/lvm2app.h         |   48 ++++++++++++++++++++++++++++++++++++++++++++++
 liblvm/lvm_lv.c          |   35 +++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/liblvm/.exported_symbols b/liblvm/.exported_symbols
index 7431248..9b61d45 100644
--- a/liblvm/.exported_symbols
+++ b/liblvm/.exported_symbols
@@ -26,6 +26,9 @@ lvm_lv_get_name
 lvm_lv_get_size
 lvm_lv_is_active
 lvm_lv_is_suspended
+lvm_lv_add_tag
+lvm_lv_remove_tag
+lvm_lv_get_tags
 lvm_vg_create
 lvm_vg_extend
 lvm_vg_reduce
diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
index 41ce18c..e052301 100644
--- a/liblvm/lvm2app.h
+++ b/liblvm/lvm2app.h
@@ -835,6 +835,54 @@ uint64_t lvm_lv_is_active(const lv_t lv);
 uint64_t lvm_lv_is_suspended(const lv_t lv);
 
 /**
+ * Add/remove a tag to/from a LV.
+ *
+ * These functions require calling lvm_vg_write to commit the change to disk.
+ * After successfully adding/removing a tag, use lvm_vg_write to commit the
+ * new VG to disk.  Upon failure, retry the operation or release the VG handle
+ * with lvm_vg_close.
+ *
+ * \param   lv
+ * Logical volume handle.
+ *
+ * \param   tag
+ * Tag to add/remove to/from LV.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
+ */
+int lvm_lv_add_tag(lv_t lv, const char *tag);
+int lvm_lv_remove_tag(lv_t lv, const char *tag);
+
+/**
+ * Return the list of logical volume tags.
+ *
+ * The memory allocated for the list is tied to the vg_t handle and will be
+ * released when lvm_vg_close is called.
+ *
+ * To process the list, use the dm_list iterator functions.  For example:
+ *      lv_t lv;
+ *      struct dm_list *tags;
+ *      struct lvm_str_list *strl;
+ *
+ *      tags = lvm_lv_get_tags(lv);
+ *	dm_list_iterate_items(strl, tags) {
+ *		tag = strl->str;
+ *              // do something with tag
+ *      }
+ *
+ *
+ * \return
+ * A list with entries of type struct lvm_str_list, containing the
+ * tag strings attached to volume group.
+ * If no tags are attached to the LV, an empty list is returned
+ * (check with dm_list_empty()).
+ * If there is a problem obtaining the list of tags, NULL is returned.
+ */
+struct dm_list *lvm_lv_get_tags(const lv_t lv);
+
+
+/**
  * Resize logical volume to new_size bytes.
  *
  * NOTE: This function is currently not implemented.
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 7a37d2c..86175ae 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -20,9 +20,19 @@
 #include "segtype.h"
 #include "locking.h"
 #include "activate.h"
+#include "lvm_misc.h"
 
 #include <string.h>
 
+static int _lv_check_handle(const lv_t lv, const int vg_writeable)
+{
+	if (!lv || !lv->vg || vg_read_error(lv->vg))
+		return -1;
+	if (vg_writeable && !vg_check_write_mode(lv->vg))
+		return -1;
+	return 0;
+}
+
 /* FIXME: have lib/report/report.c _disp function call lv_size()? */
 uint64_t lvm_lv_get_size(const lv_t lv)
 {
@@ -68,6 +78,31 @@ uint64_t lvm_lv_is_suspended(const lv_t lv)
 	return 0;
 }
 
+int lvm_lv_add_tag(lv_t lv, const char *tag)
+{
+	if (_lv_check_handle(lv, 1))
+		return -1;
+	if (!lv_change_tag(lv, tag, 1))
+		return -1;
+	return 0;
+}
+
+
+int lvm_lv_remove_tag(lv_t lv, const char *tag)
+{
+	if (_lv_check_handle(lv, 1))
+		return -1;
+	if (!lv_change_tag(lv, tag, 0))
+		return -1;
+	return 0;
+}
+
+
+struct dm_list *lvm_lv_get_tags(const lv_t lv)
+{
+	return tag_list_copy(lv->vg->vgmem, &lv->tags);
+}
+
 /* Set defaults for non-segment specific LV parameters */
 static void _lv_set_default_params(struct lvcreate_params *lp,
 				   vg_t vg, const char *lvname,
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 8/8] Update lvm2app interactive unit test for vg/lv tags.
  2010-02-17 17:29             ` [PATCH 7/8] Add lvm_lv_get_tags(), lvm_lv_add_tag(), and lvm_lv_remove_tag() Dave Wysochanski
@ 2010-02-17 17:29               ` Dave Wysochanski
  2010-02-23 19:30                 ` [PATCH 0/4] Cleanup lvm2app.h doxygen documentation and add example Dave Wysochanski
  0 siblings, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-17 17:29 UTC (permalink / raw)
  To: lvm-devel

Simple test of vg/lv tag addition/deletion.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 test/api/test.c |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 102 insertions(+), 6 deletions(-)

diff --git a/test/api/test.c b/test/api/test.c
index 6e222da..8775dfb 100644
--- a/test/api/test.c
+++ b/test/api/test.c
@@ -89,6 +89,14 @@ static void _show_help(void)
 	       "Issue a lvm_config_reload() API to reload LVM config\n");
 	printf("'config_override' device: "
 	       "Issue a lvm_config_override() with accept device filter\n");
+	printf("'vg_get_tags vgname': "
+	       "List the tags of a VG\n");
+	printf("'lv_get_tags vgname lvname': "
+	       "List the tags of a LV\n");
+	printf("'vg_{add|remove}_tag vgname tag': "
+	       "Add/remove a tag from a VG\n");
+	printf("'lv_{add|remove}_tag vgname lvname tag': "
+	       "Add/remove a tag from a LV\n");
 	printf("'quit': exit the program\n");
 }
 
@@ -468,13 +476,11 @@ static void _list_vg_names(lvm_t libh)
 {
 	struct dm_list *list;
 	struct lvm_str_list *strl;
-	const char *tmp;
 
 	list = lvm_list_vg_names(libh);
 	printf("VG names:\n");
 	dm_list_iterate_items(strl, list) {
-		tmp = strl->str;
-		printf("%s\n", tmp);
+		printf("%s\n", strl->str);
 	}
 }
 
@@ -482,17 +488,94 @@ static void _list_vg_ids(lvm_t libh)
 {
 	struct dm_list *list;
 	struct lvm_str_list *strl;
-	const char *tmp;
 
 	list = lvm_list_vg_uuids(libh);
 	printf("VG uuids:\n");
 	dm_list_iterate_items(strl, list) {
-		tmp = strl->str;
-		printf("%s\n", tmp);
+		printf("%s\n", strl->str);
 	}
 }
 
+static void _display_tags(struct dm_list *list)
+{
+	struct lvm_str_list *strl;
+	if (dm_list_empty(list)) {
+		printf("No tags exist\n");
+		return;
+	} else if (!list) {
+		printf("Error obtaining tags\n");
+		return;
+	}
+	dm_list_iterate_items(strl, list) {
+		printf("%s\n", strl->str);
+	}
+}
+
+static void _vg_get_tags(char **argv, int argc)
+{
+	vg_t vg;
+
+	if (!(vg = _lookup_vg_by_name(argv, argc)))
+		return;
+	printf("VG tags:\n");
+	_display_tags(lvm_vg_get_tags(vg));
+}
+
+static void _vg_tag(char **argv, int argc, int add)
+{
+	vg_t vg;
 
+	if (argc < 3) {
+		printf("Please enter vgname, tag\n");
+		return;
+	}
+	if (!(vg = _lookup_vg_by_name(argv, argc)))
+		return;
+	if (add && lvm_vg_add_tag(vg, argv[2]))
+		printf("Error ");
+	else if (!add && lvm_vg_remove_tag(vg, argv[2])){
+		printf("Error ");
+	} else {
+		printf("Success ");
+	}
+	printf("%s tag %s to VG %s\n",
+	       add ? "adding":"removing", argv[2], argv[1]);
+}
+
+static void _lv_get_tags(char **argv, int argc)
+{
+	lv_t lv;
+
+	if (argc < 3) {
+		printf("Please enter vgname, lvname\n");
+		return;
+	}
+	if (!(lv = _lookup_lv_by_name(argv[2])))
+		return;
+	printf("LV tags:\n");
+	_display_tags(lvm_lv_get_tags(lv));
+}
+
+static void _lv_tag(char **argv, int argc, int add)
+{
+	lv_t lv;
+
+	if (argc < 3) {
+		printf("Please enter vgname, lvname\n");
+		return;
+	}
+	if (!(lv = _lookup_lv_by_name(argv[2])))
+		return;
+	if (add && lvm_lv_add_tag(lv, argv[3]))
+		printf("Error ");
+	else if (!add && lvm_lv_remove_tag(lv, argv[3])){
+		printf("Error ");
+	} else {
+		printf("Success ");
+	}
+	printf("%s tag %s to LV %s\n",
+	       add ? "adding":"removing", argv[3], argv[2]);
+}
 static void _lvs_in_vg(char **argv, int argc)
 {
 	struct dm_list *lvs;
@@ -549,6 +632,7 @@ static void _lv_activate(char **argv, int argc)
 	printf("activating LV %s in VG %s\n",
 		argv[2], argv[1]);
 }
+
 static void _vg_remove_lv(char **argv, int argc)
 {
 	lv_t lv;
@@ -670,6 +754,18 @@ static int lvmapi_test_shell(lvm_t libh)
 			_scan_vgs(libh);
 		} else if (!strcmp(argv[0], "vg_create_lv_linear")) {
 			_vg_create_lv_linear(argv, argc);
+		} else if (!strcmp(argv[0], "vg_add_tag")) {
+			_vg_tag(argv, argc, 1);
+		} else if (!strcmp(argv[0], "vg_remove_tag")) {
+			_vg_tag(argv, argc, 0);
+		} else if (!strcmp(argv[0], "vg_get_tags")) {
+			_vg_get_tags(argv, argc);
+		} else if (!strcmp(argv[0], "lv_add_tag")) {
+			_lv_tag(argv, argc, 1);
+		} else if (!strcmp(argv[0], "lv_remove_tag")) {
+			_lv_tag(argv, argc, 0);
+		} else if (!strcmp(argv[0], "lv_get_tags")) {
+			_lv_get_tags(argv, argc);
 		} else {
 			printf ("Unrecognized command %s\n", argv[0]);
 		}
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag()
  2010-02-17 17:29       ` [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag() Dave Wysochanski
  2010-02-17 17:29         ` [PATCH 5/8] Add tag_list_copy() supporting function inside lvm2app Dave Wysochanski
@ 2010-02-18  8:55         ` Zdenek Kabelac
  2010-02-18 12:17           ` Dave Wysochanski
  1 sibling, 1 reply; 19+ messages in thread
From: Zdenek Kabelac @ 2010-02-18  8:55 UTC (permalink / raw)
  To: lvm-devel

On 17.2.2010 18:29, Dave Wysochanski wrote:
> We need to allocate memory for the tag and copy the tag value before we
> add it to the list of tags.  We could put this inside lvm2app since the
> tools keep their memory around until vg_write/vg_commit is called, but
> we put it inside the internal library to minimize code in lvm2app.
> We need to copy the tag passed in by the caller to ensure the lifetime of
> the memory until the {vg|lv} handle is released.
> 
> Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
> ---
>  lib/metadata/metadata.c |   14 ++++++++++++--
>  1 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
> index 2b8a1be..2667e90 100644
> --- a/lib/metadata/metadata.c
> +++ b/lib/metadata/metadata.c
> @@ -667,6 +667,8 @@ int vg_reduce(struct volume_group *vg, char *pv_name)
>  
>  int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
>  {
> +	char *tag_new;
> +
>  	if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
>  		log_error("Logical volume %s/%s does not support tags",
>  			  lv->vg->name, lv->name);
> @@ -674,7 +676,10 @@ int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
>  	}
>  
>  	if (add_tag) {
> -		if (!str_list_add(lv->vg->vgmem, &lv->tags, tag)) {
> +		if (!(tag_new = dm_pool_strdup(lv->vg->vgmem, tag))) {
> +			return_0;
> +		}

just a tiny change here:

return_0;
prints just backtrace - however dm_pool_strdup() doesn't report allocation
failure message so a better way would be:

+log_error("tag duplication failed")
+return 0;

To remain consistent with the rest of lvm code.


Zdenek



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag().
  2010-02-17 17:29           ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Dave Wysochanski
  2010-02-17 17:29             ` [PATCH 7/8] Add lvm_lv_get_tags(), lvm_lv_add_tag(), and lvm_lv_remove_tag() Dave Wysochanski
@ 2010-02-18  9:05             ` Zdenek Kabelac
  2010-02-23 15:07               ` [PATCH] RFC: move str_list inside lvm2app.h, include lvm2app.h inside lvm-types.h Dave Wysochanski
  2010-02-23 18:21               ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Dave Wysochanski
  1 sibling, 2 replies; 19+ messages in thread
From: Zdenek Kabelac @ 2010-02-18  9:05 UTC (permalink / raw)
  To: lvm-devel

On 17.2.2010 18:29, Dave Wysochanski wrote:
> Add lvm2app functions to manage VG tags.
> For lvm_vg_get_tags(), we return a list of tags, similar to other
> functions that return lists.  An empty list is returned if there
> are no VG tags.  NULL is returned if there is a problem obtaining
> the list of tags.
> 
> Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
> ---
>  liblvm/.exported_symbols |    3 ++
>  liblvm/lvm2app.h         |   51 ++++++++++++++++++++++++++++++++++++++++++++-
>  liblvm/lvm_vg.c          |   34 ++++++++++++++++++++++++++++++
>  3 files changed, 86 insertions(+), 2 deletions(-)
> 
> diff --git a/liblvm/.exported_symbols b/liblvm/.exported_symbols
> index c184a88..7431248 100644
> --- a/liblvm/.exported_symbols
> +++ b/liblvm/.exported_symbols
> @@ -18,6 +18,7 @@ lvm_vg_get_extent_size
>  lvm_vg_get_extent_count
>  lvm_vg_get_free_extent_count
>  lvm_vg_get_pv_count
> +lvm_vg_get_tags
>  lvm_lv_activate
>  lvm_lv_deactivate
>  lvm_lv_get_uuid
> @@ -33,6 +34,8 @@ lvm_vg_write
>  lvm_vg_open
>  lvm_vg_close
>  lvm_vg_remove
> +lvm_vg_add_tag
> +lvm_vg_remove_tag
>  lvm_scan
>  lvm_errno
>  lvm_errmsg
> diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
> index 39bfff8..41ce18c 100644
> --- a/liblvm/lvm2app.h
> +++ b/liblvm/lvm2app.h
> @@ -159,10 +159,10 @@ typedef struct lvm_pv_list {
>   * Lists of these structures are returned by lvm_list_vg_names and
>   * lvm_list_vg_uuids.
>   */
> -struct lvm_str_list {
> +typedef struct lvm_str_list {
>  	struct dm_list list;
>  	const char *str;
> -};
> +} lvm_str_list_t;
>


Looks quite similar to 'struct str_list' from lib/datastruct/lvm-types.h ?
Are we going to replace old one with new version ?




>  /*************************** generic lvm handling ***************************/
>  /**
> @@ -458,6 +458,26 @@ int lvm_vg_extend(vg_t vg, const char *device);
>  int lvm_vg_reduce(vg_t vg, const char *device);
>  
>  /**
> + * Add/remove a tag to/from a VG.
> + *
> + * These functions require calling lvm_vg_write to commit the change to disk.
> + * After successfully adding/removing a tag, use lvm_vg_write to commit the
> + * new VG to disk.  Upon failure, retry the operation or release the VG handle
> + * with lvm_vg_close.
> + *
> + * \param   vg
> + * VG handle obtained from lvm_vg_create or lvm_vg_open.
> + *
> + * \param   tag
> + * Tag to add/remove to/from VG.
> + *
> + * \return
> + * 0 (success) or -1 (failure).
> + */
> +int lvm_vg_add_tag(vg_t vg, const char *tag);
> +int lvm_vg_remove_tag(vg_t vg, const char *tag);

I assume doxygen will generate comment only for the lvm_vg_add_tag()
and lvm_vg_remove_tag() would be without any comment ?

Zdenek



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag()
  2010-02-18  8:55         ` [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag() Zdenek Kabelac
@ 2010-02-18 12:17           ` Dave Wysochanski
  0 siblings, 0 replies; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-18 12:17 UTC (permalink / raw)
  To: lvm-devel

On Thu, 2010-02-18 at 09:55 +0100, Zdenek Kabelac wrote:
> On 17.2.2010 18:29, Dave Wysochanski wrote:
> > We need to allocate memory for the tag and copy the tag value before we
> > add it to the list of tags.  We could put this inside lvm2app since the
> > tools keep their memory around until vg_write/vg_commit is called, but
> > we put it inside the internal library to minimize code in lvm2app.
> > We need to copy the tag passed in by the caller to ensure the lifetime of
> > the memory until the {vg|lv} handle is released.
> > 
> > Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
> > ---
> >  lib/metadata/metadata.c |   14 ++++++++++++--
> >  1 files changed, 12 insertions(+), 2 deletions(-)
> > 
> > diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
> > index 2b8a1be..2667e90 100644
> > --- a/lib/metadata/metadata.c
> > +++ b/lib/metadata/metadata.c
> > @@ -667,6 +667,8 @@ int vg_reduce(struct volume_group *vg, char *pv_name)
> >  
> >  int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
> >  {
> > +	char *tag_new;
> > +
> >  	if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
> >  		log_error("Logical volume %s/%s does not support tags",
> >  			  lv->vg->name, lv->name);
> > @@ -674,7 +676,10 @@ int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
> >  	}
> >  
> >  	if (add_tag) {
> > -		if (!str_list_add(lv->vg->vgmem, &lv->tags, tag)) {
> > +		if (!(tag_new = dm_pool_strdup(lv->vg->vgmem, tag))) {
> > +			return_0;
> > +		}
> 
> just a tiny change here:
> 
> return_0;
> prints just backtrace - however dm_pool_strdup() doesn't report allocation
> failure message so a better way would be:
> 
> +log_error("tag duplication failed")
> +return 0;
> 
Ok.  Changed to:

-               if (!str_list_add(lv->vg->vgmem, &lv->tags, tag)) {
+               if (!(tag_new = dm_pool_strdup(lv->vg->vgmem, tag))) {
+                       log_error("Failed to duplicate tag %s from %s/%s",
+                                 tag, lv->vg->name, lv->name);
+                       return 0;
+               }


> To remain consistent with the rest of lvm code.
> 
> 
> Zdenek
> 
> --
> lvm-devel mailing list
> lvm-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/lvm-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] RFC: move str_list inside lvm2app.h, include lvm2app.h inside lvm-types.h.
  2010-02-18  9:05             ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Zdenek Kabelac
@ 2010-02-23 15:07               ` Dave Wysochanski
  2010-02-23 18:21               ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Dave Wysochanski
  1 sibling, 0 replies; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-23 15:07 UTC (permalink / raw)
  To: lvm-devel

lvm2app exports functions that return lists of strings.  A member of
the string list is defined by a type that is also used internally to
lvm.  Our options seem to be:
1) Duplicate the structure in lvm2app and internal lvm
2) Make internal lvm code include lvm2app.h
3) Use only simple types for return values (use iterator functions)
   a) use char ** for lists of strings
   b) use iterator functions

Option #1 was already sent out.  This patch is an attempt at option #2.
Option #3 might be the best option, though there are some existing
APIs that return dm_lists of strings, and it might be more likely an
application writer would misuse say char **.  If we used iterators it
might be ok, but then again this could be similar to the list type as
far as ease of understanding/use for an application.

This patch makes lvm-types.h include lvm2app.h though, so might not
be the best approach.  Longer term though, the direction is to have
the tools call the library, or some incarnation of it, so including
lvm2app.h from an internal file might fit the longer-term direction
better than duplication.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 include/.symlinks.in       |    1 +
 lib/datastruct/lvm-types.h |    6 ++----
 liblvm/lvm2app.h           |   20 +++++++++++---------
 liblvm/lvm_misc.c          |    4 ++++
 4 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/include/.symlinks.in b/include/.symlinks.in
index 5a7e556..7651d90 100644
--- a/include/.symlinks.in
+++ b/include/.symlinks.in
@@ -58,5 +58,6 @@
 @top_srcdir@/libdm/misc/dm-log-userspace.h
 @top_srcdir@/libdm/misc/dmlib.h
 @top_srcdir@/libdm/misc/kdev_t.h
+ at top_srcdir@/liblvm/lvm2app.h
 @top_srcdir@/po/pogen.h
 @top_srcdir@/tools/lvm2cmd.h
diff --git a/lib/datastruct/lvm-types.h b/lib/datastruct/lvm-types.h
index 5358850..743de9c 100644
--- a/lib/datastruct/lvm-types.h
+++ b/lib/datastruct/lvm-types.h
@@ -19,14 +19,12 @@
 #include <sys/types.h>
 #include <inttypes.h>
 
+#include "lvm2app.h"
+
 /* Define some portable printing types */
 #define PRIsize_t "zu"
 #define PRIptrdiff_t "td"
 #define PRIpid_t PRId32
 
-struct str_list {
-	struct dm_list list;
-	const char *str;
-};
 
 #endif
diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
index e052301..d172030 100644
--- a/liblvm/lvm2app.h
+++ b/liblvm/lvm2app.h
@@ -159,10 +159,12 @@ typedef struct lvm_pv_list {
  * Lists of these structures are returned by lvm_list_vg_names and
  * lvm_list_vg_uuids.
  */
-typedef struct lvm_str_list {
+struct str_list {
 	struct dm_list list;
 	const char *str;
-} lvm_str_list_t;
+};
+
+typedef struct str_list lvm_str_list_t;
 
 /*************************** generic lvm handling ***************************/
 /**
@@ -285,7 +287,7 @@ int lvm_scan(lvm_t libh);
  * To process the list, use the dm_list iterator functions.  For example:
  *      vg_t vg;
  *      struct dm_list *vgnames;
- *      struct lvm_str_list *strl;
+ *      lvm_str_list_t *strl;
  *
  *      vgnames = lvm_list_vg_names(libh);
  *	dm_list_iterate_items(strl, vgnames) {
@@ -297,7 +299,7 @@ int lvm_scan(lvm_t libh);
  *
  *
  * \return
- * A list with entries of type struct lvm_str_list, containing the
+ * A list with entries of type lvm_str_list_t, containing the
  * VG name strings of the Volume Groups known to the system.
  * NULL is returned if unable to allocate memory.
  * An empty list (verify with dm_list_empty) is returned if no VGs
@@ -318,7 +320,7 @@ struct dm_list *lvm_list_vg_names(lvm_t libh);
  * Handle obtained from lvm_init.
  *
  * \return
- * A list with entries of type struct lvm_str_list, containing the
+ * A list with entries of type lvm_str_list_t, containing the
  * VG UUID strings of the Volume Groups known to the system.
  * NULL is returned if unable to allocate memory.
  * An empty list (verify with dm_list_empty) is returned if no VGs
@@ -673,7 +675,7 @@ uint64_t lvm_vg_get_max_lv(const vg_t vg);
  * To process the list, use the dm_list iterator functions.  For example:
  *      vg_t vg;
  *      struct dm_list *tags;
- *      struct lvm_str_list *strl;
+ *      lvm_str_list_t *strl;
  *
  *      tags = lvm_vg_get_tags(vg);
  *	dm_list_iterate_items(strl, tags) {
@@ -683,7 +685,7 @@ uint64_t lvm_vg_get_max_lv(const vg_t vg);
  *
  *
  * \return
- * A list with entries of type struct lvm_str_list, containing the
+ * A list with entries of type lvm_str_list_t, containing the
  * tag strings attached to volume group.
  * If no tags are attached to the given VG, an empty list is returned
  * (check with dm_list_empty()).
@@ -863,7 +865,7 @@ int lvm_lv_remove_tag(lv_t lv, const char *tag);
  * To process the list, use the dm_list iterator functions.  For example:
  *      lv_t lv;
  *      struct dm_list *tags;
- *      struct lvm_str_list *strl;
+ *      lvm_str_list_t *strl;
  *
  *      tags = lvm_lv_get_tags(lv);
  *	dm_list_iterate_items(strl, tags) {
@@ -873,7 +875,7 @@ int lvm_lv_remove_tag(lv_t lv, const char *tag);
  *
  *
  * \return
- * A list with entries of type struct lvm_str_list, containing the
+ * A list with entries of type lvm_str_list_t, containing the
  * tag strings attached to volume group.
  * If no tags are attached to the LV, an empty list is returned
  * (check with dm_list_empty()).
diff --git a/liblvm/lvm_misc.c b/liblvm/lvm_misc.c
index f52c563..5fc899c 100644
--- a/liblvm/lvm_misc.c
+++ b/liblvm/lvm_misc.c
@@ -12,7 +12,11 @@
  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <sys/types.h>
+
 #include "lvm_misc.h"
+#include "lvm2app.h"
+#include "lvm-logging.h"
 
 struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list)
 {
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag().
  2010-02-18  9:05             ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Zdenek Kabelac
  2010-02-23 15:07               ` [PATCH] RFC: move str_list inside lvm2app.h, include lvm2app.h inside lvm-types.h Dave Wysochanski
@ 2010-02-23 18:21               ` Dave Wysochanski
  1 sibling, 0 replies; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-23 18:21 UTC (permalink / raw)
  To: lvm-devel

On Thu, 2010-02-18 at 10:05 +0100, Zdenek Kabelac wrote:
> > @@ -159,10 +159,10 @@ typedef struct lvm_pv_list {
> >   * Lists of these structures are returned by lvm_list_vg_names and
> >   * lvm_list_vg_uuids.
> >   */
> > -struct lvm_str_list {
> > +typedef struct lvm_str_list {
> >  	struct dm_list list;
> >  	const char *str;
> > -};
> > +} lvm_str_list_t;
> >
> 
> 
> Looks quite similar to 'struct str_list' from lib/datastruct/lvm-types.h ?
> Are we going to replace old one with new version ?
> 

As per some IRC conversations, at this point I think we need to
duplicate the structures.  In the future we may change to some other
scheme for handling strings but for now this is it.  The lvm_str_list
has been in lvm2app.h for a while now and other functions use it.


> >  /**
> > + * Add/remove a tag to/from a VG.
> > + *
> > + * These functions require calling lvm_vg_write to commit the change to disk.
> > + * After successfully adding/removing a tag, use lvm_vg_write to commit the
> > + * new VG to disk.  Upon failure, retry the operation or release the VG handle
> > + * with lvm_vg_close.
> > + *
> > + * \param   vg
> > + * VG handle obtained from lvm_vg_create or lvm_vg_open.
> > + *
> > + * \param   tag
> > + * Tag to add/remove to/from VG.
> > + *
> > + * \return
> > + * 0 (success) or -1 (failure).
> > + */
> > +int lvm_vg_add_tag(vg_t vg, const char *tag);
> > +int lvm_vg_remove_tag(vg_t vg, const char *tag);
> 
> I assume doxygen will generate comment only for the lvm_vg_add_tag()
> and lvm_vg_remove_tag() would be without any comment ?
> 

Actually doxygen handles this strangely so I'm fixing this as well as a
lot of the other doxygen tags as a result of the documentation updates.
Another patch will be soon coming.


Thanks for the feedback.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 0/4] Cleanup lvm2app.h doxygen documentation and add example.
  2010-02-17 17:29               ` [PATCH 8/8] Update lvm2app interactive unit test for vg/lv tags Dave Wysochanski
@ 2010-02-23 19:30                 ` Dave Wysochanski
  2010-02-23 19:30                   ` [PATCH 1/4] Update doxygen comments for lvm2app.h Dave Wysochanski
  0 siblings, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-23 19:30 UTC (permalink / raw)
  To: lvm-devel


This patchset cleans up some of the lvm2app.h doxygen tags and
moves us closer to more useful documentation.
Included is an intial Doxygen file, as well as example code that
along being part of the documentation, gets built in the nightly
lvm2app tests.

Should apply cleanly on top of the 8 tags patches posted earlier.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/4] Update doxygen comments for lvm2app.h.
  2010-02-23 19:30                 ` [PATCH 0/4] Cleanup lvm2app.h doxygen documentation and add example Dave Wysochanski
@ 2010-02-23 19:30                   ` Dave Wysochanski
  2010-02-23 19:30                     ` [PATCH 2/4] Add Doxygen file for lvm2app to generate documentation from lvm2app.h Dave Wysochanski
  0 siblings, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-23 19:30 UTC (permalink / raw)
  To: lvm-devel

Fix add/remove tag function headers.
Fix a lot of little problems with doxygen comments.
Clarify the basic objects and their handles, and place functions with their
appropriate handles/objects.
All this cleanup moves automatic documentation of lvm2app much closer to being
useful as official documentation.  In the future I will add some examples
and plan to build the examples as part of the unit tests.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/lvm2app.h |  363 ++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 255 insertions(+), 108 deletions(-)

diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
index e052301..61ffd87 100644
--- a/liblvm/lvm2app.h
+++ b/liblvm/lvm2app.h
@@ -33,7 +33,7 @@
  * \mainpage LVM library API
  *
  * The API is designed around the following basic LVM objects:
- * 1) Physical Volume (PV) 2) Volume Group (VG) 3) Logical Volume (LV).
+ * 1) Physical Volume (pv_t) 2) Volume Group (vg_t) 3) Logical Volume (lv_t).
  *
  * The library provides functions to list the objects in a system,
  * get and set object properties (such as names, UUIDs, and sizes), as well
@@ -44,8 +44,8 @@
  * A central object in the library is the Volume Group, represented by the
  * VG handle, vg_t. Performing an operation on a PV or LV object first
  * requires obtaining a VG handle. Once the vg_t has been obtained, it can
- * be used to enumerate the pv_t's and lv_t's within that vg_t. Attributes
- * of these objects can then be queried.
+ * be used to enumerate the pv_t and lv_t objects within that vg_t. Attributes
+ * of these objects can then be queried or changed.
  *
  * A volume group handle may be obtained with read or write permission.
  * Any attempt to change a property of a pv_t, vg_t, or lv_t without
@@ -94,7 +94,7 @@ struct volume_group;
 struct logical_volume;
 
 /**
- * lvm handle.
+ * \class lvm_t
  *
  * This is the base handle that is needed to open and create objects such as
  * volume groups and logical volumes.  In addition, this handle provides a
@@ -105,37 +105,38 @@ struct logical_volume;
 typedef struct lvm *lvm_t;
 
 /**
- * Volume group object.
+ * \class vg_t
  *
- * This object can be either a read-only object or a read-write object
- * depending on the mode it was returned by a function. Create functions
- * return a read-write object, but open functions have the argument mode to
- * define if the object can be modified or not.
+ * The volume group object is a central object in the library, and can be
+ * either a read-only object or a read-write object depending on the function
+ * used to obtain the object handle. For example, lvm_vg_create() always
+ * returns a read/write handle, while lvm_vg_open() has a "mode" argument
+ * to define the read/write mode of the handle.
  */
 typedef struct volume_group *vg_t;
 
 /**
- * Logical Volume object.
+ * \class lv_t
  *
- * This object is bound to a volume group and has the same mode of the volume
- * group.  Changes will be written to disk when the volume group gets
- * committed to disk.
+ * This logical volume object is bound to a vg_t and has the same
+ * read/write mode as the vg_t.  Changes will be written to disk
+ * when the vg_t gets committed to disk by calling lvm_vg_write().
  */
 typedef struct logical_volume *lv_t;
 
 /**
- * Physical volume object.
+ * \class pv_t
  *
- * This object is bound to a volume group and has the same mode of the volume
- * group.  Changes will be written to disk when the volume group gets
- * committed to disk.
+ * This physical volume object is bound to a vg_t and has the same
+ * read/write mode as the vg_t.  Changes will be written to disk
+ * when the vg_t gets committed to disk by calling lvm_vg_write().
  */
 typedef struct physical_volume *pv_t;
 
 /**
  * Logical Volume object list.
  *
- * Lists of these structures are returned by lvm_vg_list_pvs.
+ * Lists of these structures are returned by lvm_vg_list_pvs().
  */
 typedef struct lvm_lv_list {
 	struct dm_list list;
@@ -145,7 +146,7 @@ typedef struct lvm_lv_list {
 /**
  * Physical volume object list.
  *
- * Lists of these structures are returned by lvm_vg_list_pvs.
+ * Lists of these structures are returned by lvm_vg_list_pvs().
  */
 typedef struct lvm_pv_list {
 	struct dm_list list;
@@ -156,8 +157,8 @@ typedef struct lvm_pv_list {
  * String list.
  *
  * This string list contains read-only strings.
- * Lists of these structures are returned by lvm_list_vg_names and
- * lvm_list_vg_uuids.
+ * Lists of these structures are returned by functions such as
+ * lvm_list_vg_names() and lvm_list_vg_uuids().
  */
 typedef struct lvm_str_list {
 	struct dm_list list;
@@ -168,6 +169,8 @@ typedef struct lvm_str_list {
 /**
  * Create a LVM handle.
  *
+ * \memberof lvm_t
+ *
  * Once all LVM operations have been completed, use lvm_quit to release
  * the handle and any associated resources.
  *
@@ -184,7 +187,9 @@ typedef struct lvm_str_list {
 lvm_t lvm_init(const char *system_dir);
 
 /**
- * Destroy a LVM handle allocated with lvm_init.
+ * Destroy a LVM handle allocated with lvm_init().
+ *
+ * \memberof lvm_t
  *
  * This function should be used after all LVM operations are complete or after
  * an unrecoverable error.  Destroying the LVM handle frees the memory and
@@ -192,19 +197,21 @@ lvm_t lvm_init(const char *system_dir);
  * cannot be used subsequently.
  *
  * \param   libh
- * Handle obtained from lvm_init.
+ * Handle obtained from lvm_init().
  */
 void lvm_quit(lvm_t libh);
 
 /**
  * Reload the original configuration from the system directory.
  *
+ * \memberof lvm_t
+ *
  * This function should be used when any LVM configuration changes in the LVM
  * system_dir or by another lvm_config* function, and the change is needed by
  * the application.
  *
  * \param   libh
- * Handle obtained from lvm_init.
+ * Handle obtained from lvm_init().
  *
  * \return
  * 0 (success) or -1 (failure).
@@ -214,12 +221,14 @@ int lvm_config_reload(lvm_t libh);
 /**
  * Override the LVM configuration with a configuration string.
  *
+ * \memberof lvm_t
+ *
  * This function is equivalent to the --config option on lvm commands.
  * Once this API has been used to over-ride the configuration,
- * use lvm_config_reload to apply the new settings.
+ * use lvm_config_reload() to apply the new settings.
  *
  * \param   libh
- * Handle obtained from lvm_init.
+ * Handle obtained from lvm_init().
  *
  * \param   config_string
  * LVM configuration string to apply.  See the lvm.conf file man page
@@ -233,6 +242,8 @@ int lvm_config_override(lvm_t libh, const char *config_string);
 /**
  * Return stored error no describing last LVM API error.
  *
+ * \memberof lvm_t
+ *
  * Users of liblvm should use lvm_errno to determine the details of a any
  * failure of the last call.  A basic success or fail is always returned by
  * every function, either by returning a 0 or -1, or a non-NULL / NULL.
@@ -242,7 +253,7 @@ int lvm_config_override(lvm_t libh, const char *config_string);
  * returns a value.
  *
  * \param   libh
- * Handle obtained from lvm_init.
+ * Handle obtained from lvm_init().
  *
  * \return
  * An errno value describing the last LVM error.
@@ -252,11 +263,13 @@ int lvm_errno(lvm_t libh);
 /**
  * Return stored error message describing last LVM error.
  *
+ * \memberof lvm_t
+ *
  * This function may be used in conjunction with lvm_errno to obtain more
  * specific error information for a function that is known to have failed.
  *
  * \param   libh
- * Handle obtained from lvm_init.
+ * Handle obtained from lvm_init().
  *
  * \return
  * An error string describing the last LVM error.
@@ -266,16 +279,18 @@ const char *lvm_errmsg(lvm_t libh);
 /**
  * Scan all devices on the system for VGs and LVM metadata.
  *
+ * \memberof lvm_t
+ *
  * \return
  * 0 (success) or -1 (failure).
  */
 int lvm_scan(lvm_t libh);
 
-/*************************** volume group handling **************************/
-
 /**
  * Return the list of volume group names.
  *
+ * \memberof lvm_t
+ *
  * The memory allocated for the list is tied to the lvm_t handle and will be
  * released when lvm_quit is called.
  *
@@ -308,6 +323,8 @@ struct dm_list *lvm_list_vg_names(lvm_t libh);
 /**
  * Return the list of volume group uuids.
  *
+ * \memberof lvm_t
+ *
  * The memory allocated for the list is tied to the lvm_t handle and will be
  * released when lvm_quit is called.
  *
@@ -315,7 +332,7 @@ struct dm_list *lvm_list_vg_names(lvm_t libh);
  * metadata.  To scan the system, use lvm_scan.
  *
  * \param   libh
- * Handle obtained from lvm_init.
+ * Handle obtained from lvm_init().
  *
  * \return
  * A list with entries of type struct lvm_str_list, containing the
@@ -331,8 +348,10 @@ struct dm_list *lvm_list_vg_uuids(lvm_t libh);
  *
  * Open a VG for reading or writing.
  *
+ * \memberof lvm_t
+ *
  * \param   libh
- * Handle obtained from lvm_init.
+ * Handle obtained from lvm_init().
  *
  * \param   vgname
  * Name of the VG to open.
@@ -352,17 +371,19 @@ vg_t lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
 /**
  * Create a VG with default parameters.
  *
+ * \memberof lvm_t
+ *
  * This function creates a Volume Group object in memory.
  * Upon success, other APIs may be used to set non-default parameters.
- * For example, to set a non-default extent size, use lvm_vg_set_extent_size.
+ * For example, to set a non-default extent size, use lvm_vg_set_extent_size().
  * Next, to add physical storage devices to the volume group, use
- * lvm_vg_extend for each device.
+ * lvm_vg_extend() for each device.
  * Once all parameters are set appropriately and all devices are added to the
- * VG, use lvm_vg_write to commit the new VG to disk, and lvm_vg_close to
+ * VG, use lvm_vg_write() to commit the new VG to disk, and lvm_vg_close() to
  * release the VG handle.
  *
  * \param   libh
- * Handle obtained from lvm_init.
+ * Handle obtained from lvm_init().
  *
  * \param   vg_name
  * Name of the VG to open.
@@ -372,15 +393,47 @@ vg_t lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
  */
 vg_t lvm_vg_create(lvm_t libh, const char *vg_name);
 
- /**
+/*************************** volume group handling **************************/
+
+/**
+ * Return a list of LV handles for a given VG handle.
+ *
+ * \memberof vg_t
+ *
+ * \param   vg
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
+ *
+ * \return
+ * A list of lvm_lv_list structures containing lv handles for this vg.
+ * If no LVs exist on the given VG, NULL is returned.
+ */
+struct dm_list *lvm_vg_list_lvs(vg_t vg);
+
+/**
+ * Return a list of PV handles for a given VG handle.
+ *
+ * \memberof vg_t
+ *
+ * \param   vg
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
+ *
+ * \return
+ * A list of lvm_pv_list structures containing pv handles for this vg.
+ * If no PVs exist on the given VG, NULL is returned.
+ */
+struct dm_list *lvm_vg_list_pvs(vg_t vg);
+
+/**
  * Write a VG to disk.
  *
+ * \memberof vg_t
+ *
  * This function commits the Volume Group object referenced by the VG handle
  * to disk. Upon failure, retry the operation and/or release the VG handle
- * with lvm_vg_close.
+ * with lvm_vg_close().
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * 0 (success) or -1 (failure).
@@ -390,11 +443,13 @@ int lvm_vg_write(vg_t vg);
 /**
  * Remove a VG from the system.
  *
+ * \memberof vg_t
+ *
  * This function removes a Volume Group object in memory, and requires
- * calling lvm_vg_write to commit the removal to disk.
+ * calling lvm_vg_write() to commit the removal to disk.
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * 0 (success) or -1 (failure).
@@ -402,13 +457,15 @@ int lvm_vg_write(vg_t vg);
 int lvm_vg_remove(vg_t vg);
 
 /**
- * Close a VG opened with lvm_vg_create or lvm_vg_open.
+ * Close a VG opened with lvm_vg_create or lvm_vg_open().
+ *
+ * \memberof vg_t
  *
  * This function releases a VG handle and any resources associated with the
  * handle.
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * 0 (success) or -1 (failure).
@@ -418,17 +475,19 @@ int lvm_vg_close(vg_t vg);
 /**
  * Extend a VG by adding a device.
  *
- * This function requires calling lvm_vg_write to commit the change to disk.
- * After successfully adding a device, use lvm_vg_write to commit the new VG
+ * \memberof vg_t
+ *
+ * This function requires calling lvm_vg_write() to commit the change to disk.
+ * After successfully adding a device, use lvm_vg_write() to commit the new VG
  * to disk.  Upon failure, retry the operation or release the VG handle with
- * lvm_vg_close.
+ * lvm_vg_close().
  * If the device is not initialized for LVM use, it will be initialized
  * before adding to the VG.  Although some internal checks are done,
  * the caller should be sure the device is not in use by other subsystems
  * before calling lvm_vg_extend.
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \param   device
  * Absolute pathname of device to add to VG.
@@ -441,13 +500,15 @@ int lvm_vg_extend(vg_t vg, const char *device);
 /**
  * Reduce a VG by removing an unused device.
  *
- * This function requires calling lvm_vg_write to commit the change to disk.
- * After successfully removing a device, use lvm_vg_write to commit the new VG
+ * \memberof vg_t
+ *
+ * This function requires calling lvm_vg_write() to commit the change to disk.
+ * After successfully removing a device, use lvm_vg_write() to commit the new VG
  * to disk.  Upon failure, retry the operation or release the VG handle with
- * lvm_vg_close.
+ * lvm_vg_close().
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \param   device
  * Name of device to remove from VG.
@@ -458,35 +519,59 @@ int lvm_vg_extend(vg_t vg, const char *device);
 int lvm_vg_reduce(vg_t vg, const char *device);
 
 /**
- * Add/remove a tag to/from a VG.
+ * Add a tag to a VG.
+ *
+ * \memberof vg_t
  *
- * These functions require calling lvm_vg_write to commit the change to disk.
- * After successfully adding/removing a tag, use lvm_vg_write to commit the
+ * This function requires calling lvm_vg_write() to commit the change to disk.
+ * After successfully adding a tag, use lvm_vg_write() to commit the
  * new VG to disk.  Upon failure, retry the operation or release the VG handle
- * with lvm_vg_close.
+ * with lvm_vg_close().
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \param   tag
- * Tag to add/remove to/from VG.
+ * Tag to add to the VG.
  *
  * \return
  * 0 (success) or -1 (failure).
  */
 int lvm_vg_add_tag(vg_t vg, const char *tag);
+
+/**
+ * Remove a tag from a VG.
+ *
+ * \memberof vg_t
+ *
+ * This function requires calling lvm_vg_write() to commit the change to disk.
+ * After successfully removing a tag, use lvm_vg_write() to commit the
+ * new VG to disk.  Upon failure, retry the operation or release the VG handle
+ * with lvm_vg_close().
+ *
+ * \param   vg
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
+ *
+ * \param   tag
+ * Tag to remove from VG.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
+ */
 int lvm_vg_remove_tag(vg_t vg, const char *tag);
 
 /**
  * Set the extent size of a VG.
  *
- * This function requires calling lvm_vg_write to commit the change to disk.
- * After successfully setting a new extent size, use lvm_vg_write to commit
+ * \memberof vg_t
+ *
+ * This function requires calling lvm_vg_write() to commit the change to disk.
+ * After successfully setting a new extent size, use lvm_vg_write() to commit
  * the new VG to disk.  Upon failure, retry the operation or release the VG
- * handle with lvm_vg_close.
+ * handle with lvm_vg_close().
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \param   new_size
  * New extent size in bytes.
@@ -499,8 +584,10 @@ int lvm_vg_set_extent_size(vg_t vg, uint32_t new_size);
 /**
  * Get whether or not a volume group is clustered.
  *
+ * \memberof vg_t
+ *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * 1 if the VG is clustered, 0 if not
@@ -510,8 +597,10 @@ uint64_t lvm_vg_is_clustered(vg_t vg);
 /**
  * Get whether or not a volume group is exported.
  *
+ * \memberof vg_t
+ *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * 1 if the VG is exported, 0 if not
@@ -521,12 +610,14 @@ uint64_t lvm_vg_is_exported(vg_t vg);
 /**
  * Get whether or not a volume group is a partial volume group.
  *
+ * \memberof vg_t
+ *
  * When one or more physical volumes belonging to the volume group
  * are missing from the system the volume group is a partial volume
  * group.
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * 1 if the VG is PVs, 0 if not
@@ -536,12 +627,14 @@ uint64_t lvm_vg_is_partial(vg_t vg);
 /**
  * Get the current metadata sequence number of a volume group.
  *
+ * \memberof vg_t
+ *
  * The metadata sequence number is incrented for each metadata change.
  * Applications may use the sequence number to determine if any LVM objects
  * have changed from a prior query.
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Metadata sequence number.
@@ -551,11 +644,13 @@ uint64_t lvm_vg_get_seqno(const vg_t vg);
 /**
  * Get the current name of a volume group.
  *
+ * \memberof vg_t
+ *
  * Memory is allocated using dm_malloc() and caller must free the memory
  * using dm_free().
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Copy of the uuid string.
@@ -565,11 +660,13 @@ char *lvm_vg_get_uuid(const vg_t vg);
 /**
  * Get the current uuid of a volume group.
  *
+ * \memberof vg_t
+ *
  * Memory is allocated using dm_malloc() and caller must free the memory
  * using dm_free().
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Copy of the name.
@@ -579,8 +676,10 @@ char *lvm_vg_get_name(const vg_t vg);
 /**
  * Get the current size in bytes of a volume group.
  *
+ * \memberof vg_t
+ *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Size in bytes.
@@ -590,8 +689,10 @@ uint64_t lvm_vg_get_size(const vg_t vg);
 /**
  * Get the current unallocated space in bytes of a volume group.
  *
+ * \memberof vg_t
+ *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Free size in bytes.
@@ -601,8 +702,10 @@ uint64_t lvm_vg_get_free_size(const vg_t vg);
 /**
  * Get the current extent size in bytes of a volume group.
  *
+ * \memberof vg_t
+ *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Extent size in bytes.
@@ -612,8 +715,10 @@ uint64_t lvm_vg_get_extent_size(const vg_t vg);
 /**
  * Get the current number of total extents of a volume group.
  *
+ * \memberof vg_t
+ *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Extent count.
@@ -623,8 +728,10 @@ uint64_t lvm_vg_get_extent_count(const vg_t vg);
 /**
  * Get the current number of free extents of a volume group.
  *
+ * \memberof vg_t
+ *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Free extent count.
@@ -634,8 +741,10 @@ uint64_t lvm_vg_get_free_extent_count(const vg_t vg);
 /**
  * Get the current number of physical volumes of a volume group.
  *
+ * \memberof vg_t
+ *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Physical volume count.
@@ -645,8 +754,10 @@ uint64_t lvm_vg_get_pv_count(const vg_t vg);
 /**
  * Get the maximum number of physical volumes allowed in a volume group.
  *
+ * \memberof vg_t
+ *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Maximum number of physical volumes allowed in a volume group.
@@ -656,8 +767,10 @@ uint64_t lvm_vg_get_max_pv(const vg_t vg);
 /**
  * Get the maximum number of logical volumes allowed in a volume group.
  *
+ * \memberof vg_t
+ *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \return
  * Maximum number of logical volumes allowed in a volume group.
@@ -667,6 +780,8 @@ uint64_t lvm_vg_get_max_lv(const vg_t vg);
 /**
  * Return the list of volume group tags.
  *
+ * \memberof vg_t
+ *
  * The memory allocated for the list is tied to the vg_t handle and will be
  * released when lvm_vg_close is called.
  *
@@ -694,26 +809,14 @@ struct dm_list *lvm_vg_get_tags(const vg_t vg);
 /************************** logical volume handling *************************/
 
 /**
- * Return a list of LV handles for a given VG handle.
- *
- * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
- *
- * \return
- * A list of lv_list_t structures containing lv handles for this vg.
- * If no LVs exist on the given VG, NULL is returned.
- */
-struct dm_list *lvm_vg_list_lvs(vg_t vg);
-
-/**
  * Create a linear logical volume.
  * This function commits the change to disk and does _not_ require calling
- * lvm_vg_write.
+ * lvm_vg_write().
  * NOTE: The commit behavior of this function is subject to change
  * as the API is developed.
  *
  * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open().
  *
  * \param   name
  * Name of logical volume to create.
@@ -730,6 +833,8 @@ lv_t lvm_vg_create_lv_linear(vg_t vg, const char *name, uint64_t size);
 /**
  * Activate a logical volume.
  *
+ * \memberof lv_t
+ *
  * This function is the equivalent of the lvm command "lvchange -ay".
  *
  * NOTE: This function cannot currently handle LVs with an in-progress pvmove or
@@ -746,6 +851,8 @@ int lvm_lv_activate(lv_t lv);
 /**
  * Deactivate a logical volume.
  *
+ * \memberof lv_t
+ *
  * This function is the equivalent of the lvm command "lvchange -an".
  *
  * \param   lv
@@ -759,8 +866,10 @@ int lvm_lv_deactivate(lv_t lv);
 /**
  * Remove a logical volume from a volume group.
  *
+ * \memberof lv_t
+ *
  * This function commits the change to disk and does _not_ require calling
- * lvm_vg_write.
+ * lvm_vg_write().
  * NOTE: The commit behavior of this function is subject to change
  * as the API is developed.
  * Currently only removing linear LVs are possible.
@@ -776,6 +885,8 @@ int lvm_vg_remove_lv(lv_t lv);
 /**
  * Get the current name of a logical volume.
  *
+ * \memberof lv_t
+ *
  * Memory is allocated using dm_malloc() and caller must free the memory
  * using dm_free().
  *
@@ -790,6 +901,8 @@ char *lvm_lv_get_uuid(const lv_t lv);
 /**
  * Get the current uuid of a logical volume.
  *
+ * \memberof lv_t
+ *
  * Memory is allocated using dm_malloc() and caller must free the memory
  * using dm_free().
  *
@@ -804,6 +917,8 @@ char *lvm_lv_get_name(const lv_t lv);
 /**
  * Get the current size in bytes of a logical volume.
  *
+ * \memberof lv_t
+ *
  * \param   lv
  * Logical volume handle.
  *
@@ -815,6 +930,8 @@ uint64_t lvm_lv_get_size(const lv_t lv);
 /**
  * Get the current activation state of a logical volume.
  *
+ * \memberof lv_t
+ *
  * \param   lv
  * Logical volume handle.
  *
@@ -826,6 +943,8 @@ uint64_t lvm_lv_is_active(const lv_t lv);
 /**
  * Get the current suspended state of a logical volume.
  *
+ * \memberof lv_t
+ *
  * \param   lv
  * Logical volume handle.
  *
@@ -835,28 +954,52 @@ uint64_t lvm_lv_is_active(const lv_t lv);
 uint64_t lvm_lv_is_suspended(const lv_t lv);
 
 /**
- * Add/remove a tag to/from a LV.
+ * Add a tag to an LV.
  *
- * These functions require calling lvm_vg_write to commit the change to disk.
- * After successfully adding/removing a tag, use lvm_vg_write to commit the
+ * \memberof lv_t
+ *
+ * This function requires calling lvm_vg_write() to commit the change to disk.
+ * After successfully adding a tag, use lvm_vg_write() to commit the
  * new VG to disk.  Upon failure, retry the operation or release the VG handle
- * with lvm_vg_close.
+ * with lvm_vg_close().
  *
  * \param   lv
  * Logical volume handle.
  *
  * \param   tag
- * Tag to add/remove to/from LV.
+ * Tag to add to an LV.
  *
  * \return
  * 0 (success) or -1 (failure).
  */
 int lvm_lv_add_tag(lv_t lv, const char *tag);
+
+/**
+ * Remove a tag from an LV.
+ *
+ * \memberof lv_t
+ *
+ * This function requires calling lvm_vg_write() to commit the change to disk.
+ * After successfully removing a tag, use lvm_vg_write() to commit the
+ * new VG to disk.  Upon failure, retry the operation or release the VG handle
+ * with lvm_vg_close().
+ *
+ * \param   lv
+ * Logical volume handle.
+ *
+ * \param   tag
+ * Tag to remove from LV.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
+ */
 int lvm_lv_remove_tag(lv_t lv, const char *tag);
 
 /**
  * Return the list of logical volume tags.
  *
+ * \memberof lv_t
+ *
  * The memory allocated for the list is tied to the vg_t handle and will be
  * released when lvm_vg_close is called.
  *
@@ -885,6 +1028,8 @@ struct dm_list *lvm_lv_get_tags(const lv_t lv);
 /**
  * Resize logical volume to new_size bytes.
  *
+ * \memberof lv_t
+ *
  * NOTE: This function is currently not implemented.
  *
  * \param   lv
@@ -908,19 +1053,9 @@ int lvm_lv_resize(const lv_t lv, uint64_t new_size);
  */
 
 /**
- * Return a list of PV handles for a given VG handle.
+ * Get the current uuid of a physical volume.
  *
- * \param   vg
- * VG handle obtained from lvm_vg_create or lvm_vg_open.
- *
- * \return
- * A list of pv_list_t structures containing pv handles for this vg.
- * If no PVs exist on the given VG, NULL is returned.
- */
-struct dm_list *lvm_vg_list_pvs(vg_t vg);
-
-/**
- * Get the current uuid of a logical volume.
+ * \memberof pv_t
  *
  * Memory is allocated using dm_malloc() and caller must free the memory
  * using dm_free().
@@ -934,7 +1069,9 @@ struct dm_list *lvm_vg_list_pvs(vg_t vg);
 char *lvm_pv_get_uuid(const pv_t pv);
 
 /**
- * Get the current name of a logical volume.
+ * Get the current name of a physical volume.
+ *
+ * \memberof pv_t
  *
  * Memory is allocated using dm_malloc() and caller must free the memory
  * using dm_free().
@@ -950,6 +1087,8 @@ char *lvm_pv_get_name(const pv_t pv);
 /**
  * Get the current number of metadata areas in the physical volume.
  *
+ * \memberof pv_t
+ *
  * \param   pv
  * Physical volume handle.
  *
@@ -962,6 +1101,8 @@ uint64_t lvm_pv_get_mda_count(const pv_t pv);
  * Get the current size in bytes of a device underlying a
  * physical volume.
  *
+ * \memberof pv_t
+ *
  * \param   pv
  * Physical volume handle.
  *
@@ -973,6 +1114,8 @@ uint64_t lvm_pv_get_dev_size(const pv_t pv);
 /**
  * Get the current size in bytes of a physical volume.
  *
+ * \memberof pv_t
+ *
  * \param   pv
  * Physical volume handle.
  *
@@ -984,6 +1127,8 @@ uint64_t lvm_pv_get_size(const pv_t pv);
 /**
  * Get the current unallocated space in bytes of a physical volume.
  *
+ * \memberof pv_t
+ *
  * \param   pv
  * Physical volume handle.
  *
@@ -995,6 +1140,8 @@ uint64_t lvm_pv_get_free(const pv_t pv);
 /**
  * Resize physical volume to new_size bytes.
  *
+ * \memberof pv_t
+ *
  * NOTE: This function is currently not implemented.
  *
  * \param   pv
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/4] Add Doxygen file for lvm2app to generate documentation from lvm2app.h.
  2010-02-23 19:30                   ` [PATCH 1/4] Update doxygen comments for lvm2app.h Dave Wysochanski
@ 2010-02-23 19:30                     ` Dave Wysochanski
  2010-02-23 19:30                       ` [PATCH 3/4] Add an example to the lvm2app.h code, which is also part of the unit testing Dave Wysochanski
  0 siblings, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-23 19:30 UTC (permalink / raw)
  To: lvm-devel


Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/Doxyfile |  254 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 254 insertions(+), 0 deletions(-)
 create mode 100644 liblvm/Doxyfile

diff --git a/liblvm/Doxyfile b/liblvm/Doxyfile
new file mode 100644
index 0000000..b0b3db6
--- /dev/null
+++ b/liblvm/Doxyfile
@@ -0,0 +1,254 @@
+# Doxyfile 1.5.7.1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+DOXYFILE_ENCODING      = UTF-8
+PROJECT_NAME           = 
+PROJECT_NUMBER         = 
+OUTPUT_DIRECTORY       = doxygen-output
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       = 
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = YES
+STRIP_FROM_PATH        = 
+STRIP_FROM_INC_PATH    = 
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = NO
+QT_AUTOBRIEF           = NO
+MULTILINE_CPP_IS_BRIEF = NO
+INHERIT_DOCS           = YES
+SEPARATE_MEMBER_PAGES  = NO
+TAB_SIZE               = 8
+ALIASES                = 
+OPTIMIZE_OUTPUT_FOR_C  = NO
+OPTIMIZE_OUTPUT_JAVA   = NO
+OPTIMIZE_FOR_FORTRAN   = NO
+OPTIMIZE_OUTPUT_VHDL   = NO
+BUILTIN_STL_SUPPORT    = NO
+CPP_CLI_SUPPORT        = NO
+SIP_SUPPORT            = NO
+IDL_PROPERTY_SUPPORT   = YES
+DISTRIBUTE_GROUP_DOC   = NO
+SUBGROUPING            = YES
+TYPEDEF_HIDES_STRUCT   = NO
+SYMBOL_CACHE_SIZE      = 0
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = YES
+EXTRACT_STATIC         = NO
+EXTRACT_LOCAL_CLASSES  = YES
+EXTRACT_LOCAL_METHODS  = NO
+EXTRACT_ANON_NSPACES   = NO
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = NO
+CASE_SENSE_NAMES       = YES
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_GROUP_NAMES       = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = YES
+GENERATE_TESTLIST      = YES
+GENERATE_BUGLIST       = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       = 
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = NO
+SHOW_FILES             = YES
+SHOW_NAMESPACES        = YES
+FILE_VERSION_FILTER    = 
+LAYOUT_FILE            = 
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           = 
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = ./
+INPUT_ENCODING         = UTF-8
+FILE_PATTERNS          = *.c \
+                         *.h
+RECURSIVE              = NO
+EXCLUDE                = 
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       = 
+EXCLUDE_SYMBOLS        = 
+EXAMPLE_PATH           = ../test/api
+EXAMPLE_PATTERNS       = 
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = 
+INPUT_FILTER           = 
+FILTER_PATTERNS        = 
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = NO
+INLINE_SOURCES         = NO
+STRIP_CODE_COMMENTS    = YES
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION    = NO
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS              = NO
+VERBATIM_HEADERS       = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          = 
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = YES
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            = 
+HTML_FOOTER            = 
+HTML_STYLESHEET        = 
+HTML_ALIGN_MEMBERS     = YES
+HTML_DYNAMIC_SECTIONS  = NO
+GENERATE_DOCSET        = NO
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+GENERATE_HTMLHELP      = NO
+CHM_FILE               = 
+HHC_LOCATION           = 
+GENERATE_CHI           = NO
+CHM_INDEX_ENCODING     = 
+BINARY_TOC             = NO
+TOC_EXPAND             = NO
+GENERATE_QHP           = NO
+QCH_FILE               = 
+QHP_NAMESPACE          = org.doxygen.Project
+QHP_VIRTUAL_FOLDER     = doc
+QHG_LOCATION           = 
+DISABLE_INDEX          = NO
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = NONE
+TREEVIEW_WIDTH         = 250
+FORMULA_FONTSIZE       = 10
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = YES
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         = 
+LATEX_HEADER           = 
+PDF_HYPERLINKS         = YES
+USE_PDFLATEX           = YES
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = NO
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    = 
+RTF_EXTENSIONS_FILE    = 
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = YES
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             = 
+XML_DTD                = 
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX = 
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = NO
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           = ../libdm
+INCLUDE_FILE_PATTERNS  =
+PREDEFINED             = 
+EXPAND_AS_DEFINED      = 
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+TAGFILES               = 
+GENERATE_TAGFILE       = 
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = YES
+MSCGEN_PATH            = 
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = NO
+DOT_FONTNAME           = FreeSans
+DOT_FONTSIZE           = 10
+DOT_FONTPATH           = 
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+GROUP_GRAPHS           = YES
+UML_LOOK               = NO
+TEMPLATE_RELATIONS     = NO
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = YES
+CALLER_GRAPH           = NO
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               = 
+DOTFILE_DIRS           = 
+DOT_GRAPH_MAX_NODES    = 50
+MAX_DOT_GRAPH_DEPTH    = 0
+DOT_TRANSPARENT        = NO
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+SEARCHENGINE           = NO
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 3/4] Add an example to the lvm2app.h code, which is also part of the unit testing.
  2010-02-23 19:30                     ` [PATCH 2/4] Add Doxygen file for lvm2app to generate documentation from lvm2app.h Dave Wysochanski
@ 2010-02-23 19:30                       ` Dave Wysochanski
  2010-02-23 19:30                         ` [PATCH 4/4] Add lvm_list_all.c to lvm2app nightly tests Dave Wysochanski
  0 siblings, 1 reply; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-23 19:30 UTC (permalink / raw)
  To: lvm-devel


Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/lvm2app.h        |    4 +-
 test/api/lvm_list_all.c |  101 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 1 deletions(-)
 create mode 100644 test/api/lvm_list_all.c

diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
index 61ffd87..2301a9e 100644
--- a/liblvm/lvm2app.h
+++ b/liblvm/lvm2app.h
@@ -62,7 +62,9 @@
  * whether the original "vg_seqno" obtained with READ permission matches
  * the new one obtained with WRITE permission.
  */
-
+/**
+ * \example lvm_list_all.c
+ */
 /**
  * Retrieve the library version.
  *
diff --git a/test/api/lvm_list_all.c b/test/api/lvm_list_all.c
new file mode 100644
index 0000000..11feac6
--- /dev/null
+++ b/test/api/lvm_list_all.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2009 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <stdio.h>
+#include <unistd.h>
+#include <inttypes.h>
+
+#include "lvm2app.h"
+
+static void _process_vg(vg_t vg);
+/*
+ * List all volume groups, physical volumes, and logical volumes in
+ * the system.  Sample output:
+ *
+ * Opening volume group VolGroup00
+ * vg_name: VolGroup00, vg_uuid: OQ2d4T-qzZ7-k73u-vHt8-9T33-kTk8-ZjW4qZ
+ * - lv_name: LogVol00, lv_uuid: bFO4EU-UaDu-iuMm-N6BA-xcZc-nm3u-J5K5lu
+ * - lv_name: LogVol01, lv_uuid: BHGsPK-PwzY-kye0-MEWa-a67z-BiYE-03ZjwM
+ * - pv_name: /dev/sda2, pv_uuid: Be91pt-CqT0-4YJE-nGI6-Oisz-hy0N-l9CHgn
+ * Opening volume group vgtest
+ * vg_name: vgtest, vg_uuid: Bo3niX-gRkd-FMf2-wIdR-Hgao-MZdM-diQrxh
+ * - lv_name: lv0, lv_uuid: x5nTlk-UvuT-GJHE-mPiL-Nc6u-O2nW-AkXpfo
+ * - lv_name: lv1, lv_uuid: fZ6KbM-f3YT-vsR6-XPoc-XDcY-evv5-RhzlCQ
+ * - pv_name: /dev/loop0, pv_uuid: xe6FGu-ya5h-677k-mVlc-bpok-dawg-8tIfOh
+ * - pv_name: /dev/loop1, pv_uuid: 1voe8u-fBCz-lliH-kDFR-vNx7-sZoy-RZP7ts
+ * - pv_name: /dev/loop2, pv_uuid: dGJvCt-fSrY-1azp-r9rG-Kxby-Shon-RWbhZI
+ */
+int main(int argc, char *argv[])
+{
+	lvm_t lvm;
+	vg_t vg;
+	struct dm_list *vgnames;
+	struct lvm_str_list *strl;
+
+	lvm = lvm_init(NULL);
+	if (!lvm) {
+		fprintf(stderr, "lvm_init() failed\n");
+		goto bad;
+	}
+
+	printf("Library version: %s\n", lvm_library_get_version());
+	vgnames = lvm_list_vg_names(lvm);
+	if (!vgnames) {
+		fprintf(stderr, "lvm_list_vg_names() failed\n");
+		goto bad;
+	}
+	dm_list_iterate_items(strl, vgnames) {
+		printf("Opening volume group %s\n", strl->str);
+		vg = lvm_vg_open(lvm, strl->str, "r", 0);
+		_process_vg(vg);
+		lvm_vg_close(vg);
+	}
+	lvm_quit(lvm);
+	_exit(0);
+bad:
+	if (lvm)
+		lvm_quit(lvm);
+	_exit(-1);
+}
+
+static void _process_vg(vg_t vg)
+{
+	struct dm_list *lvs, *pvs;
+	struct lvm_pv_list *pvl;
+	struct lvm_lv_list *lvl;
+
+	if (!vg) {
+		fprintf(stderr, "Error opening volume group");
+		return;
+	}
+	printf("vg_name: %s, vg_uuid: %s\n", lvm_vg_get_name(vg),
+	       lvm_vg_get_uuid(vg));
+	lvs = lvm_vg_list_lvs(vg);
+	if (!lvs) {
+		fprintf(stderr, "lvm_vg_list_lvs() failed\n");
+		return;
+	}
+	dm_list_iterate_items(lvl, lvs) {
+		printf("- lv_name: %s, lv_uuid: %s\n",
+			lvm_lv_get_name(lvl->lv), lvm_lv_get_uuid(lvl->lv));
+	}
+	pvs = lvm_vg_list_pvs(vg);
+	if (!pvs) {
+		fprintf(stderr, "lvm_vg_list_pvs() failed\n");
+		return;
+	}
+	dm_list_iterate_items(pvl, pvs) {
+		printf("- pv_name: %s, pv_uuid: %s\n",
+			lvm_pv_get_name(pvl->pv), lvm_pv_get_uuid(pvl->pv));
+	}
+}
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/4] Add lvm_list_all.c to lvm2app nightly tests.
  2010-02-23 19:30                       ` [PATCH 3/4] Add an example to the lvm2app.h code, which is also part of the unit testing Dave Wysochanski
@ 2010-02-23 19:30                         ` Dave Wysochanski
  0 siblings, 0 replies; 19+ messages in thread
From: Dave Wysochanski @ 2010-02-23 19:30 UTC (permalink / raw)
  To: lvm-devel

This code also shows up as an example in the documentation.
To ensure it continues to compile and work, we build it as part of the
nightly lvm2app tests.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 test/api/Makefile.in |    7 ++++++-
 test/lvm2app.sh      |    7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/test/api/Makefile.in b/test/api/Makefile.in
index 2c0c62f..2c554f8 100644
--- a/test/api/Makefile.in
+++ b/test/api/Makefile.in
@@ -20,9 +20,10 @@ ifeq ("@DEBUG@", "yes")
 	DEFS += -DDEBUG
 endif
 
-TARGETS = vgtest
+TARGETS = vgtest lvm_list_all
 test_SOURCES = test.c
 vgtest_SOURCES = vgtest.c
+lvm_list_all_SOURCES = lvm_list_all.c
 INCLUDES += -I../../include
 
 LVMLIBS = @LVM2APP_LIB@ -ldevmapper
@@ -41,6 +42,7 @@ endif
 
 test_OBJECTS = $(test_SOURCES:.c=.o)
 vgtest_OBJECTS = $(vgtest_SOURCES:.c=.o)
+lvm_list_all_OBJECTS = $(lvm_list_all_SOURCES:.c=.o)
 OBJECTS = $(test_OBJECTS) $(vgtest_OBJECTS)
 
 test: $(test_OBJECTS) $(DEPLIBS)
@@ -48,3 +50,6 @@ test: $(test_OBJECTS) $(DEPLIBS)
 
 vgtest: $(vgtest_OBJECTS) $(DEPLIBS)
 	$(CC) -o vgtest $(vgtest_OBJECTS) $(CFLAGS) $(LDFLAGS) $(LVMLIBS) $(LIBS)
+
+lvm_list_all: $(lvm_list_all_OBJECTS) $(DEPLIBS)
+	$(CC) -o lvm_list_all $(lvm_list_all_OBJECTS) $(CFLAGS) $(LDFLAGS) $(LVMLIBS) $(LIBS)
diff --git a/test/lvm2app.sh b/test/lvm2app.sh
index f253b46..3d911ab 100755
--- a/test/lvm2app.sh
+++ b/test/lvm2app.sh
@@ -14,10 +14,15 @@
 
 . ./test-utils.sh
 
-aux prepare_devs 2
+aux prepare_devs 5
 
 pvcreate $dev1 $dev2
 
 echo `pwd`
 ls -lR `pwd`
 $abs_srcdir/api/vgtest $vg1 $dev1 $dev2
+vgcreate $vg1 $dev1 $dev2
+vgcreate $vg2 $dev3 $dev4
+lvcreate -l 4 -n $lv1 $vg1
+lvcreate -l 4 -n $lv2 $vg2
+$abs_srcdir/api/lvm_list_all
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-02-23 19:30 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-17 17:28 [PATCH 0/8] Add vg/lv tag addition/deletion to lvm2app, v2 Dave Wysochanski
2010-02-17 17:28 ` [PATCH 1/8] Refactor _vgchange_tag() to vg_change_tag() library function Dave Wysochanski
2010-02-17 17:28   ` [PATCH 2/8] Refactor vgcreate to call new vg_change_tag() function Dave Wysochanski
2010-02-17 17:28     ` [PATCH 3/8] Refactor lvchange_tag() to call lv_change_tag() library function Dave Wysochanski
2010-02-17 17:29       ` [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag() Dave Wysochanski
2010-02-17 17:29         ` [PATCH 5/8] Add tag_list_copy() supporting function inside lvm2app Dave Wysochanski
2010-02-17 17:29           ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Dave Wysochanski
2010-02-17 17:29             ` [PATCH 7/8] Add lvm_lv_get_tags(), lvm_lv_add_tag(), and lvm_lv_remove_tag() Dave Wysochanski
2010-02-17 17:29               ` [PATCH 8/8] Update lvm2app interactive unit test for vg/lv tags Dave Wysochanski
2010-02-23 19:30                 ` [PATCH 0/4] Cleanup lvm2app.h doxygen documentation and add example Dave Wysochanski
2010-02-23 19:30                   ` [PATCH 1/4] Update doxygen comments for lvm2app.h Dave Wysochanski
2010-02-23 19:30                     ` [PATCH 2/4] Add Doxygen file for lvm2app to generate documentation from lvm2app.h Dave Wysochanski
2010-02-23 19:30                       ` [PATCH 3/4] Add an example to the lvm2app.h code, which is also part of the unit testing Dave Wysochanski
2010-02-23 19:30                         ` [PATCH 4/4] Add lvm_list_all.c to lvm2app nightly tests Dave Wysochanski
2010-02-18  9:05             ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Zdenek Kabelac
2010-02-23 15:07               ` [PATCH] RFC: move str_list inside lvm2app.h, include lvm2app.h inside lvm-types.h Dave Wysochanski
2010-02-23 18:21               ` [PATCH 6/8] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Dave Wysochanski
2010-02-18  8:55         ` [PATCH 4/8] Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag() Zdenek Kabelac
2010-02-18 12:17           ` Dave Wysochanski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.