]> xenbits.xensource.com Git - libvirt.git/commitdiff
virNodeGetCPUMap: Implement virsh support.
authorViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Tue, 16 Oct 2012 14:05:13 +0000 (16:05 +0200)
committerEric Blake <eblake@redhat.com>
Wed, 24 Oct 2012 00:48:06 +0000 (18:48 -0600)
- Added a new host command nodecpumap
- Added documentation

Example:
$ virsh nodecpumap
CPUs present:  8
CPUs online:   3
CPU map:       y-y-y---

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
tools/virsh-host.c
tools/virsh.pod

index 106f5e9e0d3d6ab6bd668aa02ec9787dc62ac756..0f9b3f32e3ab609f3ba2afe1242047c473804be0 100644 (file)
@@ -270,6 +270,45 @@ cmdNodeinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
     return true;
 }
 
+/*
+ * "nodecpumap" command
+ */
+static const vshCmdInfo info_node_cpumap[] = {
+    {"help", N_("node cpu map")},
+    {"desc", N_("Displays the node's total number of CPUs, the number of"
+                " online CPUs and the list of online CPUs.")},
+    {NULL, NULL}
+};
+
+static bool
+cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
+{
+    int cpu, cpunum;
+    unsigned char *cpumap = NULL;
+    unsigned int online;
+    bool ret = false;
+
+    cpunum = virNodeGetCPUMap(ctl->conn, &cpumap, &online, 0);
+    if (cpunum < 0) {
+        vshError(ctl, "%s", _("Unable to get cpu map"));
+        goto cleanup;
+    }
+
+    vshPrint(ctl, "%-15s %d\n", _("CPUs present:"), cpunum);
+    vshPrint(ctl, "%-15s %d\n", _("CPUs online:"), online);
+
+    vshPrint(ctl, "%-15s ", _("CPU map:"));
+    for (cpu = 0; cpu < cpunum; cpu++)
+        vshPrint(ctl, "%c", VIR_CPU_USED(cpumap, cpu) ? 'y' : '-');
+    vshPrint(ctl, "\n");
+
+    ret = true;
+
+  cleanup:
+    VIR_FREE(cpumap);
+    return ret;
+}
+
 /*
  * "nodecpustats" command
  */
@@ -1046,6 +1085,7 @@ const vshCmdDef hostAndHypervisorCmds[] = {
     {"hostname", cmdHostname, NULL, info_hostname, 0},
     {"node-memory-tune", cmdNodeMemoryTune,
      opts_node_memory_tune, info_node_memory_tune, 0},
+    {"nodecpumap", cmdNodeCpuMap, NULL, info_node_cpumap, 0},
     {"nodecpustats", cmdNodeCpuStats, opts_node_cpustats, info_nodecpustats, 0},
     {"nodeinfo", cmdNodeinfo, NULL, info_nodeinfo, 0},
     {"nodememstats", cmdNodeMemStats, opts_node_memstats, info_nodememstats, 0},
index 8a30ce25e6bd59222f0c1bc9793f4265fe1666aa..76f32c23997fc128a04579626f16f430771cc882 100644 (file)
@@ -277,6 +277,11 @@ and size of the physical memory. The output corresponds to virNodeInfo
 structure. Specifically, the "CPU socket(s)" field means number of CPU
 sockets per NUMA cell.
 
+=item B<nodecpumap>
+
+Displays the node's total number of CPUs, the number of online CPUs
+and the list of online CPUs.
+
 =item B<nodecpustats> [I<cpu>] [I<--percent>]
 
 Returns cpu stats of the node.