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

[Xen-devel] [RFC XEN PATCH v4 21/41] tools/xl: add option '--mgmt | -m' to xl command pmem-list



'xl pmem-list --mgmt | -m' is used to list all management 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 |  8 ++++++++
 tools/xl/xl_cmdtable.c      |  1 +
 tools/xl/xl_nvdimm.c        | 22 ++++++++++++++++++++--
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_nvdimm.c b/tools/libxl/libxl_nvdimm.c
index c0024298ec..896b5632ac 100644
--- a/tools/libxl/libxl_nvdimm.c
+++ b/tools/libxl/libxl_nvdimm.c
@@ -31,6 +31,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),
 };
 
 static int get_xc_region_type(libxl_nvdimm_pmem_region_type type,
@@ -38,6 +39,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,
     };
     static unsigned int nr_types =
         sizeof(xc_region_types) / sizeof(xc_region_types[0]);
@@ -62,6 +64,8 @@ static void copy_from_xc_regions(libxl_nvdimm_pmem_region 
*tgt_regions,
 
     BUILD_BUG_ON(sizeof(libxl_nvdimm_pmem_raw_region) !=
                  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));
 
     while (tgt < end) {
         memcpy((void *)tgt + offset, src, size);
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 1c7b8998e9..22478657ff 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -1044,6 +1044,7 @@ libxl_psr_cat_info = Struct("psr_cat_info", [
 
 libxl_nvdimm_pmem_region_type = Enumeration("nvdimm_pmem_region_type", [
     (0, "RAW"),
+    (1, "MGMT"),
     ])
 
 libxl_nvdimm_pmem_raw_region = Struct("nvdimm_pmem_raw_region", [
@@ -1052,8 +1053,15 @@ libxl_nvdimm_pmem_raw_region = 
Struct("nvdimm_pmem_raw_region", [
     ("pxm", uint32),
     ])
 
+libxl_nvdimm_pmem_mgmt_region = Struct("nvdimm_pmem_mgmt_region", [
+    ("smfn", uint64),
+    ("emfn", uint64),
+    ("used", 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),
                      ])),
     ])
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 12a2c2d601..8a0b58493d 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -621,6 +621,7 @@ struct cmd_spec cmd_table[] = {
       "List PMEM regions of specified types, or all PMEM regions if no type is 
specified",
       "[options]",
       "-r, --raw   List PMEM regions detected by Xen hypervisor\n"
+      "-m, --mgmt  List PMEM regions used fro management\n"
     },
     { "pmem-setup",
       &main_pmem_setup, 0, 1,
diff --git a/tools/xl/xl_nvdimm.c b/tools/xl/xl_nvdimm.c
index 25dc6350da..e42e7a3640 100644
--- a/tools/xl/xl_nvdimm.c
+++ b/tools/xl/xl_nvdimm.c
@@ -41,8 +41,17 @@ static void show_raw_region(libxl_nvdimm_pmem_region 
*region, unsigned int idx)
            idx, raw->smfn, raw->emfn, raw->pxm);
 }
 
+static void show_mgmt_region(libxl_nvdimm_pmem_region *region, unsigned int 
idx)
+{
+    libxl_nvdimm_pmem_mgmt_region *mgmt = &region->u.mgmt;
+
+    printf(" %u: mfn 0x%lx - 0x%lx, used 0x%lx pages\n",
+           idx, mgmt->smfn, mgmt->emfn, mgmt->used);
+}
+
 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,
 };
 
 static int list_regions(libxl_nvdimm_pmem_region_type type)
@@ -74,22 +83,31 @@ int main_pmem_list(int argc, char **argv)
 {
     static struct option opts[] = {
         { "raw", 0, 0, 'r' },
+        { "mgmt", 0, 0, 'm' },
         COMMON_LONG_OPTS
     };
 
-    bool all = true, raw = false;
+    bool all = true, raw = false, mgmt = false;
     int opt, ret = 0;
 
-    SWITCH_FOREACH_OPT(opt, "r", opts, "pmem-list", 0) {
+    SWITCH_FOREACH_OPT(opt, "rm", opts, "pmem-list", 0) {
     case 'r':
         all = false;
         raw = true;
         break;
+
+    case 'm':
+        all = false;
+        mgmt = true;
+        break;
     }
 
     if (all || raw)
         ret = list_regions(LIBXL_NVDIMM_PMEM_REGION_TYPE_RAW);
 
+    if (!ret && (all || mgmt))
+        ret = list_regions(LIBXL_NVDIMM_PMEM_REGION_TYPE_MGMT);
+
     return ret;
 }
 
-- 
2.15.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.