mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 05:17:54 +03:00
domain_conf: cleanup error paths for graphics parser
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
537d32a2fd
commit
0159b38324
@ -10772,17 +10772,15 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
|
|||||||
char *port = virXMLPropString(node, "port");
|
char *port = virXMLPropString(node, "port");
|
||||||
char *websocket = virXMLPropString(node, "websocket");
|
char *websocket = virXMLPropString(node, "websocket");
|
||||||
char *sharePolicy = virXMLPropString(node, "sharePolicy");
|
char *sharePolicy = virXMLPropString(node, "sharePolicy");
|
||||||
char *autoport;
|
char *autoport = virXMLPropString(node, "autoport");
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
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,
|
||||||
_("cannot parse vnc port %s"), port);
|
_("cannot parse vnc port %s"), port);
|
||||||
VIR_FREE(port);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
VIR_FREE(port);
|
|
||||||
/* Legacy compat syntax, used -1 for auto-port */
|
/* Legacy compat syntax, used -1 for auto-port */
|
||||||
if (def->data.vnc.port == -1) {
|
if (def->data.vnc.port == -1) {
|
||||||
if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
|
if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
|
||||||
@ -10794,13 +10792,12 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
|
|||||||
def->data.vnc.autoport = true;
|
def->data.vnc.autoport = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
|
if (autoport) {
|
||||||
if (STREQ(autoport, "yes")) {
|
if (STREQ(autoport, "yes")) {
|
||||||
if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
|
if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
|
||||||
def->data.vnc.port = 0;
|
def->data.vnc.port = 0;
|
||||||
def->data.vnc.autoport = true;
|
def->data.vnc.autoport = true;
|
||||||
}
|
}
|
||||||
VIR_FREE(autoport);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (websocket) {
|
if (websocket) {
|
||||||
@ -10809,10 +10806,8 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
|
|||||||
&def->data.vnc.websocket) < 0) {
|
&def->data.vnc.websocket) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot parse vnc WebSocket port %s"), websocket);
|
_("cannot parse vnc WebSocket port %s"), websocket);
|
||||||
VIR_FREE(websocket);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
VIR_FREE(websocket);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sharePolicy) {
|
if (sharePolicy) {
|
||||||
@ -10821,13 +10816,12 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
|
|||||||
|
|
||||||
if (policy < 0) {
|
if (policy < 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown vnc display sharing policy '%s'"), sharePolicy);
|
_("unknown vnc display sharing policy '%s'"),
|
||||||
VIR_FREE(sharePolicy);
|
sharePolicy);
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
def->data.vnc.sharePolicy = policy;
|
def->data.vnc.sharePolicy = policy;
|
||||||
}
|
}
|
||||||
VIR_FREE(sharePolicy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def->data.vnc.socket = virXMLPropString(node, "socket");
|
def->data.vnc.socket = virXMLPropString(node, "socket");
|
||||||
@ -10839,6 +10833,10 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
error:
|
error:
|
||||||
|
VIR_FREE(port);
|
||||||
|
VIR_FREE(autoport);
|
||||||
|
VIR_FREE(websocket);
|
||||||
|
VIR_FREE(sharePolicy);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10848,6 +10846,7 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
|
|||||||
xmlNodePtr node)
|
xmlNodePtr node)
|
||||||
{
|
{
|
||||||
char *fullscreen = virXMLPropString(node, "fullscreen");
|
char *fullscreen = virXMLPropString(node, "fullscreen");
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
if (fullscreen != NULL) {
|
if (fullscreen != NULL) {
|
||||||
if (STREQ(fullscreen, "yes")) {
|
if (STREQ(fullscreen, "yes")) {
|
||||||
@ -10857,17 +10856,19 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
|
|||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unknown fullscreen value '%s'"), fullscreen);
|
_("unknown fullscreen value '%s'"), fullscreen);
|
||||||
VIR_FREE(fullscreen);
|
goto cleanup;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
VIR_FREE(fullscreen);
|
|
||||||
} else {
|
} else {
|
||||||
def->data.sdl.fullscreen = false;
|
def->data.sdl.fullscreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
def->data.sdl.xauth = virXMLPropString(node, "xauth");
|
def->data.sdl.xauth = virXMLPropString(node, "xauth");
|
||||||
def->data.sdl.display = virXMLPropString(node, "display");
|
def->data.sdl.display = virXMLPropString(node, "display");
|
||||||
|
|
||||||
return 0;
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(fullscreen);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -10877,52 +10878,44 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDefPtr def,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
char *port = virXMLPropString(node, "port");
|
char *port = virXMLPropString(node, "port");
|
||||||
char *autoport;
|
char *autoport = virXMLPropString(node, "autoport");
|
||||||
char *replaceUser;
|
char *replaceUser = virXMLPropString(node, "replaceUser");
|
||||||
char *multiUser;
|
char *multiUser = virXMLPropString(node, "multiUser");
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
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,
|
||||||
_("cannot parse rdp port %s"), port);
|
_("cannot parse rdp port %s"), port);
|
||||||
VIR_FREE(port);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
/* Legacy compat syntax, used -1 for auto-port */
|
/* Legacy compat syntax, used -1 for auto-port */
|
||||||
if (def->data.rdp.port == -1)
|
if (def->data.rdp.port == -1)
|
||||||
def->data.rdp.autoport = true;
|
def->data.rdp.autoport = true;
|
||||||
|
|
||||||
VIR_FREE(port);
|
|
||||||
} else {
|
} else {
|
||||||
def->data.rdp.port = 0;
|
def->data.rdp.port = 0;
|
||||||
def->data.rdp.autoport = true;
|
def->data.rdp.autoport = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
|
if (STREQ_NULLABLE(autoport, "yes"))
|
||||||
if (STREQ(autoport, "yes"))
|
def->data.rdp.autoport = true;
|
||||||
def->data.rdp.autoport = true;
|
|
||||||
|
|
||||||
VIR_FREE(autoport);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (def->data.rdp.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
|
if (def->data.rdp.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
|
||||||
def->data.rdp.port = 0;
|
def->data.rdp.port = 0;
|
||||||
|
|
||||||
if ((replaceUser = virXMLPropString(node, "replaceUser")) != NULL) {
|
if (STREQ_NULLABLE(replaceUser, "yes"))
|
||||||
if (STREQ(replaceUser, "yes"))
|
def->data.rdp.replaceUser = true;
|
||||||
def->data.rdp.replaceUser = true;
|
|
||||||
VIR_FREE(replaceUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((multiUser = virXMLPropString(node, "multiUser")) != NULL) {
|
if (STREQ_NULLABLE(multiUser, "yes"))
|
||||||
if (STREQ(multiUser, "yes"))
|
def->data.rdp.multiUser = true;
|
||||||
def->data.rdp.multiUser = true;
|
|
||||||
VIR_FREE(multiUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
error:
|
error:
|
||||||
|
VIR_FREE(port);
|
||||||
|
VIR_FREE(autoport);
|
||||||
|
VIR_FREE(replaceUser);
|
||||||
|
VIR_FREE(multiUser);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10932,6 +10925,7 @@ virDomainGraphicsDefParseXMLDesktop(virDomainGraphicsDefPtr def,
|
|||||||
xmlNodePtr node)
|
xmlNodePtr node)
|
||||||
{
|
{
|
||||||
char *fullscreen = virXMLPropString(node, "fullscreen");
|
char *fullscreen = virXMLPropString(node, "fullscreen");
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
if (fullscreen != NULL) {
|
if (fullscreen != NULL) {
|
||||||
if (STREQ(fullscreen, "yes")) {
|
if (STREQ(fullscreen, "yes")) {
|
||||||
@ -10941,16 +10935,18 @@ virDomainGraphicsDefParseXMLDesktop(virDomainGraphicsDefPtr def,
|
|||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unknown fullscreen value '%s'"), fullscreen);
|
_("unknown fullscreen value '%s'"), fullscreen);
|
||||||
VIR_FREE(fullscreen);
|
goto cleanup;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
VIR_FREE(fullscreen);
|
|
||||||
} else {
|
} else {
|
||||||
def->data.desktop.fullscreen = false;
|
def->data.desktop.fullscreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
def->data.desktop.display = virXMLPropString(node, "display");
|
def->data.desktop.display = virXMLPropString(node, "display");
|
||||||
return 0;
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(fullscreen);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -10961,9 +10957,9 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
|
|||||||
{
|
{
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
char *port = virXMLPropString(node, "port");
|
char *port = virXMLPropString(node, "port");
|
||||||
char *tlsPort;
|
char *tlsPort = virXMLPropString(node, "tlsPort");
|
||||||
char *autoport;
|
char *autoport = virXMLPropString(node, "autoport");
|
||||||
char *defaultMode;
|
char *defaultMode = virXMLPropString(node, "defaultMode");
|
||||||
int defaultModeVal;
|
int defaultModeVal;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
@ -10971,45 +10967,35 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
|
|||||||
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,
|
||||||
_("cannot parse spice port %s"), port);
|
_("cannot parse spice port %s"), port);
|
||||||
VIR_FREE(port);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
VIR_FREE(port);
|
|
||||||
} else {
|
} else {
|
||||||
def->data.spice.port = 0;
|
def->data.spice.port = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsPort = virXMLPropString(node, "tlsPort");
|
|
||||||
if (tlsPort) {
|
if (tlsPort) {
|
||||||
if (virStrToLong_i(tlsPort, NULL, 10, &def->data.spice.tlsPort) < 0) {
|
if (virStrToLong_i(tlsPort, NULL, 10, &def->data.spice.tlsPort) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot parse spice tlsPort %s"), tlsPort);
|
_("cannot parse spice tlsPort %s"), tlsPort);
|
||||||
VIR_FREE(tlsPort);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
VIR_FREE(tlsPort);
|
|
||||||
} else {
|
} else {
|
||||||
def->data.spice.tlsPort = 0;
|
def->data.spice.tlsPort = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
|
if (STREQ_NULLABLE(autoport, "yes"))
|
||||||
if (STREQ(autoport, "yes"))
|
def->data.spice.autoport = true;
|
||||||
def->data.spice.autoport = true;
|
|
||||||
VIR_FREE(autoport);
|
|
||||||
}
|
|
||||||
|
|
||||||
def->data.spice.defaultMode = VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY;
|
def->data.spice.defaultMode = VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY;
|
||||||
|
|
||||||
if ((defaultMode = virXMLPropString(node, "defaultMode")) != NULL) {
|
if (defaultMode) {
|
||||||
if ((defaultModeVal = virDomainGraphicsSpiceChannelModeTypeFromString(defaultMode)) < 0) {
|
if ((defaultModeVal = virDomainGraphicsSpiceChannelModeTypeFromString(defaultMode)) < 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown default spice channel mode %s"),
|
_("unknown default spice channel mode %s"),
|
||||||
defaultMode);
|
defaultMode);
|
||||||
VIR_FREE(defaultMode);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
def->data.spice.defaultMode = defaultModeVal;
|
def->data.spice.defaultMode = defaultModeVal;
|
||||||
VIR_FREE(defaultMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->data.spice.port == -1 && def->data.spice.tlsPort == -1) {
|
if (def->data.spice.port == -1 && def->data.spice.tlsPort == -1) {
|
||||||
@ -11256,6 +11242,10 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
error:
|
error:
|
||||||
|
VIR_FREE(port);
|
||||||
|
VIR_FREE(tlsPort);
|
||||||
|
VIR_FREE(autoport);
|
||||||
|
VIR_FREE(defaultMode);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user