mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-03 15:43:51 +00:00
Pull info about serial console TTY and VNC port from xenstore into domain XML
This commit is contained in:
parent
56e0d5b33d
commit
3c43212307
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Mon Aug 7 18:33:45 EDT 2006 Daniel Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
* src/xend_internal.c: Added details of serial console TTY to XML
|
||||||
|
representation of domain. Fetch VNC port from xenstore if it is
|
||||||
|
available (only in xen 3.0.3 or later).
|
||||||
|
* src/xs_internal.c, src/xs_internal.h: Added APIs for retrieving
|
||||||
|
the serial console TTY and VNC server port from xenstore.
|
||||||
|
* docs/libvir.html: Document 'port' attribute for VNC graphics,
|
||||||
|
and '<console>' element for serial console.
|
||||||
|
|
||||||
Mon Aug 7 21:57:41 CEST 2006 Daniel Veillard <veillard@redhat.com>
|
Mon Aug 7 21:57:41 CEST 2006 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* TODO: updated with new items
|
* TODO: updated with new items
|
||||||
|
@ -28,6 +28,7 @@ the following is an example of the format as returned by the shell command
|
|||||||
<mac address='</span><span style="color: #0000FF; background-color: #FFFFFF"></span><span style="color: #0000FF; background-color: #FFFFFF">aa:00:00:00:00:11'/>
|
<mac address='</span><span style="color: #0000FF; background-color: #FFFFFF"></span><span style="color: #0000FF; background-color: #FFFFFF">aa:00:00:00:00:11'/>
|
||||||
<script path='/etc/xen/scripts/vif-bridge'/>
|
<script path='/etc/xen/scripts/vif-bridge'/>
|
||||||
</interface></span>
|
</interface></span>
|
||||||
|
<span style="color: #FF8000; background-color: #FFFFFF"><console tty='/dev/pts/5'/></span>
|
||||||
</devices>
|
</devices>
|
||||||
</domain></pre><p>The root element must be called <code>domain</code> with no namespace, the
|
</domain></pre><p>The root element must be called <code>domain</code> with no namespace, the
|
||||||
<code>type</code> attribute indicates the kind of hypervisor used, 'xen' is
|
<code>type</code> attribute indicates the kind of hypervisor used, 'xen' is
|
||||||
@ -47,10 +48,10 @@ significant:</p><ul><li>name: the domain name, preferably ASCII based</li>
|
|||||||
<li>root: the root filesystem from the guest viewpoint, it may be
|
<li>root: the root filesystem from the guest viewpoint, it may be
|
||||||
passed as part of the cmdline content too</li>
|
passed as part of the cmdline content too</li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li>devices: a list of <code>disk</code> and <code>interface</code>
|
<li>devices: a list of <code>disk</code>, <code>interface</code>
|
||||||
descriptions in no special order</li>
|
and <code>console</code> descriptions in no special order</li>
|
||||||
</ul><p>The format of the devices and their type may grow over time, but the
|
</ul><p>The format of the devices and their type may grow over time, but the
|
||||||
following should be sufficient for basic use:</p><p>A disk device indicates a block device, it can have two values for the
|
following should be sufficient for basic use:</p><p>A <code>disk</code> device indicates a block device, it can have two values for the
|
||||||
type attribute either 'file' or 'block' corresponding to the 2 options
|
type attribute either 'file' or 'block' corresponding to the 2 options
|
||||||
availble at the Xen layer. It has two mandatory children, and one optional
|
availble at the Xen layer. It has two mandatory children, and one optional
|
||||||
one in no specific order:</p><ul><li>source with a file attribute containing the path in Domain 0 to the
|
one in no specific order:</p><ul><li>source with a file attribute containing the path in Domain 0 to the
|
||||||
@ -60,14 +61,17 @@ one in no specific order:</p><ul><li>source with a file attribute containing the
|
|||||||
the guest</li>
|
the guest</li>
|
||||||
<li>readonly an optional empty element indicating the device is
|
<li>readonly an optional empty element indicating the device is
|
||||||
read-only</li>
|
read-only</li>
|
||||||
</ul><p>An interface element describes a network device mapped on the guest, it
|
</ul><p>An <code>interface</code> element describes a network device mapped on the guest, it
|
||||||
also has a type whose value is currently 'bridge', it also have a number of
|
also has a type whose value is currently 'bridge', it also have a number of
|
||||||
children in no specific order:</p><ul><li>source: indicating the bridge name</li>
|
children in no specific order:</p><ul><li>source: indicating the bridge name</li>
|
||||||
<li>mac: the optional mac address provided in the address attribute</li>
|
<li>mac: the optional mac address provided in the address attribute</li>
|
||||||
<li>ip: the optional IP address provided in the address attribute</li>
|
<li>ip: the optional IP address provided in the address attribute</li>
|
||||||
<li>script: the script used to bridge the interfcae in the Domain 0</li>
|
<li>script: the script used to bridge the interfcae in the Domain 0</li>
|
||||||
<li>target: and optional target indicating the device name.</li>
|
<li>target: and optional target indicating the device name.</li>
|
||||||
</ul><p>Life cycle actions for the domain can also be expressed in the XML format,
|
</ul><p>A <code>console</code> element describes a serial console connection to the
|
||||||
|
guest. It has no children, and a single attribute <code>tty</code> which provides
|
||||||
|
the path to the Pseudo TTY on which the guest console can be accessed
|
||||||
|
</p><p>Life cycle actions for the domain can also be expressed in the XML format,
|
||||||
they drive what should be happening if the domain crashes, is rebooted or is
|
they drive what should be happening if the domain crashes, is rebooted or is
|
||||||
poweroff. There is various actions possible when this happen:</p><ul><li>destroy: The domain is cleaned up (that's the default normal processing
|
poweroff. There is various actions possible when this happen:</p><ul><li>destroy: The domain is cleaned up (that's the default normal processing
|
||||||
in Xen)</li>
|
in Xen)</li>
|
||||||
@ -113,7 +117,7 @@ systems:</p><pre><domain type='xen' id='3'>
|
|||||||
<source file='/root/fv0'/>
|
<source file='/root/fv0'/>
|
||||||
<target <span style="color: #0000E5; background-color: #FFFFFF">dev='ioemu:hda'</span>/>
|
<target <span style="color: #0000E5; background-color: #FFFFFF">dev='ioemu:hda'</span>/>
|
||||||
</disk>
|
</disk>
|
||||||
<span style="color: #0000E5; background-color: #FFFFFF"><graphics type='vnc'/></span>
|
<span style="color: #0000E5; background-color: #FFFFFF"><graphics type='vnc' port='5904'/></span>
|
||||||
</devices>
|
</devices>
|
||||||
</domain></pre><p>There is a few things to notice specifically for HVM domains:</p><ul><li>the <os> block description is very different, first it indicates
|
</domain></pre><p>There is a few things to notice specifically for HVM domains:</p><ul><li>the <os> block description is very different, first it indicates
|
||||||
that the type is 'hvm' for hardware virtualization, then instead of a
|
that the type is 'hvm' for hardware virtualization, then instead of a
|
||||||
|
@ -320,6 +320,7 @@ the following is an example of the format as returned by the shell command
|
|||||||
<mac address='</span><span style="color: #0000FF; background-color: #FFFFFF"></span><span style="color: #0000FF; background-color: #FFFFFF">aa:00:00:00:00:11'/>
|
<mac address='</span><span style="color: #0000FF; background-color: #FFFFFF"></span><span style="color: #0000FF; background-color: #FFFFFF">aa:00:00:00:00:11'/>
|
||||||
<script path='/etc/xen/scripts/vif-bridge'/>
|
<script path='/etc/xen/scripts/vif-bridge'/>
|
||||||
</interface></span>
|
</interface></span>
|
||||||
|
<span style="color: #FF8000; background-color: #FFFFFF"><console tty='/dev/pts/5'/></span>
|
||||||
</devices>
|
</devices>
|
||||||
</domain></pre>
|
</domain></pre>
|
||||||
|
|
||||||
@ -345,14 +346,14 @@ significant:</p>
|
|||||||
passed as part of the cmdline content too</li>
|
passed as part of the cmdline content too</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>devices: a list of <code>disk</code> and <code>interface</code>
|
<li>devices: a list of <code>disk</code>, <code>interface</code>
|
||||||
descriptions in no special order</li>
|
and <code>console</code> descriptions in no special order</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>The format of the devices and their type may grow over time, but the
|
<p>The format of the devices and their type may grow over time, but the
|
||||||
following should be sufficient for basic use:</p>
|
following should be sufficient for basic use:</p>
|
||||||
|
|
||||||
<p>A disk device indicates a block device, it can have two values for the
|
<p>A <code>disk</code> device indicates a block device, it can have two values for the
|
||||||
type attribute either 'file' or 'block' corresponding to the 2 options
|
type attribute either 'file' or 'block' corresponding to the 2 options
|
||||||
availble at the Xen layer. It has two mandatory children, and one optional
|
availble at the Xen layer. It has two mandatory children, and one optional
|
||||||
one in no specific order:</p>
|
one in no specific order:</p>
|
||||||
@ -366,7 +367,7 @@ one in no specific order:</p>
|
|||||||
read-only</li>
|
read-only</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>An interface element describes a network device mapped on the guest, it
|
<p>An <code>interface</code> element describes a network device mapped on the guest, it
|
||||||
also has a type whose value is currently 'bridge', it also have a number of
|
also has a type whose value is currently 'bridge', it also have a number of
|
||||||
children in no specific order:</p>
|
children in no specific order:</p>
|
||||||
<ul>
|
<ul>
|
||||||
@ -377,6 +378,11 @@ children in no specific order:</p>
|
|||||||
<li>target: and optional target indicating the device name.</li>
|
<li>target: and optional target indicating the device name.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<p>A <code>console</code> element describes a serial console connection to the
|
||||||
|
guest. It has no children, and a single attribute <code>tty</code> which provides
|
||||||
|
the path to the Pseudo TTY on which the guest console can be accessed
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>Life cycle actions for the domain can also be expressed in the XML format,
|
<p>Life cycle actions for the domain can also be expressed in the XML format,
|
||||||
they drive what should be happening if the domain crashes, is rebooted or is
|
they drive what should be happening if the domain crashes, is rebooted or is
|
||||||
poweroff. There is various actions possible when this happen:</p>
|
poweroff. There is various actions possible when this happen:</p>
|
||||||
@ -435,7 +441,7 @@ systems:</p>
|
|||||||
<source file='/root/fv0'/>
|
<source file='/root/fv0'/>
|
||||||
<target <span style="color: #0000E5; background-color: #FFFFFF">dev='ioemu:hda'</span>/>
|
<target <span style="color: #0000E5; background-color: #FFFFFF">dev='ioemu:hda'</span>/>
|
||||||
</disk>
|
</disk>
|
||||||
<span style="color: #0000E5; background-color: #FFFFFF"><graphics type='vnc'/></span>
|
<span style="color: #0000E5; background-color: #FFFFFF"><graphics type='vnc' port='5904'/></span>
|
||||||
</devices>
|
</devices>
|
||||||
</domain></pre>
|
</domain></pre>
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "xml.h"
|
#include "xml.h"
|
||||||
#include "xend_internal.h"
|
#include "xend_internal.h"
|
||||||
#include "xen_internal.h" /* for DOM0_INTERFACE_VERSION */
|
#include "xen_internal.h" /* for DOM0_INTERFACE_VERSION */
|
||||||
|
#include "xs_internal.h" /* To extract VNC port & Serial console TTY */
|
||||||
|
|
||||||
#ifndef PROXY
|
#ifndef PROXY
|
||||||
static const char * xenDaemonGetType(virConnectPtr conn);
|
static const char * xenDaemonGetType(virConnectPtr conn);
|
||||||
@ -1434,6 +1435,7 @@ xend_parse_sexp_desc_os(struct sexpr *node, virBufferPtr buf, int hvm)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* xend_parse_sexp_desc:
|
* xend_parse_sexp_desc:
|
||||||
|
* @domain: the domain associated with the XML
|
||||||
* @root: the root of the parsed S-Expression
|
* @root: the root of the parsed S-Expression
|
||||||
*
|
*
|
||||||
* Parse the xend sexp description and turn it into the XML format similar
|
* Parse the xend sexp description and turn it into the XML format similar
|
||||||
@ -1443,11 +1445,12 @@ xend_parse_sexp_desc_os(struct sexpr *node, virBufferPtr buf, int hvm)
|
|||||||
* the caller must free() the returned value.
|
* the caller must free() the returned value.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
xend_parse_sexp_desc(struct sexpr *root)
|
xend_parse_sexp_desc(virDomainPtr domain, struct sexpr *root)
|
||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
struct sexpr *cur, *node;
|
struct sexpr *cur, *node;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
|
char *tty;
|
||||||
virBuffer buf;
|
virBuffer buf;
|
||||||
int hvm = 0;
|
int hvm = 0;
|
||||||
|
|
||||||
@ -1599,11 +1602,13 @@ xend_parse_sexp_desc(struct sexpr *root)
|
|||||||
if (hvm) {
|
if (hvm) {
|
||||||
/* Graphics device */
|
/* Graphics device */
|
||||||
tmp = sexpr_node(root, "domain/image/hvm/vnc");
|
tmp = sexpr_node(root, "domain/image/hvm/vnc");
|
||||||
/* XXX extract VNC port from XenStore if its available */
|
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
if (tmp[0] == '1')
|
if (tmp[0] == '1') {
|
||||||
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'/>\n",
|
int port = xenStoreDomainGetVNCPort(domain);
|
||||||
5900 + sexpr_int(root, "domain/domid"));
|
if (port == -1)
|
||||||
|
port = 5900 + sexpr_int(root, "domain/domid");
|
||||||
|
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'/>\n", port);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = sexpr_node(root, "domain/image/hvm/sdl");
|
tmp = sexpr_node(root, "domain/image/hvm/sdl");
|
||||||
@ -1618,6 +1623,12 @@ xend_parse_sexp_desc(struct sexpr *root)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tty = xenStoreDomainGetConsolePath(domain);
|
||||||
|
if (tty) {
|
||||||
|
virBufferVSprintf(&buf, " <console tty='%s'/>\n", tty);
|
||||||
|
free(tty);
|
||||||
|
}
|
||||||
|
|
||||||
virBufferAdd(&buf, " </devices>\n", 13);
|
virBufferAdd(&buf, " </devices>\n", 13);
|
||||||
virBufferAdd(&buf, "</domain>\n", 10);
|
virBufferAdd(&buf, "</domain>\n", 10);
|
||||||
|
|
||||||
@ -2145,7 +2156,7 @@ xenDaemonDomainDumpXML(virDomainPtr domain)
|
|||||||
if (root == NULL)
|
if (root == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
ret = xend_parse_sexp_desc(root);
|
ret = xend_parse_sexp_desc(domain, root);
|
||||||
sexpr_free(root);
|
sexpr_free(root);
|
||||||
|
|
||||||
return (ret);
|
return (ret);
|
||||||
|
@ -627,3 +627,41 @@ xenStoreDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
|
|||||||
return(virDomainDoStoreWrite(domain, "control/shutdown", "reboot"));
|
return(virDomainDoStoreWrite(domain, "control/shutdown", "reboot"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenStoreDomainGetVNCPort:
|
||||||
|
* @domain: pointer to the domain block
|
||||||
|
*
|
||||||
|
* Return the port number on which the domain is listening for VNC
|
||||||
|
* connections.
|
||||||
|
*
|
||||||
|
* Returns the port number, -1 in case of error
|
||||||
|
*/
|
||||||
|
int xenStoreDomainGetVNCPort(virDomainPtr domain) {
|
||||||
|
char *tmp;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
tmp = virDomainDoStoreQuery(domain, "console/vnc-port");
|
||||||
|
if (tmp != NULL) {
|
||||||
|
char *end;
|
||||||
|
ret = strtol(tmp, &end, 10);
|
||||||
|
if (ret == 0 && end == tmp)
|
||||||
|
ret = -1;
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenStoreDomainGetConsolePath:
|
||||||
|
* @domain: pointer to the domain block
|
||||||
|
*
|
||||||
|
* Return the path to the psuedo TTY on which the guest domain's
|
||||||
|
* serial console is attached.
|
||||||
|
*
|
||||||
|
* Returns the path to the serial console. It is the callers
|
||||||
|
* responsibilty to free() the return string. Returns NULL
|
||||||
|
* on error
|
||||||
|
*/
|
||||||
|
char * xenStoreDomainGetConsolePath(virDomainPtr domain) {
|
||||||
|
return virDomainDoStoreQuery(domain, "console/tty");
|
||||||
|
}
|
||||||
|
@ -35,6 +35,9 @@ unsigned long xenStoreDomainGetMaxMemory(virDomainPtr domain);
|
|||||||
int xenStoreDomainShutdown (virDomainPtr domain);
|
int xenStoreDomainShutdown (virDomainPtr domain);
|
||||||
int xenStoreDomainReboot (virDomainPtr domain,
|
int xenStoreDomainReboot (virDomainPtr domain,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
int xenStoreDomainGetVNCPort(virDomainPtr domain);
|
||||||
|
char * xenStoreDomainGetConsolePath(virDomainPtr domain);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user