[PATCH 02/12] Initial virsh exposure of virNodeHugeTLB

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

 



The API is exposed as 'hugepage' command.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tools/virsh-host.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/virsh.pod    |  7 ++++++
 2 files changed, 69 insertions(+)

diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index cac6086..e71a341 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -644,6 +644,62 @@ cmdHostname(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
 }
 
 /*
+ * "hugepages" command
+ */
+static const vshCmdInfo info_hugepages[] = {
+    {.name = "help",
+     .data = N_("print hugepages info")
+    },
+    {.name = "desc",
+     .data = N_("print hugepages info")
+    },
+    {.name = NULL}
+};
+
+static const vshCmdOptDef opts_hugepages[] = {
+    {.name = "node",
+     .type = VSH_OT_INT,
+     .help = N_("NUMA node")
+    },
+    {.name = NULL}
+};
+
+static bool
+cmdHugepages(vshControl *ctl, const vshCmd *cmd)
+{
+    virTypedParameterPtr params = NULL;
+    int nparams = 0;
+    int node = -1; /* Overall stats */
+    unsigned int flags = 0;
+    bool ret = false;
+    size_t i;
+
+    if (vshCommandOptInt(cmd, "node", &node) < 0)
+        return false;
+
+    if (virNodeHugeTLB(ctl->conn, node, NULL, &nparams, flags) < 0)
+        goto cleanup;
+
+    params = vshCalloc(ctl, nparams, sizeof(*params));
+
+    if (virNodeHugeTLB(ctl->conn, node, params, &nparams, flags) < 0)
+        goto cleanup;
+
+    vshPrint(ctl, _("Supported huge page sizes:\n"));
+    for (i = 0; i < nparams; i++) {
+        char *str = vshGetTypedParamValue(ctl, &params[i]);
+        vshPrint(ctl, "\t%-15s\t%s\n", params[i].field, str);
+        VIR_FREE(str);
+    }
+
+    ret = 0;
+ cleanup:
+    virTypedParamsFree(params, nparams);
+    return ret;
+}
+
+
+/*
  * "uri" command
  */
 static const vshCmdInfo info_uri[] = {
@@ -964,6 +1020,12 @@ const vshCmdDef hostAndHypervisorCmds[] = {
      .info = info_hostname,
      .flags = 0
     },
+    {.name = "hugepages",
+     .handler = cmdHugepages,
+     .opts = opts_hugepages,
+     .info = info_hugepages,
+     .flags = 0
+    },
     {.name = "maxvcpus",
      .handler = cmdMaxvcpus,
      .opts = opts_maxvcpus,
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 02671b4..5ba591e 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -279,6 +279,13 @@ Prints the hypervisor canonical URI, can be useful in shell mode.
 
 Print the hypervisor hostname.
 
+=item B<hugepages> [I<node>]
+
+Print information on host huge pages. By default overall statistics are printed.
+To narrow down selection to a single NUMA node use pass it's number to I<node>.
+As a special case, if NUMA node number equals to value of -1, the aggregated
+stats are printed out.
+
 =item B<sysinfo>
 
 Print the XML representation of the hypervisor sysinfo, if available.
-- 
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]