[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH 21/21] Update lvm_vg_get_attr_list() to use attributes obtained during vg_open().



The original lvm_vg_get_attr_list() code used rh->mem, then called
dm_report_free(rh) which released the memory for the attributes.
This patch relies on the change to vg_open(), which reads all vg
attributes and stores them on a list inside struct volume_group.
The list remains valid and the report handle open until vg_close
is called.

TODO: Fix lvm_vg_get_attr_value() to use attribute values obtained
during vg_open.  Probably need to define an lvm_attribute structure.

Signed-off-by: Dave Wysochanski <dwysocha redhat com>
---
 lib/lvm2.h          |    2 +-
 lib/report/report.c |   27 +++++----------------------
 2 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/lib/lvm2.h b/lib/lvm2.h
index cc57574..353f5fa 100644
--- a/lib/lvm2.h
+++ b/lib/lvm2.h
@@ -80,7 +80,7 @@ const char *lvm_vg_name(const vg_t *vg);
 const char *lvm_lv_name(const lv_t *lv);
 const char *lvm_vg_uuid(vg_t *vg);
 
-int lvm_vg_get_attr_list(vg_t *vg, struct dm_list *list);
+struct dm_list * lvm_vg_get_attr_list(vg_t *vg);
 int lvm_vg_get_attr_value(vg_t *vg, const char *attr_name,
 			  struct dm_report_field_value_type *value);
 
diff --git a/lib/report/report.c b/lib/report/report.c
index 1d219bf..556dca1 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1193,29 +1193,9 @@ int report_object(void *handle, struct volume_group *vg,
 /*
  * Get a list of attributes for a vg
  */
-int lvm_vg_get_attr_list(vg_t *vg, struct dm_list *list)
+struct dm_list *lvm_vg_get_attr_list(vg_t *vg)
 {
-	void *rh;
-	report_type_t report_type = VGS;
-
-	dm_list_init(list);
-
-	/*
-	 * Create a report so we can return the headings.
-	 */
-	if (!(rh = report_init(vg->cmd, "all", "", &report_type,
-			       " ", 1, 1, 1, 0, 0, 0))) {
-		stack;
-		return 0;
-	}
-
-	if (!dm_report_get_field_ids(rh, report_type, list)) {
-		dm_report_free(rh);
-		return 0;
-	}
-
-	dm_report_free(rh);
-	return 1;
+	return &vg->attrs;
 }
 
 /*
@@ -1224,6 +1204,9 @@ int lvm_vg_get_attr_list(vg_t *vg, struct dm_list *list)
 int lvm_vg_get_attr_value(vg_t *vg, const char *attr_name,
 			  struct dm_report_field_value_type *value)
 {
+	/*
+	 * FIXME: this should be returning values filled in during vg_open
+	 */
 	void *rh;
 	report_type_t report_type = VGS;
 
-- 
1.6.0.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]