[libvirt PATCH v3 31/51] domain_conf: Use virXMLPropTristateXXX in virDomainGraphicsDefParseXMLSpice

Tim Wiederhake twiederh at redhat.com
Fri Mar 19 15:57:28 UTC 2021


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/conf/domain_conf.c | 75 ++++++------------------------------------
 1 file changed, 10 insertions(+), 65 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4684496522..d78d09a4b9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13396,23 +13396,10 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
 
                 def->data.spice.zlib = compressionVal;
             } else if (virXMLNodeNameEqual(cur, "playback")) {
-                int compressionVal;
-                g_autofree char *compression = virXMLPropString(cur, "compression");
-
-                if (!compression) {
-                    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                                   _("spice playback missing compression"));
-                    return -1;
-                }
-
-                if ((compressionVal =
-                     virTristateSwitchTypeFromString(compression)) <= 0) {
-                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                                   _("unknown spice playback compression"));
+                if (virXMLPropTristateSwitch(cur, "compression", true,
+                                             &def->data.spice.playback) < 0)
                     return -1;
-                }
 
-                def->data.spice.playback = compressionVal;
             } else if (virXMLNodeNameEqual(cur, "streaming")) {
                 int modeVal;
                 g_autofree char *mode = virXMLPropString(cur, "mode");
@@ -13431,62 +13418,20 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
 
                 def->data.spice.streaming = modeVal;
             } else if (virXMLNodeNameEqual(cur, "clipboard")) {
-                int copypasteVal;
-                g_autofree char *copypaste = virXMLPropString(cur, "copypaste");
-
-                if (!copypaste) {
-                    virReportError(VIR_ERR_XML_ERROR, "%s",
-                                   _("spice clipboard missing copypaste"));
+                if (virXMLPropTristateBool(cur, "copypaste", true,
+                                           &def->data.spice.copypaste) < 0)
                     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 (!enable) {
-                    virReportError(VIR_ERR_XML_ERROR, "%s",
-                                   _("spice filetransfer missing enable"));
+                if (virXMLPropTristateBool(cur, "enable", true,
+                                           &def->data.spice.filetransfer) < 0)
                     return -1;
-                }
-
-                if ((enableVal =
-                     virTristateBoolTypeFromString(enable)) <= 0) {
-                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                                   _("unknown enable value '%s'"), enable);
-                    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");
+                def->data.spice.rendernode = virXMLPropString(cur,
+                                                              "rendernode");
 
-                if (!enable) {
-                    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);
+                if (virXMLPropTristateBool(cur, "enable", true,
+                                           &def->data.spice.gl) < 0)
                     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




More information about the libvir-list mailing list