ndctl: add support for Xen mode namespace
RFC PATCH 1/1 ndctl: add support for Xen mode namespace
Add support to create the Xen mode namespace which turns the underlying pfn device into PFN_MODE_XEN.
Signed-off-by Haozhong Zhang <[email protected]>
--- ndctl/builtin-xaction-namespace.c | 7 ++++++- ndctl/lib/libndctl.c | 6 ++++++ ndctl/libndctl.h.in | 2 ++ ndctl/util/json.c | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-)
ndctl/builtin-xaction-namespace.c +6 -1
@@ -176,6 +176,8 @@ static int set_defaults(enum namespace_action mode)/* pass */ ; else if (strcmp(param.map, "dev") == 0)/* pass */ ; + else if (strcmp(param.map, "xen") == 0) +/* pass */ ; else {error ("invalid map location '%s'\n" , param.map); rc = -EINVAL ;
@@ -292,7 +294,8 @@ static bool do_setup_pfn(struct ndctl_namespace *ndns,* array in device memory. */ if (!ndns ||ndctl_namespace_get_mode (ndns) !=NDCTL_NS_MODE_MEMORY - || p->loc ==NDCTL_PFN_LOC_PMEM ) + || p->loc ==NDCTL_PFN_LOC_PMEM + || p->loc ==NDCTL_PFN_LOC_XEN )return true;return false;
@@ -486,6 +489,8 @@ static int validate_namespace_options(struct ndctl_region *region,if (param.map) {if (!strcmp (param.map,"mem" )) p->loc =NDCTL_PFN_LOC_RAM ; +else if (!strcmp (param.map,"xen" )) + p->loc =NDCTL_PFN_LOC_XEN ;else p->loc =NDCTL_PFN_LOC_PMEM ;
ndctl/lib/libndctl.c +6 -0
@@ -3015,6 +3015,8 @@ NDCTL_EXPORT enum ndctl_namespace_mode ndctl_namespace_get_mode(return NDCTL_NS_MODE_RAW ;if (strcmp ("safe" , buf) ==0 )return NDCTL_NS_MODE_SAFE ; +if (strcmp ("xen" , buf) ==0 ) +return NDCTL_NS_MODE_XEN ;return -ENXIO ; }
@@ -3998,6 +4000,8 @@ static int __add_pfn(struct ndctl_pfn *pfn, const char *pfn_base) pfn->loc =NDCTL_PFN_LOC_RAM ; else if (strcmp(buf, "pmem") == 0) pfn->loc = NDCTL_PFN_LOC_PMEM; + else if (strcmp(buf, "xen") == 0) + pfn->loc = NDCTL_PFN_LOC_XEN; else goto err_read;
@@ -4190,12 +4194,14 @@ NDCTL_EXPORT int ndctl_pfn_set_location(struct ndctl_pfn *pfn, [NDCTL_PFN_LOC_NONE] = "none", [NDCTL_PFN_LOC_RAM] = "ram", [NDCTL_PFN_LOC_PMEM] = "pmem", + [NDCTL_PFN_LOC_XEN] = "xen", };switch (loc) {case NDCTL_PFN_LOC_NONE :case NDCTL_PFN_LOC_RAM :case NDCTL_PFN_LOC_PMEM : +case NDCTL_PFN_LOC_XEN :break ;default :return -EINVAL ;
ndctl/libndctl.h.in +2 -0
@@ -472,6 +472,7 @@ enum ndctl_namespace_mode { NDCTL_NS_MODE_SAFE, NDCTL_NS_MODE_RAW, NDCTL_NS_MODE_DAX, + NDCTL_NS_MODE_XEN, }; enum ndctl_namespace_mode ndctl_namespace_get_mode( struct ndctl_namespace *ndns);
@@ -560,6 +561,7 @@ enum ndctl_pfn_loc { NDCTL_PFN_LOC_NONE, NDCTL_PFN_LOC_RAM, NDCTL_PFN_LOC_PMEM, + NDCTL_PFN_LOC_XEN, }; int ndctl_pfn_set_location(struct ndctl_pfn *pfn, enum ndctl_pfn_loc loc); enum ndctl_pfn_loc ndctl_pfn_get_location(struct ndctl_pfn *pfn);
ndctl/util/json.c +4 -0
@@ -188,6 +188,10 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, size =ndctl_namespace_get_size (ndns); jobj =json_object_new_string ("raw" );break ; +case NDCTL_NS_MODE_XEN : + size =ndctl_namespace_get_size (ndns); + jobj =json_object_new_string ("xen" ); +break ;default : jobj =NULL ; }
Signature · 6 lines
2.10.1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm