Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/conf/domain_conf.c | 66 +++++++++++-------------------------------
1 file changed, 17 insertions(+), 49 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 011745e73a..360528ef1e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13429,23 +13429,18 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
def->data.spice.zlib = compressionVal;
} else if (virXMLNodeNameEqual(cur, "playback")) {
- int compressionVal;
- g_autofree char *compression = virXMLPropString(cur,
"compression");
+ virTristateSwitch compression = VIR_TRISTATE_SWITCH_ABSENT;
- if (!compression) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("spice playback missing compression"));
+ if (virXMLPropOnOff(cur, "compression", &compression) <
0)
return -1;
- }
- if ((compressionVal =
- virTristateSwitchTypeFromString(compression)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("unknown spice playback compression"));
+ if (compression == VIR_TRISTATE_SWITCH_ABSENT) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("spice playback missing compression"));
return -1;
}
- def->data.spice.playback = compressionVal;
+ def->data.spice.playback = compression;
} else if (virXMLNodeNameEqual(cur, "streaming")) {
int modeVal;
g_autofree char *mode = virXMLPropString(cur, "mode");
@@ -13464,62 +13459,35 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
def->data.spice.streaming = modeVal;
} else if (virXMLNodeNameEqual(cur, "clipboard")) {
- int copypasteVal;
- g_autofree char *copypaste = virXMLPropString(cur,
"copypaste");
+ if (virXMLPropYesNo(cur, "copypaste",
&def->data.spice.copypaste) < 0)
+ return -1;
- if (!copypaste) {
+ if (def->data.spice.copypaste == VIR_TRISTATE_BOOL_ABSENT) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("spice clipboard missing copypaste"));
return -1;
}
-
- if ((copypasteVal =
- virTristateBoolTypeFromString(copypaste)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown copypaste value '%s'"),
copypaste);
- return -1;
- }
-
- def->data.spice.copypaste = copypasteVal;
} else if (virXMLNodeNameEqual(cur, "filetransfer")) {
- int enableVal;
- g_autofree char *enable = virXMLPropString(cur, "enable");
+ if (virXMLPropYesNo(cur, "enable",
&def->data.spice.filetransfer) < 0)
+ return -1;
- if (!enable) {
+ if (def->data.spice.filetransfer == VIR_TRISTATE_BOOL_ABSENT) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("spice filetransfer missing enable"));
return -1;
}
+ } else if (virXMLNodeNameEqual(cur, "gl")) {
+ def->data.spice.rendernode = virXMLPropString(cur,
+ "rendernode");
- if ((enableVal =
- virTristateBoolTypeFromString(enable)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown enable value '%s'"),
enable);
+ if (virXMLPropYesNo(cur, "enable", &def->data.spice.gl)
< 0)
return -1;
- }
-
- def->data.spice.filetransfer = enableVal;
- } else if (virXMLNodeNameEqual(cur, "gl")) {
- int enableVal;
- g_autofree char *enable = virXMLPropString(cur, "enable");
- g_autofree char *rendernode = virXMLPropString(cur,
"rendernode");
- if (!enable) {
+ if (def->data.spice.gl == VIR_TRISTATE_BOOL_ABSENT) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("spice gl element missing enable"));
return -1;
}
-
- if ((enableVal =
- virTristateBoolTypeFromString(enable)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown enable value '%s'"),
enable);
- return -1;
- }
-
- def->data.spice.gl = enableVal;
- def->data.spice.rendernode = g_steal_pointer(&rendernode);
-
} else if (virXMLNodeNameEqual(cur, "mouse")) {
int modeVal;
g_autofree char *mode = virXMLPropString(cur, "mode");
--
2.26.2