mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-02 23:23:51 +00:00
Added support for generating new style PV framebuffer. Added vnclisten & vncpasswd handling
This commit is contained in:
parent
804e20e6c3
commit
7a9f673e3e
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
||||
Thu Dec 12 09:05:03 EST 2006 Daniel Berrange <berrange@redhat.com>
|
||||
|
||||
* src/xend_internal.c: Added support for vnclisten parameter
|
||||
in generated XML
|
||||
* src/xml.c: Support new style paravirt framebuffer graphics
|
||||
configuration from xen 3.0.4 tree. Also add support for setting
|
||||
vncpasswd & vnclisten address SEXPR values, based on passwd
|
||||
and listen XML attributes.
|
||||
* tests/sexpr2xmltest.c: Whitespace cleanup.
|
||||
* tests/xml2sexprtest.c: Added test cases for new style paravirt
|
||||
framebuffer graphics configuration
|
||||
* tests/xml2sexprdata/xml2sexpr-pv-vfb*: Data files for new
|
||||
tests for graphics
|
||||
* tests/sexpr2xmldata/sexpr2xml-pv-vfb-*.xml: Added listen address
|
||||
attribute
|
||||
|
||||
Thu Dec 7 12:28:03 EST 2006 Daniel Berrange <berrange@redhat.com>
|
||||
|
||||
* src/xend_internal.c: Add bounds checking in xenDaemonListDomains to
|
||||
|
@ -1745,9 +1745,14 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
|
||||
virBufferAdd(&buf, " <graphics type='sdl'/>\n", 27);
|
||||
} else if (tmp && !strcmp(tmp, "vnc")) {
|
||||
int port = xenStoreDomainGetVNCPort(conn, domid);
|
||||
const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten");
|
||||
if (port == -1)
|
||||
port = 5900 + domid;
|
||||
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'/>\n", port);
|
||||
if (listenAddr) {
|
||||
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d' listen='%s'/>\n", port, listenAddr);
|
||||
} else {
|
||||
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'/>\n", port);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1787,9 +1792,13 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
|
||||
if (tmp != NULL) {
|
||||
if (tmp[0] == '1') {
|
||||
int port = xenStoreDomainGetVNCPort(conn, domid);
|
||||
const char *listenAddr = sexpr_fmt_node(root, "domain/image/%s/vnclisten", hvm ? "hvm" : "linux");
|
||||
if (port == -1)
|
||||
port = 5900 + domid;
|
||||
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'/>\n", port);
|
||||
if (listenAddr)
|
||||
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d' listen='%s'/>\n", port, listenAddr);
|
||||
else
|
||||
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'/>\n", port);
|
||||
}
|
||||
}
|
||||
|
||||
|
117
src/xml.c
117
src/xml.c
@ -572,7 +572,7 @@ virDomainGetXMLDesc(virDomainPtr domain, int flags)
|
||||
|
||||
#ifndef PROXY
|
||||
/**
|
||||
* virtDomainParseXMLGraphicsDesc:
|
||||
* virtDomainParseXMLGraphicsDescImage:
|
||||
* @node: node containing graphics description
|
||||
* @buf: a buffer for the result S-Expr
|
||||
* @xendConfigVersion: xend configuration file format
|
||||
@ -584,7 +584,7 @@ virDomainGetXMLDesc(virDomainPtr domain, int flags)
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of error
|
||||
*/
|
||||
static int virDomainParseXMLGraphicsDesc(xmlNodePtr node, virBufferPtr buf, int xendConfigVersion)
|
||||
static int virDomainParseXMLGraphicsDescImage(xmlNodePtr node, virBufferPtr buf, int xendConfigVersion)
|
||||
{
|
||||
xmlChar *graphics_type = NULL;
|
||||
|
||||
@ -592,16 +592,19 @@ static int virDomainParseXMLGraphicsDesc(xmlNodePtr node, virBufferPtr buf, int
|
||||
if (graphics_type != NULL) {
|
||||
if (xmlStrEqual(graphics_type, BAD_CAST "sdl")) {
|
||||
virBufferAdd(buf, "(sdl 1)", 7);
|
||||
// TODO:
|
||||
// Need to understand sdl options
|
||||
//
|
||||
//virBufferAdd(buf, "(display localhost:10.0)", 24);
|
||||
//virBufferAdd(buf, "(xauthority /root/.Xauthority)", 30);
|
||||
/* TODO:
|
||||
* Need to understand sdl options
|
||||
*
|
||||
*virBufferAdd(buf, "(display localhost:10.0)", 24);
|
||||
*virBufferAdd(buf, "(xauthority /root/.Xauthority)", 30);
|
||||
*/
|
||||
}
|
||||
else if (xmlStrEqual(graphics_type, BAD_CAST "vnc")) {
|
||||
virBufferAdd(buf, "(vnc 1)", 7);
|
||||
if (xendConfigVersion >= 2) {
|
||||
xmlChar *vncport = xmlGetProp(node, BAD_CAST "port");
|
||||
xmlChar *vnclisten = xmlGetProp(node, BAD_CAST "listen");
|
||||
xmlChar *vncpasswd = xmlGetProp(node, BAD_CAST "passwd");
|
||||
if (vncport != NULL) {
|
||||
long port = strtol((const char *)vncport, NULL, 10);
|
||||
if (port == -1)
|
||||
@ -610,6 +613,14 @@ static int virDomainParseXMLGraphicsDesc(xmlNodePtr node, virBufferPtr buf, int
|
||||
virBufferVSprintf(buf, "(vncdisplay %d)", port - 5900);
|
||||
xmlFree(vncport);
|
||||
}
|
||||
if (vnclisten != NULL) {
|
||||
virBufferVSprintf(buf, "(vnclisten %s)", vnclisten);
|
||||
xmlFree(vnclisten);
|
||||
}
|
||||
if (vncpasswd != NULL) {
|
||||
virBufferVSprintf(buf, "(vncpasswd %s)", vncpasswd);
|
||||
xmlFree(vncpasswd);
|
||||
}
|
||||
}
|
||||
}
|
||||
xmlFree(graphics_type);
|
||||
@ -618,6 +629,64 @@ static int virDomainParseXMLGraphicsDesc(xmlNodePtr node, virBufferPtr buf, int
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virtDomainParseXMLGraphicsDescVFB:
|
||||
* @node: node containing graphics description
|
||||
* @buf: a buffer for the result S-Expr
|
||||
*
|
||||
* Parse the graphics part of the XML description and add it to the S-Expr
|
||||
* in buf. This is a temporary interface as the S-Expr interface will be
|
||||
* replaced by XML-RPC in the future. However the XML format should stay
|
||||
* valid over time.
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of error
|
||||
*/
|
||||
static int virDomainParseXMLGraphicsDescVFB(xmlNodePtr node, virBufferPtr buf)
|
||||
{
|
||||
xmlChar *graphics_type = NULL;
|
||||
|
||||
graphics_type = xmlGetProp(node, BAD_CAST "type");
|
||||
if (graphics_type != NULL) {
|
||||
virBufferAdd(buf, "(device (vkbd))", 15);
|
||||
virBufferAdd(buf, "(device (vfb ", 13);
|
||||
if (xmlStrEqual(graphics_type, BAD_CAST "sdl")) {
|
||||
virBufferAdd(buf, "(type sdl)", 10);
|
||||
/* TODO:
|
||||
* Need to understand sdl options
|
||||
*
|
||||
*virBufferAdd(buf, "(display localhost:10.0)", 24);
|
||||
*virBufferAdd(buf, "(xauthority /root/.Xauthority)", 30);
|
||||
*/
|
||||
}
|
||||
else if (xmlStrEqual(graphics_type, BAD_CAST "vnc")) {
|
||||
virBufferAdd(buf, "(type vnc)", 10);
|
||||
xmlChar *vncport = xmlGetProp(node, BAD_CAST "port");
|
||||
xmlChar *vnclisten = xmlGetProp(node, BAD_CAST "listen");
|
||||
xmlChar *vncpasswd = xmlGetProp(node, BAD_CAST "passwd");
|
||||
if (vncport != NULL) {
|
||||
long port = strtol((const char *)vncport, NULL, 10);
|
||||
if (port == -1)
|
||||
virBufferAdd(buf, "(vncunused 1)", 13);
|
||||
else if (port > 5900)
|
||||
virBufferVSprintf(buf, "(vncdisplay %d)", port - 5900);
|
||||
xmlFree(vncport);
|
||||
}
|
||||
if (vnclisten != NULL) {
|
||||
virBufferVSprintf(buf, "(vnclisten %s)", vnclisten);
|
||||
xmlFree(vnclisten);
|
||||
}
|
||||
if (vncpasswd != NULL) {
|
||||
virBufferVSprintf(buf, "(vncpasswd %s)", vncpasswd);
|
||||
xmlFree(vncpasswd);
|
||||
}
|
||||
}
|
||||
virBufferAdd(buf, "))", 2);
|
||||
xmlFree(graphics_type);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainParseXMLOSDescHVM:
|
||||
* @node: node containing HVM OS description
|
||||
@ -792,7 +861,7 @@ virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
|
||||
obj = xmlXPathEval(BAD_CAST "/domain/devices/graphics[1]", ctxt);
|
||||
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
|
||||
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr > 0)) {
|
||||
res = virDomainParseXMLGraphicsDesc(obj->nodesetval->nodeTab[0], buf, xendConfigVersion);
|
||||
res = virDomainParseXMLGraphicsDescImage(obj->nodesetval->nodeTab[0], buf, xendConfigVersion);
|
||||
if (res != 0) {
|
||||
goto error;
|
||||
}
|
||||
@ -896,15 +965,18 @@ virDomainParseXMLOSDescPV(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
|
||||
virBufferVSprintf(buf, "(args '%s')", (const char *) cmdline);
|
||||
|
||||
/* Is a graphics device specified? */
|
||||
obj = xmlXPathEval(BAD_CAST "/domain/devices/graphics[1]", ctxt);
|
||||
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
|
||||
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr > 0)) {
|
||||
res = virDomainParseXMLGraphicsDesc(obj->nodesetval->nodeTab[0], buf, xendConfigVersion);
|
||||
if (res != 0) {
|
||||
goto error;
|
||||
/* Old style config before merge of PVFB */
|
||||
if (xendConfigVersion < 3) {
|
||||
obj = xmlXPathEval(BAD_CAST "/domain/devices/graphics[1]", ctxt);
|
||||
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
|
||||
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr > 0)) {
|
||||
res = virDomainParseXMLGraphicsDescImage(obj->nodesetval->nodeTab[0], buf, xendConfigVersion);
|
||||
if (res != 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(obj);
|
||||
}
|
||||
xmlXPathFreeObject(obj);
|
||||
|
||||
error:
|
||||
virBufferAdd(buf, "))", 2);
|
||||
@ -1408,6 +1480,21 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
|
||||
}
|
||||
xmlXPathFreeObject(obj);
|
||||
|
||||
/* New style PVFB config - 3.0.4 merge */
|
||||
if (xendConfigVersion >= 3 && !hvm) {
|
||||
obj = xmlXPathEval(BAD_CAST "/domain/devices/graphics", ctxt);
|
||||
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
|
||||
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr >= 0)) {
|
||||
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
|
||||
res = virDomainParseXMLGraphicsDescVFB(obj->nodesetval->nodeTab[i], &buf);
|
||||
if (res != 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(obj);
|
||||
}
|
||||
|
||||
|
||||
virBufferAdd(&buf, ")", 1); /* closes (vm */
|
||||
buf.content[buf.use] = 0;
|
||||
|
@ -18,6 +18,6 @@
|
||||
<source file='/root/some.img'/>
|
||||
<target dev='xvda'/>
|
||||
</disk>
|
||||
<graphics type='vnc' port='5906'/>
|
||||
<graphics type='vnc' port='5906' listen='0.0.0.0'/>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -18,6 +18,6 @@
|
||||
<source file='/root/some.img'/>
|
||||
<target dev='xvda'/>
|
||||
</disk>
|
||||
<graphics type='vnc' port='5906'/>
|
||||
<graphics type='vnc' port='5906' listen='0.0.0.0'/>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -64,14 +64,14 @@ static int testComparePVOrigVFB(void *data ATTRIBUTE_UNUSED) {
|
||||
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml",
|
||||
"sexpr2xmldata/sexpr2xml-pv-vfb-orig.sexpr",
|
||||
2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int testComparePVNewVFB(void *data ATTRIBUTE_UNUSED) {
|
||||
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-vfb-new.xml",
|
||||
"sexpr2xmldata/sexpr2xml-pv-vfb-new.sexpr",
|
||||
3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int testCompareFVversion2(void *data ATTRIBUTE_UNUSED) {
|
||||
@ -147,6 +147,7 @@ main(int argc, char **argv)
|
||||
if (virtTestRun("SEXPR-2-XML PV config (version 2)",
|
||||
1, testComparePVversion2, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virtTestRun("SEXPR-2-XML PV config (Orig VFB)",
|
||||
1, testComparePVOrigVFB, NULL) != 0)
|
||||
ret = -1;
|
||||
|
1
tests/xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr
Normal file
1
tests/xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr
Normal file
@ -0,0 +1 @@
|
||||
(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w')))(device (vkbd))(device (vfb (type vnc)(vncdisplay 6)(vnclisten 127.0.0.1)(vncpasswd 123456))))
|
23
tests/xml2sexprdata/xml2sexpr-pv-vfb-new.xml
Normal file
23
tests/xml2sexprdata/xml2sexpr-pv-vfb-new.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<domain type='xen' id='6'>
|
||||
<name>pvtest</name>
|
||||
<uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
|
||||
<os>
|
||||
<type>linux</type>
|
||||
<kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
|
||||
<initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
|
||||
<cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os </cmdline>
|
||||
</os>
|
||||
<memory>430080</memory>
|
||||
<vcpu>2</vcpu>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>destroy</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='file'/>
|
||||
<source file='/root/some.img'/>
|
||||
<target dev='xvda'/>
|
||||
</disk>
|
||||
<graphics type='vnc' port='5906' listen="127.0.0.1" passwd="123456"/>
|
||||
</devices>
|
||||
</domain>
|
1
tests/xml2sexprdata/xml2sexpr-pv-vfb-orig.sexpr
Normal file
1
tests/xml2sexprdata/xml2sexpr-pv-vfb-orig.sexpr
Normal file
@ -0,0 +1 @@
|
||||
(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os ')(vnc 1)(vncdisplay 6)(vnclisten 127.0.0.1)(vncpasswd 123456)))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
|
23
tests/xml2sexprdata/xml2sexpr-pv-vfb-orig.xml
Normal file
23
tests/xml2sexprdata/xml2sexpr-pv-vfb-orig.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<domain type='xen' id='6'>
|
||||
<name>pvtest</name>
|
||||
<uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
|
||||
<os>
|
||||
<type>linux</type>
|
||||
<kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
|
||||
<initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
|
||||
<cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os </cmdline>
|
||||
</os>
|
||||
<memory>430080</memory>
|
||||
<vcpu>2</vcpu>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>destroy</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='file'/>
|
||||
<source file='/root/some.img'/>
|
||||
<target dev='xvda'/>
|
||||
</disk>
|
||||
<graphics type='vnc' port='5906' listen="127.0.0.1" passwd="123456"/>
|
||||
</devices>
|
||||
</domain>
|
@ -82,6 +82,21 @@ static int testCompareFVversion2VNC(void *data ATTRIBUTE_UNUSED) {
|
||||
2);
|
||||
}
|
||||
|
||||
static int testComparePVOrigVFB(void *data ATTRIBUTE_UNUSED) {
|
||||
return testCompareFiles("xml2sexprdata/xml2sexpr-pv-vfb-orig.xml",
|
||||
"xml2sexprdata/xml2sexpr-pv-vfb-orig.sexpr",
|
||||
"pvtest",
|
||||
2);
|
||||
}
|
||||
|
||||
|
||||
static int testComparePVNewVFB(void *data ATTRIBUTE_UNUSED) {
|
||||
return testCompareFiles("xml2sexprdata/xml2sexpr-pv-vfb-new.xml",
|
||||
"xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr",
|
||||
"pvtest",
|
||||
3);
|
||||
}
|
||||
|
||||
static int testCompareDiskFile(void *data ATTRIBUTE_UNUSED) {
|
||||
return testCompareFiles("xml2sexprdata/xml2sexpr-disk-file.xml",
|
||||
"xml2sexprdata/xml2sexpr-disk-file.sexpr",
|
||||
@ -185,6 +200,14 @@ main(int argc, char **argv)
|
||||
1, testCompareFVversion2VNC, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virtTestRun("XML-2-SEXPR PV config (Orig VFB)",
|
||||
1, testComparePVOrigVFB, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virtTestRun("XML-2-SEXPR PV config (New VFB)",
|
||||
1, testComparePVNewVFB, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virtTestRun("XML-2-SEXPR Disk File",
|
||||
1, testCompareDiskFile, NULL) != 0)
|
||||
ret = -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user