[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC XEN PATCH v4 26/41] tools/xl: add option '--data | -d' to xl command pmem-list
'xl pmem-list --data | -d' is used to list all data PMEM regions. Signed-off-by: Haozhong Zhang <haozhong.zhang@xxxxxxxxx> --- Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/libxl/libxl_nvdimm.c | 4 ++++ tools/libxl/libxl_types.idl | 9 +++++++++ tools/xl/xl_cmdtable.c | 1 + tools/xl/xl_nvdimm.c | 22 ++++++++++++++++++++-- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_nvdimm.c b/tools/libxl/libxl_nvdimm.c index 33eb4007ec..0d51036794 100644 --- a/tools/libxl/libxl_nvdimm.c +++ b/tools/libxl/libxl_nvdimm.c @@ -32,6 +32,7 @@ static size_t xc_pmem_region_struct_size[] = { [LIBXL_NVDIMM_PMEM_REGION_TYPE_RAW] = sizeof(libxl_nvdimm_pmem_raw_region), [LIBXL_NVDIMM_PMEM_REGION_TYPE_MGMT] = sizeof(libxl_nvdimm_pmem_mgmt_region), + [LIBXL_NVDIMM_PMEM_REGION_TYPE_DATA] = sizeof(libxl_nvdimm_pmem_data_region), }; static int get_xc_region_type(libxl_nvdimm_pmem_region_type type, @@ -40,6 +41,7 @@ static int get_xc_region_type(libxl_nvdimm_pmem_region_type type, static uint8_t xc_region_types[] = { [LIBXL_NVDIMM_PMEM_REGION_TYPE_RAW] = PMEM_REGION_TYPE_RAW, [LIBXL_NVDIMM_PMEM_REGION_TYPE_MGMT] = PMEM_REGION_TYPE_MGMT, + [LIBXL_NVDIMM_PMEM_REGION_TYPE_DATA] = PMEM_REGION_TYPE_DATA, }; static unsigned int nr_types = sizeof(xc_region_types) / sizeof(xc_region_types[0]); @@ -66,6 +68,8 @@ static void copy_from_xc_regions(libxl_nvdimm_pmem_region *tgt_regions, sizeof(xen_sysctl_nvdimm_pmem_raw_region_t)); BUILD_BUG_ON(sizeof(libxl_nvdimm_pmem_mgmt_region) != sizeof(xen_sysctl_nvdimm_pmem_mgmt_region_t)); + BUILD_BUG_ON(sizeof(libxl_nvdimm_pmem_data_region) != + sizeof(xen_sysctl_nvdimm_pmem_data_region_t)); while (tgt < end) { memcpy((void *)tgt + offset, src, size); diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 22478657ff..e65bcbbb4f 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -1045,6 +1045,7 @@ libxl_psr_cat_info = Struct("psr_cat_info", [ libxl_nvdimm_pmem_region_type = Enumeration("nvdimm_pmem_region_type", [ (0, "RAW"), (1, "MGMT"), + (2, "DATA") ]) libxl_nvdimm_pmem_raw_region = Struct("nvdimm_pmem_raw_region", [ @@ -1059,9 +1060,17 @@ libxl_nvdimm_pmem_mgmt_region = Struct("nvdimm_pmem_mgmt_region", [ ("used", uint64), ]) +libxl_nvdimm_pmem_data_region = Struct("nvdimm_pmem_data_region", [ + ("smfn", uint64), + ("emfn", uint64), + ("mgmt_smfn", uint64), + ("mgmt_emfn", uint64), + ]) + libxl_nvdimm_pmem_region = Struct("nvdimm_pmem_region", [ ("u", KeyedUnion(None, libxl_nvdimm_pmem_region_type, "type", [("raw", libxl_nvdimm_pmem_raw_region), ("mgmt", libxl_nvdimm_pmem_mgmt_region), + ("data", libxl_nvdimm_pmem_data_region), ])), ]) diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index e5d117d3b9..74297e8188 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -622,6 +622,7 @@ struct cmd_spec cmd_table[] = { "[options]", "-r, --raw List PMEM regions detected by Xen hypervisor\n" "-m, --mgmt List PMEM regions used fro management\n" + "-d, --data List PMEM regions used for guest data\n" }, { "pmem-setup", &main_pmem_setup, 0, 1, diff --git a/tools/xl/xl_nvdimm.c b/tools/xl/xl_nvdimm.c index ac01039144..45770157ba 100644 --- a/tools/xl/xl_nvdimm.c +++ b/tools/xl/xl_nvdimm.c @@ -49,9 +49,18 @@ static void show_mgmt_region(libxl_nvdimm_pmem_region *region, unsigned int idx) idx, mgmt->smfn, mgmt->emfn, mgmt->used); } +static void show_data_region(libxl_nvdimm_pmem_region *region, unsigned int idx) +{ + libxl_nvdimm_pmem_data_region *data = ®ion->u.data; + + printf(" %u: mfn 0x%lx - 0x%lx, mgmt mfn 0x%lx - 0x%lx\n", + idx, data->smfn, data->emfn, data->mgmt_smfn, data->mgmt_emfn); +} + static show_region_fn_t show_region_fn[] = { [LIBXL_NVDIMM_PMEM_REGION_TYPE_RAW] = show_raw_region, [LIBXL_NVDIMM_PMEM_REGION_TYPE_MGMT] = show_mgmt_region, + [LIBXL_NVDIMM_PMEM_REGION_TYPE_DATA] = show_data_region, }; static int list_regions(libxl_nvdimm_pmem_region_type type) @@ -84,13 +93,14 @@ int main_pmem_list(int argc, char **argv) static struct option opts[] = { { "raw", 0, 0, 'r' }, { "mgmt", 0, 0, 'm' }, + { "data", 0, 0, 'd' }, COMMON_LONG_OPTS }; - bool all = true, raw = false, mgmt = false; + bool all = true, raw = false, mgmt = false, data = false; int opt, ret = 0; - SWITCH_FOREACH_OPT(opt, "rm", opts, "pmem-list", 0) { + SWITCH_FOREACH_OPT(opt, "rmd", opts, "pmem-list", 0) { case 'r': all = false; raw = true; @@ -100,6 +110,11 @@ int main_pmem_list(int argc, char **argv) all = false; mgmt = true; break; + + case 'd': + all = false; + data = true; + break; } if (all || raw) @@ -108,6 +123,9 @@ int main_pmem_list(int argc, char **argv) if (!ret && (all || mgmt)) ret = list_regions(LIBXL_NVDIMM_PMEM_REGION_TYPE_MGMT); + if (!ret && (all || data)) + ret = list_regions(LIBXL_NVDIMM_PMEM_REGION_TYPE_DATA); + return ret; } -- 2.15.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |