mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
Allow setting of VNC port when creating domains
This commit is contained in:
parent
25786cc0db
commit
1ed4d29208
@ -1,3 +1,10 @@
|
||||
Tue Sep 11 20:37:28 EDT 2006 Daniel Berrange <berrange@redhat.com>
|
||||
|
||||
* src/xml.c: Added support for setting VNC port when creating
|
||||
domains with new (version 2) style XenD config
|
||||
* tests/xml2sexprtest.c: Added test for setting VNC port
|
||||
* tests/xml2sexprdata/*vncunused*: Data files for new VNC test
|
||||
|
||||
Tue Sep 11 20:23:42 EDT 2006 Daniel Berrange <berrange@redhat.com>
|
||||
|
||||
* docs/Makefile.am: Added test XML files to EXTRA_DIST
|
||||
|
37
src/xml.c
37
src/xml.c
@ -574,6 +574,7 @@ virDomainGetXMLDesc(virDomainPtr domain, int flags)
|
||||
* virtDomainParseXMLGraphicsDesc:
|
||||
* @node: node containing graphics description
|
||||
* @buf: a buffer for the result S-Expr
|
||||
* @xendConfigVersion: xend configuration file format
|
||||
*
|
||||
* 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
|
||||
@ -582,7 +583,7 @@ virDomainGetXMLDesc(virDomainPtr domain, int flags)
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of error
|
||||
*/
|
||||
static int virDomainParseXMLGraphicsDesc(xmlNodePtr node, virBufferPtr buf)
|
||||
static int virDomainParseXMLGraphicsDesc(xmlNodePtr node, virBufferPtr buf, int xendConfigVersion)
|
||||
{
|
||||
xmlChar *graphics_type = NULL;
|
||||
|
||||
@ -596,8 +597,22 @@ static int virDomainParseXMLGraphicsDesc(xmlNodePtr node, virBufferPtr buf)
|
||||
//virBufferAdd(buf, "(display localhost:10.0)", 24);
|
||||
//virBufferAdd(buf, "(xauthority /root/.Xauthority)", 30);
|
||||
}
|
||||
else if (xmlStrEqual(graphics_type, BAD_CAST "vnc"))
|
||||
else if (xmlStrEqual(graphics_type, BAD_CAST "vnc")) {
|
||||
xmlChar *vncport = NULL;
|
||||
long port;
|
||||
|
||||
virBufferAdd(buf, "(vnc 1)", 7);
|
||||
if (xendConfigVersion >= 2) {
|
||||
vncport = xmlGetProp(node, BAD_CAST "port");
|
||||
if (vncport != NULL) {
|
||||
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(graphics_type);
|
||||
}
|
||||
return 0;
|
||||
@ -771,7 +786,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);
|
||||
res = virDomainParseXMLGraphicsDesc(obj->nodesetval->nodeTab[0], buf, xendConfigVersion);
|
||||
if (res != 0) {
|
||||
goto error;
|
||||
}
|
||||
@ -792,6 +807,7 @@ error:
|
||||
* @node: node containing PV OS description
|
||||
* @buf: a buffer for the result S-Expr
|
||||
* @ctxt: a path context representing the XML description
|
||||
* @xendConfigVersion: xend configuration file format
|
||||
*
|
||||
* Parse the OS part of the XML description for a paravirtualized domain
|
||||
* and add it to the S-Expr in buf. This is a temporary interface as the
|
||||
@ -801,7 +817,7 @@ error:
|
||||
* Returns 0 in case of success, -1 in case of error.
|
||||
*/
|
||||
static int
|
||||
virDomainParseXMLOSDescPV(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt)
|
||||
virDomainParseXMLOSDescPV(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt, int xendConfigVersion)
|
||||
{
|
||||
xmlNodePtr cur, txt;
|
||||
xmlXPathObjectPtr obj = NULL;
|
||||
@ -872,7 +888,7 @@ virDomainParseXMLOSDescPV(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);
|
||||
res = virDomainParseXMLGraphicsDesc(obj->nodesetval->nodeTab[0], buf, xendConfigVersion);
|
||||
if (res != 0) {
|
||||
goto error;
|
||||
}
|
||||
@ -1234,7 +1250,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
|
||||
}
|
||||
|
||||
if ((tmpobj == NULL) || !xmlStrEqual(tmpobj->stringval, BAD_CAST "hvm")) {
|
||||
res = virDomainParseXMLOSDescPV(obj->nodesetval->nodeTab[0], &buf, ctxt);
|
||||
res = virDomainParseXMLOSDescPV(obj->nodesetval->nodeTab[0], &buf, ctxt, xendConfigVersion);
|
||||
} else {
|
||||
hvm = 1;
|
||||
res = virDomainParseXMLOSDescHVM(obj->nodesetval->nodeTab[0], &buf, ctxt, xendConfigVersion);
|
||||
@ -1364,3 +1380,12 @@ unsigned char *virParseUUID(char **ptr, const char *uuid) {
|
||||
error:
|
||||
return(dst_uuid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* indent-tabs-mode: nil
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 4
|
||||
* End:
|
||||
*/
|
||||
|
@ -1 +1 @@
|
||||
(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
|
||||
(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)(vncdisplay 17)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
|
1
tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr
Normal file
1
tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr
Normal file
@ -0,0 +1 @@
|
||||
(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)(vncunused 1)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
|
36
tests/xml2sexprdata/xml2sexpr-fv-vncunused.xml
Normal file
36
tests/xml2sexprdata/xml2sexpr-fv-vncunused.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<domain type='xen'>
|
||||
<name>fvtest</name>
|
||||
<uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
<loader>/usr/lib/xen/boot/hvmloader</loader>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<memory>409600</memory>
|
||||
<vcpu>1</vcpu>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>restart</on_crash>
|
||||
<features>
|
||||
<acpi/>
|
||||
</features>
|
||||
<devices>
|
||||
<emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
|
||||
<interface type='bridge'>
|
||||
<source bridge='xenbr0'/>
|
||||
<mac address='00:16:3e:1b:b1:47'/>
|
||||
<script path='vif-bridge'/>
|
||||
</interface>
|
||||
<disk type='file' device='cdrom'>
|
||||
<source file='/root/boot.iso'/>
|
||||
<target dev='hdc'/>
|
||||
<readonly/>
|
||||
</disk>
|
||||
<disk type='file'>
|
||||
<source file='/root/foo.img'/>
|
||||
<target dev='ioemu:hda'/>
|
||||
</disk>
|
||||
<graphics type='vnc' port='-1'/>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -68,6 +68,13 @@ static int testCompareFVversion2(void *data ATTRIBUTE_UNUSED) {
|
||||
2);
|
||||
}
|
||||
|
||||
static int testCompareFVversion2VNC(void *data ATTRIBUTE_UNUSED) {
|
||||
return testCompareFiles("xml2sexprdata/xml2sexpr-fv-vncunused.xml",
|
||||
"xml2sexprdata/xml2sexpr-fv-vncunused.sexpr",
|
||||
"fvtest",
|
||||
2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@ -96,5 +103,9 @@ main(int argc, char **argv)
|
||||
1, testCompareFVversion2, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virtTestRun("XML-2-SEXPR FV config (format 2, VNC unused)",
|
||||
1, testCompareFVversion2VNC, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user