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

[Xen-devel] [RFC XEN PATCH v3 17/39] tools/xen-ndctl: add command 'setup-mgmt'



This command is to query Xen hypervisor to setup the specified PMEM
range for the management 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 | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/tools/misc/xen-ndctl.c b/tools/misc/xen-ndctl.c
index 6277a1eda2..1289a83dbe 100644
--- a/tools/misc/xen-ndctl.c
+++ b/tools/misc/xen-ndctl.c
@@ -36,6 +36,7 @@ static xc_interface *xch;
 static int handle_help(int argc, char *argv[]);
 static int handle_list(int argc, char *argv[]);
 static int handle_list_cmds(int argc, char *argv[]);
+static int handle_setup_mgmt(int argc, char *argv[]);
 
 static const struct xen_ndctl_cmd
 {
@@ -69,6 +70,14 @@ static const struct xen_ndctl_cmd
         .help    = "List all supported commands.\n",
         .handler = handle_list_cmds,
     },
+
+    {
+        .name    = "setup-mgmt",
+        .syntax  = "<smfn> <emfn>",
+        .help    = "Setup a PMEM region from MFN 'smfn' to 'emfn' for 
management usage.\n\n",
+        .handler = handle_setup_mgmt,
+        .need_xc = true,
+    },
 };
 
 static const unsigned int nr_cmds = sizeof(cmds) / sizeof(cmds[0]);
@@ -197,6 +206,42 @@ static int handle_list_cmds(int argc, char *argv[])
     return 0;
 }
 
+static bool string_to_mfn(const char *str, unsigned long *ret)
+{
+    unsigned long l;
+
+    errno = 0;
+    l = strtoul(str, NULL, 0);
+
+    if ( !errno )
+        *ret = l;
+    else
+        fprintf(stderr, "Invalid MFN %s: %s\n", str, strerror(errno));
+
+    return !errno;
+}
+
+static int handle_setup_mgmt(int argc, char **argv)
+{
+    unsigned long smfn, emfn;
+
+    if ( argc < 3 )
+    {
+        fprintf(stderr, "Too few arguments.\n\n");
+        show_help(argv[0]);
+        return -EINVAL;
+    }
+
+    if ( !string_to_mfn(argv[1], &smfn) ||
+         !string_to_mfn(argv[2], &emfn) )
+        return -EINVAL;
+
+    if ( argc > 3 )
+        return handle_unrecognized_argument(argv[0], argv[3]);
+
+    return xc_nvdimm_pmem_setup_mgmt(xch, smfn, emfn);
+}
+
 int main(int argc, char *argv[])
 {
     unsigned int i;
-- 
2.14.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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