[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC XEN PATCH v3 25/39] tools/xen-ndctl: add option '--data' to command 'list'
If the option '--data' is present, the command 'list' will list all PMEM regions 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/misc/xen-ndctl.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/tools/misc/xen-ndctl.c b/tools/misc/xen-ndctl.c index 320633ae05..33817863ca 100644 --- a/tools/misc/xen-ndctl.c +++ b/tools/misc/xen-ndctl.c @@ -58,10 +58,11 @@ static const struct xen_ndctl_cmd { .name = "list", - .syntax = "[--all | --raw | --mgmt]", + .syntax = "[--all | --raw | --mgmt | --data]", .help = "--all: the default option, list all PMEM regions of following types.\n" "--raw: list all PMEM regions detected by Xen hypervisor.\n" - "--mgmt: list all PMEM regions for management usage.\n", + "--mgmt: list all PMEM regions for management usage.\n" + "--data: list all PMEM regions that can be mapped to guest.\n", .handler = handle_list, .need_xc = true, }, @@ -209,6 +210,40 @@ static int handle_list_mgmt(void) return rc; } +static int handle_list_data(void) +{ + int rc; + unsigned int nr = 0, i; + xen_sysctl_nvdimm_pmem_data_region_t *data_list; + + rc = xc_nvdimm_pmem_get_regions_nr(xch, PMEM_REGION_TYPE_DATA, &nr); + if ( rc ) + { + fprintf(stderr, "Cannot get the number of PMEM regions: %s.\n", + strerror(-rc)); + return rc; + } + + data_list = malloc(nr * sizeof(*data_list)); + if ( !data_list ) + return -ENOMEM; + + rc = xc_nvdimm_pmem_get_regions(xch, PMEM_REGION_TYPE_DATA, data_list, &nr); + if ( rc ) + goto out; + + printf("Data PMEM regions:\n"); + for ( i = 0; i < nr; i++ ) + printf(" %u: MFN 0x%lx - 0x%lx, MGMT MFN 0x%lx - 0x%lx\n", + i, data_list[i].smfn, data_list[i].emfn, + data_list[i].mgmt_smfn, data_list[i].mgmt_emfn); + + out: + free(data_list); + + return rc; +} + static const struct list_handlers { const char *option; int (*handler)(void); @@ -216,6 +251,7 @@ static const struct list_handlers { { { "--raw", handle_list_raw }, { "--mgmt", handle_list_mgmt }, + { "--data", handle_list_data }, }; static const unsigned int nr_list_hndrs = -- 2.14.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |