Move code, that parses graphics listens, to it's own function.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/conf/domain_conf.c | 79 ++++++++++++++++++++++++++++++--------------------
1 file changed, 47 insertions(+), 32 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d4c78fd..a0ef3d9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10675,38 +10675,19 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr
def,
}
-/* Parse the XML definition for a graphics device */
-static virDomainGraphicsDefPtr
-virDomainGraphicsDefParseXML(xmlNodePtr node,
- xmlXPathContextPtr ctxt,
- unsigned int flags)
+static int
+virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
+ xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
+ unsigned int flags)
{
- virDomainGraphicsDefPtr def;
- char *type = NULL;
int nListens;
xmlNodePtr *listenNodes = NULL;
char *listenAddr = NULL;
xmlNodePtr save = ctxt->node;
-
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ int ret = -1;
ctxt->node = node;
-
- type = virXMLPropString(node, "type");
-
- if (!type) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("missing graphics device type"));
- goto error;
- }
-
- if ((def->type = virDomainGraphicsTypeFromString(type)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown graphics device type '%s'"), type);
- goto error;
- }
-
if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP ||
def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
@@ -10723,10 +10704,10 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
goto error;
for (i = 0; i < nListens; i++) {
- int ret = virDomainGraphicsListenDefParseXML(&def->listens[i],
- listenNodes[i],
- flags);
- if (ret < 0)
+ int rv = virDomainGraphicsListenDefParseXML(&def->listens[i],
+ listenNodes[i],
+ flags);
+ if (rv < 0)
goto error;
def->nListens++;
}
@@ -10780,6 +10761,43 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
}
}
+ ret = 0;
+ error:
+ VIR_FREE(listenNodes);
+ VIR_FREE(listenAddr);
+ ctxt->node = save;
+ return ret;
+}
+
+
+/* Parse the XML definition for a graphics device */
+static virDomainGraphicsDefPtr
+virDomainGraphicsDefParseXML(xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
+ unsigned int flags)
+{
+ virDomainGraphicsDefPtr def;
+ char *type = NULL;
+
+ if (VIR_ALLOC(def) < 0)
+ return NULL;
+
+ type = virXMLPropString(node, "type");
+ if (!type) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("missing graphics device type"));
+ goto error;
+ }
+
+ if ((def->type = virDomainGraphicsTypeFromString(type)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown graphics device type '%s'"), type);
+ goto error;
+ }
+
+ if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
+ goto error;
+
if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
char *port = virXMLPropString(node, "port");
char *websocket = virXMLPropString(node, "websocket");
@@ -11230,10 +11248,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
cleanup:
VIR_FREE(type);
- VIR_FREE(listenNodes);
- VIR_FREE(listenAddr);
- ctxt->node = save;
return def;
error:
--
2.7.4