]> xenbits.xensource.com Git - libvirt.git/commitdiff
sysinfo: implement virsh support
authorEric Blake <eblake@redhat.com>
Mon, 7 Feb 2011 22:13:48 +0000 (15:13 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 9 Feb 2011 02:29:48 +0000 (19:29 -0700)
* tools/virsh.c (cmdSysinfo): New function.
(hostAndHypervisorCmds): Add it.
* tools/virsh.pod: Document it.

tools/virsh.c
tools/virsh.pod

index 1f820e8b39b19769bfd4f8cea5ea738847c59f6f..be2cd6762257439d5259036d7f22b6eae4f4e5ba 100644 (file)
@@ -8223,7 +8223,7 @@ cmdNodeDeviceReset (vshControl *ctl, const vshCmd *cmd)
 }
 
 /*
- * "hostkey" command
+ * "hostname" command
  */
 static const vshCmdInfo info_hostname[] = {
     {"help", N_("print the hypervisor hostname")},
@@ -8280,6 +8280,36 @@ cmdURI (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
     return TRUE;
 }
 
+/*
+ * "sysinfo" command
+ */
+static const vshCmdInfo info_sysinfo[] = {
+    {"help", N_("print the hypervisor sysinfo")},
+    {"desc",
+     N_("output an XML string for the hypervisor sysinfo, if available")},
+    {NULL, NULL}
+};
+
+static int
+cmdSysinfo (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
+{
+    char *sysinfo;
+
+    if (!vshConnectionUsability(ctl, ctl->conn))
+        return FALSE;
+
+    sysinfo = virConnectGetSysinfo (ctl->conn, 0);
+    if (sysinfo == NULL) {
+        vshError(ctl, "%s", _("failed to get sysinfo"));
+        return FALSE;
+    }
+
+    vshPrint (ctl, "%s", sysinfo);
+    VIR_FREE(sysinfo);
+
+    return TRUE;
+}
+
 /*
  * "vncdisplay" command
  */
@@ -10417,6 +10447,7 @@ static const vshCmdDef hostAndHypervisorCmds[] = {
     {"hostname", cmdHostname, NULL, info_hostname},
     {"nodeinfo", cmdNodeinfo, NULL, info_nodeinfo},
     {"qemu-monitor-command", cmdQemuMonitorCommand, opts_qemu_monitor_command, info_qemu_monitor_command},
+    {"sysinfo", cmdSysinfo, NULL, info_sysinfo},
     {"uri", cmdURI, NULL, info_uri},
     {NULL, NULL, NULL, NULL}
 };
index bfaa67ec45a8a9d05941c66210ec65af78641a12..a2ca3844be39765685b1786b437acd9727837dfb 100644 (file)
@@ -132,6 +132,7 @@ group as an option.  For example:
      freecell                       NUMA free memory
      hostname                       print the hypervisor hostname
      qemu-monitor-command           Qemu Monitor Command
+     sysinfo                        print the hypervisor sysinfo
      uri                            print the hypervisor canonical URI
 
 To display detailed information for a specific command, give its name as the
@@ -227,6 +228,10 @@ Prints the hypervisor canonical URI, can be useful in shell mode.
 
 Print the hypervisor hostname.
 
+=item B<sysinfo>
+
+Print the XML representation of the hypervisor sysinfo, if available.
+
 =item B<nodeinfo>
 
 Returns basic information about the node, like number and type of CPU,