[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC NDCTL PATCH] 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 <haozhong.zhang@xxxxxxxxx> --- 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(-) diff --git a/ndctl/builtin-xaction-namespace.c b/ndctl/builtin-xaction-namespace.c index 9b1702d..f60551d 100644 --- a/ndctl/builtin-xaction-namespace.c +++ b/ndctl/builtin-xaction-namespace.c @@ -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; diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 14bf217..35882db 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -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; diff --git a/ndctl/libndctl.h.in b/ndctl/libndctl.h.in index 803368b..7d61e32 100644 --- a/ndctl/libndctl.h.in +++ b/ndctl/libndctl.h.in @@ -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); diff --git a/ndctl/util/json.c b/ndctl/util/json.c index 82e677c..8083219 100644 --- a/ndctl/util/json.c +++ b/ndctl/util/json.c @@ -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; } -- 2.10.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |