[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[RFCv2 23/46] conf: Replace virDomainGraphicsDefParseXMLSDL(hardcoded) with virDomainGraphicsSDLDefParseXML(generated)



Signed-off-by: Shi Lei <shi_lei massclouds com>
---
 po/POTFILES.in         |  1 +
 src/conf/domain_conf.c | 53 ++----------------------------------------
 src/conf/domain_conf.h | 12 ++++++----
 src/conf/meson.build   |  1 +
 4 files changed, 11 insertions(+), 56 deletions(-)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0356f1e..4de0d14 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@
 @BUILDDIR src/access/viraccessapicheckqemu.c
 @BUILDDIR src/admin/admin_client.h
 @BUILDDIR src/admin/admin_server_dispatch_stubs.h
+ BUILDDIR@src/conf/domain_conf.generated.c
 @BUILDDIR src/conf/network_conf.generated.c
 @BUILDDIR src/remote/remote_client_bodies.h
 @BUILDDIR src/remote/remote_daemon_dispatch_stubs.h
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 72ac4f4..c1f8847 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1826,8 +1826,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
         break;
 
     case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
-        VIR_FREE(def->data.sdl.display);
-        VIR_FREE(def->data.sdl.xauth);
+        virDomainGraphicsSDLDefClear(&def->data.sdl);
         break;
 
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
@@ -14514,54 +14513,6 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
 }
 
 
-static int
-virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
-                                xmlNodePtr node,
-                                xmlXPathContextPtr ctxt)
-{
-    VIR_XPATH_NODE_AUTORESTORE(ctxt)
-    int enableVal;
-    xmlNodePtr glNode;
-    g_autofree char *fullscreen = virXMLPropString(node, "fullscreen");
-    g_autofree char *enable = NULL;
-
-    ctxt->node = node;
-
-    if (fullscreen != NULL) {
-        if (virStringParseYesNo(fullscreen, &def->data.sdl.fullscreen) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unknown fullscreen value '%s'"), fullscreen);
-            return -1;
-        }
-    } else {
-        def->data.sdl.fullscreen = false;
-    }
-
-    def->data.sdl.xauth = virXMLPropString(node, "xauth");
-    def->data.sdl.display = virXMLPropString(node, "display");
-
-    glNode = virXPathNode("./gl", ctxt);
-    if (glNode) {
-        enable = virXMLPropString(glNode, "enable");
-        if (!enable) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("sdl gl element missing enable"));
-            return -1;
-        }
-
-        enableVal = virTristateBoolTypeFromString(enable);
-        if (enableVal < 0) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unknown enable value '%s'"), enable);
-            return -1;
-        }
-        def->data.sdl.gl = enableVal;
-    }
-
-    return 0;
-}
-
-
 static int
 virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDefPtr def,
                                 xmlNodePtr node,
@@ -14990,7 +14941,7 @@ virDomainGraphicsDefParseXML(virDomainXMLOptionPtr xmlopt,
             goto error;
         break;
     case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
-        if (virDomainGraphicsDefParseXMLSDL(def, node, ctxt) < 0)
+        if (virDomainGraphicsSDLDefParseXML(node, &def->data.sdl, NULL, def, NULL) < 0)
             goto error;
         break;
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3d14aa1..13d2d4f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1672,11 +1672,11 @@ struct _virDomainGraphicsListenDef {
     bool autoGenerated;
 };
 
-struct _virDomainGraphicsSDLDef {
-    char *display;
-    char *xauth;
-    bool fullscreen;
-    virTristateBool gl;
+struct _virDomainGraphicsSDLDef {   /* genparse */
+    char *display;                  /* xmlattr */
+    char *xauth;                    /* xmlattr */
+    bool fullscreen;                /* xmlattr */
+    virTristateBool gl;             /* xmlattr:gl/enable */
 };
 
 struct _virDomainGraphicsVNCDef {
@@ -3916,3 +3916,5 @@ virHostdevIsMdevDevice(const virDomainHostdevDef *hostdev)
 bool
 virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev)
     ATTRIBUTE_NONNULL(1);
+
+#include "domain_conf.generated.h"
diff --git a/src/conf/meson.build b/src/conf/meson.build
index 0619ca6..2796520 100644
--- a/src/conf/meson.build
+++ b/src/conf/meson.build
@@ -1,5 +1,6 @@
 xmlgen_input = [
   'network_conf.h',
+  'domain_conf.h',
 ]
 
 xmlgen_output = []
-- 
2.25.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]