[PATCH] add a ttyconsole command

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

 



 It was pointed out that we have a vncdisplay command but none for
extracting the TTY console device:

  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=239687

the trivial associated patch adds it as well as the doc in the man page

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard@xxxxxxxxxx  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/
Index: virsh.1
===================================================================
RCS file: /data/cvs/libxen/virsh.1,v
retrieving revision 1.6
diff -u -p -r1.6 virsh.1
--- virsh.1	23 Jul 2007 09:35:59 -0000	1.6
+++ virsh.1	25 Jul 2007 14:03:30 -0000
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "VIRSH 1"
-.TH VIRSH 1 "2007-07-23" "perl v5.8.8" "Virtualization Support"
+.TH VIRSH 1 "2007-07-25" "perl v5.8.8" "Virtualization Support"
 .SH "NAME"
 virsh \- management user interface
 .SH "SYNOPSIS"
@@ -406,6 +406,9 @@ anymore.
 Moves a domain out of the suspended state.  This will allow a previously
 suspended domain to now be eligible for scheduling by the the underlying
 hypervisor.
+.IP "\fBttyconsole\fR \fIdomain-id\fR" 4
+.IX Item "ttyconsole domain-id"
+Output the device used for the \s-1TTY\s0 console of the domain
 .IP "\fBundefine\fR \fIdomain-id\fR" 4
 .IX Item "undefine domain-id"
 Undefine the configuration for an inactive domain. Since it's not running
Index: docs/virsh.pod
===================================================================
RCS file: /data/cvs/libxen/docs/virsh.pod,v
retrieving revision 1.5
diff -u -p -r1.5 virsh.pod
--- docs/virsh.pod	23 Jul 2007 09:35:59 -0000	1.5
+++ docs/virsh.pod	25 Jul 2007 14:03:30 -0000
@@ -318,6 +318,10 @@ Moves a domain out of the suspended stat
 suspended domain to now be eligible for scheduling by the the underlying
 hypervisor.
 
+=item B<ttyconsole> I<domain-id>
+
+Output the device used for the TTY console of the domain
+
 =item B<undefine> I<domain-id>
 
 Undefine the configuration for an inactive domain. Since it's not running
Index: src/virsh.c
===================================================================
RCS file: /data/cvs/libxen/src/virsh.c,v
retrieving revision 1.92
diff -u -p -r1.92 virsh.c
--- src/virsh.c	6 Jul 2007 15:05:19 -0000	1.92
+++ src/virsh.c	25 Jul 2007 14:03:31 -0000
@@ -2740,6 +2740,69 @@ cmdVNCDisplay(vshControl * ctl, vshCmd *
 }
 
 /*
+ * "ttyconsole" command
+ */
+static vshCmdInfo info_ttyconsole[] = {
+    {"syntax", "ttyconsole <domain>"},
+    {"help", gettext_noop("tty console")},
+    {"desc", gettext_noop("Output the device for the TTY console.")},
+    {NULL, NULL}
+};
+
+static vshCmdOptDef opts_ttyconsole[] = {
+    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
+    {NULL, 0, 0, NULL}
+};
+
+static int
+cmdTTYConsole(vshControl * ctl, vshCmd * cmd)
+{
+    xmlDocPtr xml = NULL;
+    xmlXPathObjectPtr obj = NULL;
+    xmlXPathContextPtr ctxt = NULL;
+    virDomainPtr dom;
+    int ret = FALSE;
+    char *doc;
+
+    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
+        return FALSE;
+
+    if (!(dom = vshCommandOptDomain(ctl, cmd, "domain", NULL)))
+        return FALSE;
+
+    doc = virDomainGetXMLDesc(dom, 0);
+    if (!doc)
+        goto cleanup;
+
+    xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
+                     XML_PARSE_NOENT | XML_PARSE_NONET |
+                     XML_PARSE_NOWARNING);
+    free(doc);
+    if (!xml)
+        goto cleanup;
+    ctxt = xmlXPathNewContext(xml);
+    if (!ctxt)
+        goto cleanup;
+
+    obj = xmlXPathEval(BAD_CAST "string(/domain/devices/console/@tty)", ctxt);
+    if ((obj == NULL) || (obj->type != XPATH_STRING) ||
+        (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
+        goto cleanup;
+    }
+    vshPrint(ctl, "%s\n", (const char *)obj->stringval);
+
+ cleanup:
+    if (obj)
+        xmlXPathFreeObject(obj);
+    if (ctxt)
+        xmlXPathFreeContext(ctxt);
+    if (xml)
+        xmlFreeDoc(xml);
+    virDomainFree(dom);
+    return ret;
+}
+
+/*
  * "attach-device" command
  */
 static vshCmdInfo info_attach_device[] = {
@@ -3428,6 +3491,7 @@ static vshCmdDef commands[] = {
     {"setmaxmem", cmdSetmaxmem, opts_setmaxmem, info_setmaxmem},
     {"setvcpus", cmdSetvcpus, opts_setvcpus, info_setvcpus},
     {"suspend", cmdSuspend, opts_suspend, info_suspend},
+    {"ttyconsole", cmdTTYConsole, opts_ttyconsole, info_ttyconsole},
     {"undefine", cmdUndefine, opts_undefine, info_undefine},
     {"uri", cmdURI, NULL, info_uri},
     {"vcpuinfo", cmdVcpuinfo, opts_vcpuinfo, info_vcpuinfo},
--
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]