struct text_vg_version_ops {
int (*check_version) (const struct dm_config_tree * cf);
- struct volume_group *(*read_vg) (struct format_instance * fid,
- const struct dm_config_tree *cf,
- unsigned allow_lvmetad_extensions);
+
+ struct volume_group *(*read_vg) (struct cmd_context *cmd,
+ const struct format_type *fmt,
+ struct format_instance *fid,
+ const struct dm_config_tree *cft);
+
void (*read_desc) (struct dm_pool * mem, const struct dm_config_tree *cf,
time_t *when, char **desc);
+
int (*read_vgsummary) (const struct format_type *fmt,
const struct dm_config_tree *cft,
struct lvmcache_vgsummary *vgsummary);
#include "lib/misc/lib.h"
#include "lib/metadata/metadata.h"
+#include "lib/commands/toolcontext.h"
#include "import-export.h"
/* FIXME Use tidier inclusion method */
if (!(*vsn)->check_version(cft))
continue;
- if (!(vg = (*vsn)->read_vg(fid, cft, 0)))
+ if (!(vg = (*vsn)->read_vg(fid->fmt->cmd, fid->fmt, fid, cft)))
goto_out;
(*vsn)->read_desc(vg->vgmem, cft, when, desc);
when, desc);
}
-static struct volume_group *_import_vg_from_config_tree(const struct dm_config_tree *cft,
+static struct volume_group *_import_vg_from_config_tree(struct cmd_context *cmd,
struct format_instance *fid,
- unsigned allow_lvmetad_extensions)
+ const struct dm_config_tree *cft)
{
struct volume_group *vg = NULL;
struct text_vg_version_ops **vsn;
* The only path to this point uses cached vgmetadata,
* so it can use cached PV state too.
*/
- if (!(vg = (*vsn)->read_vg(fid, cft, allow_lvmetad_extensions)))
+ if (!(vg = (*vsn)->read_vg(cmd, fid->fmt, fid, cft)))
stack;
else {
set_pv_devices(fid, vg, NULL);
return vg;
}
-struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft,
- struct format_instance *fid)
+struct volume_group *import_vg_from_config_tree(struct cmd_context *cmd,
+ struct format_instance *fid,
+ const struct dm_config_tree *cft)
{
- return _import_vg_from_config_tree(cft, fid, 0);
+ return _import_vg_from_config_tree(cmd, fid, cft);
}
+
+struct volume_group *vg_from_config_tree(struct cmd_context *cmd, const struct dm_config_tree *cft)
+{
+ static struct text_vg_version_ops *ops;
+
+ _init_text_import();
+
+ ops = _text_vsn_list[0];
+
+ return ops->read_vg(cmd, cmd->fmt, NULL, cft);
+}
+
}
static int _read_sections(struct cmd_context *cmd,
- struct format_type *fmt,
+ const struct format_type *fmt,
struct format_instance *fid,
struct dm_pool *mem,
const char *section, section_fn fn,
}
for (n = n->child; n; n = n->sib) {
- if (!fn(cmd, fmt, fid, mem, vg, vgsummary, n, vgn, pv_hash, lv_hash))
+ if (!fn(cmd, (struct format_type *)fmt, fid, mem, vg, vgsummary, n, vgn, pv_hash, lv_hash))
return_0;
}
return 1;
}
-static struct volume_group *_read_vg(struct format_instance *fid,
- const struct dm_config_tree *cft,
- unsigned allow_lvmetad_extensions)
+static struct volume_group *_read_vg(struct cmd_context *cmd,
+ const struct format_type *fmt,
+ struct format_instance *fid,
+ const struct dm_config_tree *cft)
{
- struct cmd_context *cmd = fid->fmt->cmd;
- struct format_type *fmt = (struct format_type *)fid->fmt;
struct dm_pool *mem;
const struct dm_config_node *vgn;
const struct dm_config_value *cv;
dm_hash_destroy(pv_hash);
dm_hash_destroy(lv_hash);
- vg_set_fid(vg, fid);
+ if (fid)
+ vg_set_fid(vg, fid);
/*
* Finished.
if (!(cft = export_vg_to_config_tree(vg)))
return_0;
- if (!(*vg_embedded = import_vg_from_config_tree(cft, vg->fid))) {
+ if (!(*vg_embedded = import_vg_from_config_tree(vg->cmd, vg->fid, cft))) {
dm_config_destroy(cft);
return_0;
}
goto out;
}
- if (!(vg->vg_committed = import_vg_from_config_tree(cft, vg->fid)))
+ if (!(vg->vg_committed = import_vg_from_config_tree(cmd, vg->fid, cft)))
log_warn("WARNING: vg_read no vg copy: copy import failed");
dm_config_destroy(cft);
* For internal metadata caching.
*/
struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg);
-struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft,
- struct format_instance *fid);
+struct volume_group *import_vg_from_config_tree(struct cmd_context *cmd,
+ struct format_instance *fid,
+ const struct dm_config_tree *cft);
+struct volume_group *vg_from_config_tree(struct cmd_context *cmd, const struct dm_config_tree *cft);
/*
* Mirroring functions