domain_conf: call ...ListensParseXML only for appropriate graphics

Instead of calling the virDomainGraphicsListensParseXML function for all
graphics types and ignore the wrong ones move the call only to graphics
types where we supports listen elements.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2016-04-07 13:08:58 +02:00
parent 40d246d282
commit ea4fc80230

View File

@ -10641,13 +10641,6 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
ctxt->node = node; ctxt->node = node;
if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
def->type != VIR_DOMAIN_GRAPHICS_TYPE_RDP &&
def->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
ret = 0;
goto error;
}
/* parse the <listen> subelements for graphics types that support it */ /* parse the <listen> subelements for graphics types that support it */
nListens = virXPathNodeSet("./listen", ctxt, &listenNodes); nListens = virXPathNodeSet("./listen", ctxt, &listenNodes);
if (nListens < 0) if (nListens < 0)
@ -10708,6 +10701,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
static int static int
virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def, virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
xmlNodePtr node, xmlNodePtr node,
xmlXPathContextPtr ctxt,
unsigned int flags) unsigned int flags)
{ {
char *port = virXMLPropString(node, "port"); char *port = virXMLPropString(node, "port");
@ -10716,6 +10710,9 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
char *autoport = virXMLPropString(node, "autoport"); char *autoport = virXMLPropString(node, "autoport");
int ret = -1; int ret = -1;
if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
goto error;
if (port) { if (port) {
if (virStrToLong_i(port, NULL, 10, &def->data.vnc.port) < 0) { if (virStrToLong_i(port, NULL, 10, &def->data.vnc.port) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -10816,6 +10813,7 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
static int static int
virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDefPtr def, virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDefPtr def,
xmlNodePtr node, xmlNodePtr node,
xmlXPathContextPtr ctxt,
unsigned int flags) unsigned int flags)
{ {
char *port = virXMLPropString(node, "port"); char *port = virXMLPropString(node, "port");
@ -10824,6 +10822,9 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDefPtr def,
char *multiUser = virXMLPropString(node, "multiUser"); char *multiUser = virXMLPropString(node, "multiUser");
int ret = -1; int ret = -1;
if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
goto error;
if (port) { if (port) {
if (virStrToLong_i(port, NULL, 10, &def->data.rdp.port) < 0) { if (virStrToLong_i(port, NULL, 10, &def->data.rdp.port) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -10894,6 +10895,7 @@ virDomainGraphicsDefParseXMLDesktop(virDomainGraphicsDefPtr def,
static int static int
virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
xmlNodePtr node, xmlNodePtr node,
xmlXPathContextPtr ctxt,
unsigned int flags) unsigned int flags)
{ {
xmlNodePtr cur; xmlNodePtr cur;
@ -10904,6 +10906,9 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
int defaultModeVal; int defaultModeVal;
int ret = -1; int ret = -1;
if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
goto error;
if (port) { if (port) {
if (virStrToLong_i(port, NULL, 10, &def->data.spice.port) < 0) { if (virStrToLong_i(port, NULL, 10, &def->data.spice.port) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -11216,12 +11221,9 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
goto error; goto error;
} }
if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
goto error;
switch ((virDomainGraphicsType)def->type) { switch ((virDomainGraphicsType)def->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_VNC: case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
if (virDomainGraphicsDefParseXMLVNC(def, node, flags) < 0) if (virDomainGraphicsDefParseXMLVNC(def, node, ctxt, flags) < 0)
goto error; goto error;
break; break;
case VIR_DOMAIN_GRAPHICS_TYPE_SDL: case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
@ -11229,7 +11231,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
goto error; goto error;
break; break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP: case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
if (virDomainGraphicsDefParseXMLRDP(def, node, flags) < 0) if (virDomainGraphicsDefParseXMLRDP(def, node, ctxt, flags) < 0)
goto error; goto error;
break; break;
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
@ -11237,7 +11239,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
goto error; goto error;
break; break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
if (virDomainGraphicsDefParseXMLSpice(def, node, flags) < 0) if (virDomainGraphicsDefParseXMLSpice(def, node, ctxt, flags) < 0)
goto error; goto error;
break; break;
case VIR_DOMAIN_GRAPHICS_TYPE_LAST: case VIR_DOMAIN_GRAPHICS_TYPE_LAST: