[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC XEN PATCH v4 23/41] tools/xl: add option '--data | -d' to xl command pmem-setup
'xl pmem-setup --data | -d' is used to setup the specified PMEM region for guest data usage. Signed-off-by: Haozhong Zhang <haozhong.zhang@xxxxxxxxx> --- Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/libxl/libxl.h | 17 +++++++++++++++++ tools/libxl/libxl_nvdimm.c | 13 +++++++++++++ tools/xl/xl_cmdtable.c | 5 +++++ tools/xl/xl_nvdimm.c | 32 +++++++++++++++++++++++++++++--- 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index e13a911cb4..c390bf227b 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -2337,6 +2337,23 @@ int libxl_nvdimm_pmem_get_regions(libxl_ctx *ctx, int libxl_nvdimm_pmem_setup_mgmt(libxl_ctx *ctx, unsigned long smfn, unsigned long emfn); +/* + * Setup the specified PMEM region for guest data usage. + * + * Parameters: + * ctx: libxl context + * data_{smfn,emfn}: start and end MFNs of the data PMEM region + * mgmt_{smfn,emfn}: start and end MFNs of the management PMEM region used to + * manage the above data PMEM region; it cannot overlap with + * the above data PMEM region + * + * Return: + * 0 on success; otherwise, ERROR_*, and leave errno valid. + */ +int libxl_nvdimm_pmem_setup_data(libxl_ctx *ctx, + unsigned long data_smfn, unsigned data_emfn, + unsigned long mgmt_smfn, unsigned mgmt_emfn); + /* misc */ /* Each of these sets or clears the flag according to whether the diff --git a/tools/libxl/libxl_nvdimm.c b/tools/libxl/libxl_nvdimm.c index 896b5632ac..33eb4007ec 100644 --- a/tools/libxl/libxl_nvdimm.c +++ b/tools/libxl/libxl_nvdimm.c @@ -151,3 +151,16 @@ int libxl_nvdimm_pmem_setup_mgmt(libxl_ctx *ctx, return errno ? ERROR_FAIL : 0; } + +int libxl_nvdimm_pmem_setup_data(libxl_ctx *ctx, + unsigned long data_smfn, unsigned data_emfn, + unsigned long mgmt_smfn, unsigned mgmt_emfn) +{ + int rc = xc_nvdimm_pmem_setup_data(ctx->xch, data_smfn, data_emfn, + mgmt_smfn, mgmt_emfn); + + if (rc) + errno = -rc; + + return errno ? ERROR_FAIL : 0; +} diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 8a0b58493d..e5d117d3b9 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -628,6 +628,11 @@ struct cmd_spec cmd_table[] = { "Setup a PMEM region for specified usage purpose", "[options]", "-m, --mgmt <smfn> <emfn> Set PMEM pages smfn - emfn for management usage\n" + "-d, --data <smfn> <emfn> <mgmt_smfn> <mgmt_emfn>\n" + " Set PMEM pages smfn - emfn for guest data usage.\n" + " PMEM pages mgmt_smfn - mgmt_emfn are used to manage\n" + " above PMEM pages. The two types of PMEM pages cannot\n" + " overlap with each other\n" }, }; diff --git a/tools/xl/xl_nvdimm.c b/tools/xl/xl_nvdimm.c index e42e7a3640..ac01039144 100644 --- a/tools/xl/xl_nvdimm.c +++ b/tools/xl/xl_nvdimm.c @@ -118,8 +118,8 @@ int main_pmem_setup(int argc, char **argv) COMMON_LONG_OPTS }; - bool mgmt = false; - unsigned long mgmt_smfn, mgmt_emfn; + bool mgmt = false, data = false; + unsigned long mgmt_smfn, mgmt_emfn, data_smfn, data_emfn; int opt, rc = 0; #define CHECK_NR_ARGS(expected, option) \ @@ -137,7 +137,7 @@ int main_pmem_setup(int argc, char **argv) } \ } while (0) - SWITCH_FOREACH_OPT(opt, "m:", opts, "pmem-setup", 0) { + SWITCH_FOREACH_OPT(opt, "m:d:", opts, "pmem-setup", 0) { case 'm': CHECK_NR_ARGS(2, "-m"); @@ -145,14 +145,40 @@ int main_pmem_setup(int argc, char **argv) mgmt_smfn = parse_ulong(optarg); mgmt_emfn = parse_ulong(argv[optind]); + break; + + case 'd': + CHECK_NR_ARGS(4, "-d"); + + data = true; + data_smfn = parse_ulong(optarg); + data_emfn = parse_ulong(argv[optind]); + mgmt_smfn = parse_ulong(argv[optind + 1]); + mgmt_emfn = parse_ulong(argv[optind + 2]); + break; } #undef CHECK_NR_ARGS + if (mgmt && data) { + fprintf(stderr, + "Error: '-m' and '-d' cannot be used simultaneously\n\n"); + help("pmem-setup"); + + rc = ERROR_INVAL; + errno = EINVAL; + + goto out; + } + if (mgmt) rc = libxl_nvdimm_pmem_setup_mgmt(ctx, mgmt_smfn, mgmt_emfn); + if (data) + rc = libxl_nvdimm_pmem_setup_data(ctx, data_smfn, data_emfn, + mgmt_smfn, mgmt_emfn); + out: if (rc) fprintf(stderr, "Error: pmem-setup failed, %s\n", strerror(errno)); -- 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 |