* 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
*
* 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;
//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;
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;
}
* @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
* 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;
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;
}
}
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);
error:
return(dst_uuid);
}
+
+/*
+ * Local variables:
+ * indent-tabs-mode: nil
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
--- /dev/null
+<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>
+